| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_dispatcher.h" | 5 #include "chrome/renderer/extensions/extension_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/common/child_process_logging.h" | 8 #include "chrome/common/child_process_logging.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 ExtensionDispatcher::~ExtensionDispatcher() { | 55 ExtensionDispatcher::~ExtensionDispatcher() { |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool ExtensionDispatcher::OnControlMessageReceived( | 58 bool ExtensionDispatcher::OnControlMessageReceived( |
| 59 const IPC::Message& message) { | 59 const IPC::Message& message) { |
| 60 bool handled = true; | 60 bool handled = true; |
| 61 IPC_BEGIN_MESSAGE_MAP(ExtensionDispatcher, message) | 61 IPC_BEGIN_MESSAGE_MAP(ExtensionDispatcher, message) |
| 62 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnMessageInvoke) | 62 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnMessageInvoke) |
| 63 IPC_MESSAGE_HANDLER(ExtensionMsg_DeliverMessage, OnDeliverMessage) | |
| 64 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFunctionNames, OnSetFunctionNames) | 63 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFunctionNames, OnSetFunctionNames) |
| 65 IPC_MESSAGE_HANDLER(ExtensionMsg_Loaded, OnLoaded) | 64 IPC_MESSAGE_HANDLER(ExtensionMsg_Loaded, OnLoaded) |
| 66 IPC_MESSAGE_HANDLER(ExtensionMsg_Unloaded, OnUnloaded) | 65 IPC_MESSAGE_HANDLER(ExtensionMsg_Unloaded, OnUnloaded) |
| 67 IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingWhitelist, | 66 IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingWhitelist, |
| 68 OnSetScriptingWhitelist) | 67 OnSetScriptingWhitelist) |
| 69 IPC_MESSAGE_HANDLER(ExtensionMsg_ActivateExtension, OnActivateExtension) | 68 IPC_MESSAGE_HANDLER(ExtensionMsg_ActivateExtension, OnActivateExtension) |
| 70 IPC_MESSAGE_HANDLER(ExtensionMsg_ActivateApplication, OnActivateApplication) | 69 IPC_MESSAGE_HANDLER(ExtensionMsg_ActivateApplication, OnActivateApplication) |
| 71 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions) | 70 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions) |
| 72 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts) | 71 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts) |
| 73 IPC_MESSAGE_UNHANDLED(handled = false) | 72 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 extension_id, function_name, args, NULL, event_url); | 135 extension_id, function_name, args, NULL, event_url); |
| 137 | 136 |
| 138 // Reset the idle handler each time there's any activity like event or message | 137 // Reset the idle handler each time there's any activity like event or message |
| 139 // dispatch, for which Invoke is the chokepoint. | 138 // dispatch, for which Invoke is the chokepoint. |
| 140 if (is_extension_process_) { | 139 if (is_extension_process_) { |
| 141 RenderThread::current()->ScheduleIdleHandler( | 140 RenderThread::current()->ScheduleIdleHandler( |
| 142 kInitialExtensionIdleHandlerDelayS); | 141 kInitialExtensionIdleHandlerDelayS); |
| 143 } | 142 } |
| 144 } | 143 } |
| 145 | 144 |
| 146 void ExtensionDispatcher::OnDeliverMessage(int target_port_id, | |
| 147 const std::string& message) { | |
| 148 RendererExtensionBindings::DeliverMessage(target_port_id, | |
| 149 message, | |
| 150 NULL); // All render views. | |
| 151 } | |
| 152 | |
| 153 void ExtensionDispatcher::OnLoaded(const ExtensionMsg_Loaded_Params& params) { | 145 void ExtensionDispatcher::OnLoaded(const ExtensionMsg_Loaded_Params& params) { |
| 154 scoped_refptr<const Extension> extension(params.ConvertToExtension()); | 146 scoped_refptr<const Extension> extension(params.ConvertToExtension()); |
| 155 if (!extension) { | 147 if (!extension) { |
| 156 // This can happen if extension parsing fails for any reason. One reason | 148 // This can happen if extension parsing fails for any reason. One reason |
| 157 // this can legitimately happen is if the | 149 // this can legitimately happen is if the |
| 158 // --enable-experimental-extension-apis changes at runtime, which happens | 150 // --enable-experimental-extension-apis changes at runtime, which happens |
| 159 // during browser tests. Existing renderers won't know about the change. | 151 // during browser tests. Existing renderers won't know about the change. |
| 160 return; | 152 return; |
| 161 } | 153 } |
| 162 | 154 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 child_process_logging::SetActiveExtensions(active_extensions); | 327 child_process_logging::SetActiveExtensions(active_extensions); |
| 336 } | 328 } |
| 337 | 329 |
| 338 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, | 330 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, |
| 339 bool restrict_to_extensions) { | 331 bool restrict_to_extensions) { |
| 340 if (restrict_to_extensions) | 332 if (restrict_to_extensions) |
| 341 restricted_v8_extensions_.insert(extension->name()); | 333 restricted_v8_extensions_.insert(extension->name()); |
| 342 | 334 |
| 343 RenderThread::current()->RegisterExtension(extension); | 335 RenderThread::current()->RegisterExtension(extension); |
| 344 } | 336 } |
| OLD | NEW |