[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | d266361 | 2013-03-17 09:25:56 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 5 | #ifndef EXTENSIONS_RENDERER_CONSOLE_H_ |
6 | #define EXTENSIONS_RENDERER_CONSOLE_H_ | ||||
[email protected] | d266361 | 2013-03-17 09:25:56 | [diff] [blame] | 7 | |
8 | #include <string> | ||||
9 | |||||
Abhijeet Kandalkar | a5928a0a | 2019-03-13 05:04:42 | [diff] [blame] | 10 | #include "third_party/blink/public/mojom/devtools/console_message.mojom.h" |
[email protected] | d266361 | 2013-03-17 09:25:56 | [diff] [blame] | 11 | #include "v8/include/v8.h" |
12 | |||||
[email protected] | d266361 | 2013-03-17 09:25:56 | [diff] [blame] | 13 | namespace extensions { |
rdevlin.cronin | baa379d | 2017-04-19 20:49:31 | [diff] [blame] | 14 | class ScriptContext; |
[email protected] | d266361 | 2013-03-17 09:25:56 | [diff] [blame] | 15 | |
rdevlin.cronin | baa379d | 2017-04-19 20:49:31 | [diff] [blame] | 16 | // Utility for logging console messages. |
[email protected] | d266361 | 2013-03-17 09:25:56 | [diff] [blame] | 17 | namespace console { |
18 | |||||
rdevlin.cronin | baa379d | 2017-04-19 20:49:31 | [diff] [blame] | 19 | // Adds |message| to the console of of the |script_context|. If |script_context| |
20 | // is null, LOG()s the message instead. | ||||
21 | void AddMessage(ScriptContext* script_context, | ||||
Abhijeet Kandalkar | a5928a0a | 2019-03-13 05:04:42 | [diff] [blame] | 22 | blink::mojom::ConsoleMessageLevel level, |
[email protected] | d266361 | 2013-03-17 09:25:56 | [diff] [blame] | 23 | const std::string& message); |
24 | |||||
jbroman | b1ad11a | 2017-02-27 23:59:24 | [diff] [blame] | 25 | // Logs an Error then crashes the current process. |
rdevlin.cronin | baa379d | 2017-04-19 20:49:31 | [diff] [blame] | 26 | void Fatal(ScriptContext* context, const std::string& message); |
jbroman | b1ad11a | 2017-02-27 23:59:24 | [diff] [blame] | 27 | |
[email protected] | 7205a9c | 2013-08-03 03:15:00 | [diff] [blame] | 28 | // Returns a new v8::Object with each standard log method (Debug/Log/Warn/Error) |
29 | // bound to respective debug/log/warn/error methods. This is a direct drop-in | ||||
30 | // replacement for the standard devtools console.* methods usually accessible | ||||
31 | // from JS. | ||||
kalman | fb6f10ac | 2014-11-06 23:55:35 | [diff] [blame] | 32 | v8::Local<v8::Object> AsV8Object(v8::Isolate* isolate); |
[email protected] | 7205a9c | 2013-08-03 03:15:00 | [diff] [blame] | 33 | |
[email protected] | d266361 | 2013-03-17 09:25:56 | [diff] [blame] | 34 | } // namespace console |
35 | |||||
36 | } // namespace extensions | ||||
37 | |||||
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 38 | #endif // EXTENSIONS_RENDERER_CONSOLE_H_ |