Roll src/third_party/WebKit 9301d6f:4619053 (svn 201058:201059)
[chromium-blink-merge.git] / extensions / renderer / console.h
blob79d338e773aa9122b8e457c12842c7d93fab5c76
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_RENDERER_CONSOLE_H_
6 #define EXTENSIONS_RENDERER_CONSOLE_H_
8 #include <string>
10 #include "content/public/common/console_message_level.h"
11 #include "v8/include/v8.h"
13 namespace content {
14 class RenderFrame;
17 namespace extensions {
19 // Utility for logging messages to RenderFrames.
20 namespace console {
22 // Adds |message| to the console of |render_frame|. If |render_frame| is null,
23 // LOG()s the message instead.
24 void Debug(content::RenderFrame* render_frame, const std::string& message);
25 void Log(content::RenderFrame* render_frame, const std::string& message);
26 void Warn(content::RenderFrame* render_frame, const std::string& message);
27 void Error(content::RenderFrame* render_frame, const std::string& message);
29 // Logs an Error then crashes the current process.
30 void Fatal(content::RenderFrame* render_frame, const std::string& message);
32 void AddMessage(content::RenderFrame* render_frame,
33 content::ConsoleMessageLevel level,
34 const std::string& message);
36 // Returns a new v8::Object with each standard log method (Debug/Log/Warn/Error)
37 // bound to respective debug/log/warn/error methods. This is a direct drop-in
38 // replacement for the standard devtools console.* methods usually accessible
39 // from JS.
40 v8::Local<v8::Object> AsV8Object(v8::Isolate* isolate);
42 } // namespace console
44 } // namespace extensions
46 #endif // EXTENSIONS_RENDERER_CONSOLE_H_