OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/extension_helper.h" | 5 #include "chrome/renderer/extensions/extension_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/extensions/api/messaging/message.h" | 15 #include "chrome/common/extensions/api/messaging/message.h" |
| 16 #include "chrome/common/extensions/chrome_extension_messages.h" |
16 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
17 #include "chrome/common/extensions/extension_messages.h" | |
18 #include "chrome/common/render_messages.h" | 18 #include "chrome/common/render_messages.h" |
19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
20 #include "chrome/renderer/extensions/chrome_v8_context.h" | 20 #include "chrome/renderer/extensions/chrome_v8_context.h" |
21 #include "chrome/renderer/extensions/console.h" | 21 #include "chrome/renderer/extensions/console.h" |
22 #include "chrome/renderer/extensions/dispatcher.h" | 22 #include "chrome/renderer/extensions/dispatcher.h" |
23 #include "chrome/renderer/extensions/messaging_bindings.h" | 23 #include "chrome/renderer/extensions/messaging_bindings.h" |
24 #include "chrome/renderer/extensions/user_script_scheduler.h" | 24 #include "chrome/renderer/extensions/user_script_scheduler.h" |
25 #include "chrome/renderer/extensions/user_script_slave.h" | 25 #include "chrome/renderer/extensions/user_script_slave.h" |
26 #include "chrome/renderer/web_apps.h" | 26 #include "chrome/renderer/web_apps.h" |
27 #include "content/public/renderer/render_view.h" | 27 #include "content/public/renderer/render_view.h" |
28 #include "content/public/renderer/render_view_visitor.h" | 28 #include "content/public/renderer/render_view_visitor.h" |
29 #include "extensions/common/constants.h" | 29 #include "extensions/common/constants.h" |
| 30 #include "extensions/common/extension_messages.h" |
30 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 31 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
31 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 32 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
32 #include "third_party/WebKit/public/web/WebDocument.h" | 33 #include "third_party/WebKit/public/web/WebDocument.h" |
33 #include "third_party/WebKit/public/web/WebFrame.h" | 34 #include "third_party/WebKit/public/web/WebFrame.h" |
34 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" | 35 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" |
35 #include "third_party/WebKit/public/web/WebView.h" | 36 #include "third_party/WebKit/public/web/WebView.h" |
36 | 37 |
37 using content::ConsoleMessageLevel; | 38 using content::ConsoleMessageLevel; |
38 using blink::WebConsoleMessage; | 39 using blink::WebConsoleMessage; |
39 using blink::WebDataSource; | 40 using blink::WebDataSource; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 bool handled = true; | 156 bool handled = true; |
156 IPC_BEGIN_MESSAGE_MAP(ExtensionHelper, message) | 157 IPC_BEGIN_MESSAGE_MAP(ExtensionHelper, message) |
157 IPC_MESSAGE_HANDLER(ExtensionMsg_Response, OnExtensionResponse) | 158 IPC_MESSAGE_HANDLER(ExtensionMsg_Response, OnExtensionResponse) |
158 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) | 159 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) |
159 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnConnect, | 160 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnConnect, |
160 OnExtensionDispatchOnConnect) | 161 OnExtensionDispatchOnConnect) |
161 IPC_MESSAGE_HANDLER(ExtensionMsg_DeliverMessage, OnExtensionDeliverMessage) | 162 IPC_MESSAGE_HANDLER(ExtensionMsg_DeliverMessage, OnExtensionDeliverMessage) |
162 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnDisconnect, | 163 IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnDisconnect, |
163 OnExtensionDispatchOnDisconnect) | 164 OnExtensionDispatchOnDisconnect) |
164 IPC_MESSAGE_HANDLER(ExtensionMsg_ExecuteCode, OnExecuteCode) | 165 IPC_MESSAGE_HANDLER(ExtensionMsg_ExecuteCode, OnExecuteCode) |
165 IPC_MESSAGE_HANDLER(ExtensionMsg_GetApplicationInfo, OnGetApplicationInfo) | 166 IPC_MESSAGE_HANDLER(ChromeExtensionMsg_GetApplicationInfo, |
| 167 OnGetApplicationInfo) |
166 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId) | 168 IPC_MESSAGE_HANDLER(ExtensionMsg_SetTabId, OnSetTabId) |
167 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, | 169 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateBrowserWindowId, |
168 OnUpdateBrowserWindowId) | 170 OnUpdateBrowserWindowId) |
169 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, | 171 IPC_MESSAGE_HANDLER(ExtensionMsg_NotifyRenderViewType, |
170 OnNotifyRendererViewType) | 172 OnNotifyRendererViewType) |
171 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, | 173 IPC_MESSAGE_HANDLER(ExtensionMsg_AddMessageToConsole, |
172 OnAddMessageToConsole) | 174 OnAddMessageToConsole) |
173 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, | 175 IPC_MESSAGE_HANDLER(ExtensionMsg_AppWindowClosed, |
174 OnAppWindowClosed); | 176 OnAppWindowClosed); |
175 IPC_MESSAGE_UNHANDLED(handled = false) | 177 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // any icon with a data URL to have originated from a favicon. We don't want | 335 // any icon with a data URL to have originated from a favicon. We don't want |
334 // to decode arbitrary data URLs in the browser process. See | 336 // to decode arbitrary data URLs in the browser process. See |
335 // http://b/issue?id=1162972 | 337 // http://b/issue?id=1162972 |
336 for (size_t i = 0; i < app_info.icons.size(); ++i) { | 338 for (size_t i = 0; i < app_info.icons.size(); ++i) { |
337 if (app_info.icons[i].url.SchemeIs(content::kDataScheme)) { | 339 if (app_info.icons[i].url.SchemeIs(content::kDataScheme)) { |
338 app_info.icons.erase(app_info.icons.begin() + i); | 340 app_info.icons.erase(app_info.icons.begin() + i); |
339 --i; | 341 --i; |
340 } | 342 } |
341 } | 343 } |
342 | 344 |
343 Send(new ExtensionHostMsg_DidGetApplicationInfo( | 345 Send(new ChromeExtensionHostMsg_DidGetApplicationInfo( |
344 routing_id(), page_id, app_info)); | 346 routing_id(), page_id, app_info)); |
345 } | 347 } |
346 | 348 |
347 void ExtensionHelper::OnNotifyRendererViewType(ViewType type) { | 349 void ExtensionHelper::OnNotifyRendererViewType(ViewType type) { |
348 view_type_ = type; | 350 view_type_ = type; |
349 } | 351 } |
350 | 352 |
351 void ExtensionHelper::OnSetTabId(int init_tab_id) { | 353 void ExtensionHelper::OnSetTabId(int init_tab_id) { |
352 CHECK_EQ(tab_id_, -1); | 354 CHECK_EQ(tab_id_, -1); |
353 CHECK_GE(init_tab_id, 0); | 355 CHECK_GE(init_tab_id, 0); |
(...skipping 15 matching lines...) Expand all Loading... |
369 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); | 371 render_view()->GetWebView()->mainFrame()->mainWorldScriptContext(); |
370 ChromeV8Context* chrome_v8_context = | 372 ChromeV8Context* chrome_v8_context = |
371 dispatcher_->v8_context_set().GetByV8Context(script_context); | 373 dispatcher_->v8_context_set().GetByV8Context(script_context); |
372 if (!chrome_v8_context) | 374 if (!chrome_v8_context) |
373 return; | 375 return; |
374 chrome_v8_context->module_system()->CallModuleMethod( | 376 chrome_v8_context->module_system()->CallModuleMethod( |
375 "app.window", "onAppWindowClosed"); | 377 "app.window", "onAppWindowClosed"); |
376 } | 378 } |
377 | 379 |
378 } // namespace extensions | 380 } // namespace extensions |
OLD | NEW |