blob: 278745990bf0735db672c6960225eb1bd14a8c7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/renderer/extensions/extension_frame_helper.h"
#include "content/public/renderer/render_frame.h"
#include "extensions/common/extension_messages.h"
#include "extensions/renderer/console.h"
#include "extensions/renderer/dispatcher.h"
#include "third_party/WebKit/public/web/WebConsoleMessage.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
namespace extensions {
ExtensionFrameHelper::ExtensionFrameHelper(content::RenderFrame* render_frame,
Dispatcher* extension_dispatcher)
: content::RenderFrameObserver(render_frame),
content::RenderFrameObserverTracker<ExtensionFrameHelper>(render_frame),
extension_dispatcher_(extension_dispatcher) {}
ExtensionFrameHelper::~ExtensionFrameHelper() {
}
void ExtensionFrameHelper::WillReleaseScriptContext(
v8::Handle<v8::Context> context,
int world_id) {
// TODO(thestig): Remove scaffolding once this file no longer builds with
// extensions disabled.
#if defined(ENABLE_EXTENSIONS)
extension_dispatcher_->WillReleaseScriptContext(
render_frame()->GetWebFrame(), context, world_id);
#endif
}
bool ExtensionFrameHelper::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ExtensionFrameHelper, message)
IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole,
OnAddMessageToConsole)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void ExtensionFrameHelper::OnAddMessageToConsole(
content::ConsoleMessageLevel level,
const std::string& message) {
console::AddMessage(render_frame()->GetRenderView(), level, message);
}
} // namespace extensions
|