OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/renderer/extension_helper.h" | 5 #include "extensions/renderer/extension_helper.h" |
6 | 6 |
7 #include "content/public/renderer/render_view.h" | 7 #include "content/public/renderer/render_view.h" |
8 #include "content/public/renderer/render_view_visitor.h" | 8 #include "content/public/renderer/render_view_visitor.h" |
9 #include "extensions/common/api/messaging/message.h" | 9 #include "extensions/common/api/messaging/message.h" |
10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
11 #include "extensions/common/extension_messages.h" | 11 #include "extensions/common/extension_messages.h" |
| 12 #include "extensions/renderer/api/automation/automation_api_helper.h" |
12 #include "extensions/renderer/console.h" | 13 #include "extensions/renderer/console.h" |
13 #include "extensions/renderer/dispatcher.h" | 14 #include "extensions/renderer/dispatcher.h" |
14 #include "extensions/renderer/messaging_bindings.h" | 15 #include "extensions/renderer/messaging_bindings.h" |
15 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 16 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
16 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 17 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
17 #include "third_party/WebKit/public/web/WebDocument.h" | 18 #include "third_party/WebKit/public/web/WebDocument.h" |
18 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 19 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
19 #include "third_party/WebKit/public/web/WebView.h" | 20 #include "third_party/WebKit/public/web/WebView.h" |
20 | 21 |
21 using content::ConsoleMessageLevel; | 22 using content::ConsoleMessageLevel; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 116 } |
116 | 117 |
117 ExtensionHelper::ExtensionHelper(content::RenderView* render_view, | 118 ExtensionHelper::ExtensionHelper(content::RenderView* render_view, |
118 Dispatcher* dispatcher) | 119 Dispatcher* dispatcher) |
119 : content::RenderViewObserver(render_view), | 120 : content::RenderViewObserver(render_view), |
120 content::RenderViewObserverTracker<ExtensionHelper>(render_view), | 121 content::RenderViewObserverTracker<ExtensionHelper>(render_view), |
121 dispatcher_(dispatcher), | 122 dispatcher_(dispatcher), |
122 view_type_(VIEW_TYPE_INVALID), | 123 view_type_(VIEW_TYPE_INVALID), |
123 tab_id_(-1), | 124 tab_id_(-1), |
124 browser_window_id_(-1) { | 125 browser_window_id_(-1) { |
| 126 // Lifecycle managed by RenderViewObserver. |
| 127 new AutomationApiHelper(render_view); |
125 } | 128 } |
126 | 129 |
127 ExtensionHelper::~ExtensionHelper() { | 130 ExtensionHelper::~ExtensionHelper() { |
128 } | 131 } |
129 | 132 |
130 bool ExtensionHelper::OnMessageReceived(const IPC::Message& message) { | 133 bool ExtensionHelper::OnMessageReceived(const IPC::Message& message) { |
131 bool handled = true; | 134 bool handled = true; |
132 IPC_BEGIN_MESSAGE_MAP(ExtensionHelper, message) | 135 IPC_BEGIN_MESSAGE_MAP(ExtensionHelper, message) |
133 IPC_MESSAGE_HANDLER(ExtensionMsg_Response, OnExtensionResponse) | 136 IPC_MESSAGE_HANDLER(ExtensionMsg_Response, OnExtensionResponse) |
134 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) | 137 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); | 259 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); |
257 ScriptContext* script_context = | 260 ScriptContext* script_context = |
258 dispatcher_->script_context_set().GetByV8Context(v8_context); | 261 dispatcher_->script_context_set().GetByV8Context(v8_context); |
259 if (!script_context) | 262 if (!script_context) |
260 return; | 263 return; |
261 script_context->module_system()->CallModuleMethod("app.window", | 264 script_context->module_system()->CallModuleMethod("app.window", |
262 "onAppWindowClosed"); | 265 "onAppWindowClosed"); |
263 } | 266 } |
264 | 267 |
265 } // namespace extensions | 268 } // namespace extensions |
OLD | NEW |