Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chrome / renderer / extensions / extension_frame_helper.cc
blobc88c4cd1fb4a9dbaf9c89039f272522e4b0c54a9
1 // Copyright 2013 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 #include "chrome/renderer/extensions/extension_frame_helper.h"
7 #include "content/public/renderer/render_frame.h"
8 #include "extensions/common/extension_messages.h"
9 #include "extensions/renderer/console.h"
10 #include "extensions/renderer/dispatcher.h"
11 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
12 #include "third_party/WebKit/public/web/WebFrame.h"
14 namespace extensions {
16 ExtensionFrameHelper::ExtensionFrameHelper(content::RenderFrame* render_frame,
17 Dispatcher* extension_dispatcher)
18 : content::RenderFrameObserver(render_frame),
19 content::RenderFrameObserverTracker<ExtensionFrameHelper>(render_frame),
20 extension_dispatcher_(extension_dispatcher) {}
22 ExtensionFrameHelper::~ExtensionFrameHelper() {
25 void ExtensionFrameHelper::WillReleaseScriptContext(
26 v8::Handle<v8::Context> context,
27 int world_id) {
28 extension_dispatcher_->WillReleaseScriptContext(
29 render_frame()->GetWebFrame(), context, world_id);
32 bool ExtensionFrameHelper::OnMessageReceived(const IPC::Message& message) {
33 bool handled = true;
34 IPC_BEGIN_MESSAGE_MAP(ExtensionFrameHelper, message)
35 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole,
36 OnAddMessageToConsole)
37 IPC_MESSAGE_UNHANDLED(handled = false)
38 IPC_END_MESSAGE_MAP()
39 return handled;
42 void ExtensionFrameHelper::OnAddMessageToConsole(
43 content::ConsoleMessageLevel level,
44 const std::string& message) {
45 console::AddMessage(render_frame()->GetRenderView(), level, message);
48 } // namespace extensions