| 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/dispatcher.h" | 5 #include "extensions/renderer/dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/containers/scoped_ptr_map.h" | 10 #include "base/containers/scoped_ptr_map.h" |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 } | 983 } |
| 984 | 984 |
| 985 void Dispatcher::OnDispatchOnDisconnect(int port_id, | 985 void Dispatcher::OnDispatchOnDisconnect(int port_id, |
| 986 const std::string& error_message) { | 986 const std::string& error_message) { |
| 987 MessagingBindings::DispatchOnDisconnect(*script_context_set_, port_id, | 987 MessagingBindings::DispatchOnDisconnect(*script_context_set_, port_id, |
| 988 error_message, | 988 error_message, |
| 989 NULL); // All render frames. | 989 NULL); // All render frames. |
| 990 } | 990 } |
| 991 | 991 |
| 992 void Dispatcher::OnLoaded( | 992 void Dispatcher::OnLoaded( |
| 993 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions) { | 993 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions, |
| 994 const std::string& webview_partition_id) { |
| 994 for (const auto& param : loaded_extensions) { | 995 for (const auto& param : loaded_extensions) { |
| 995 std::string error; | 996 std::string error; |
| 996 scoped_refptr<const Extension> extension = param.ConvertToExtension(&error); | 997 scoped_refptr<const Extension> extension = param.ConvertToExtension(&error); |
| 997 if (!extension.get()) { | 998 if (!extension.get()) { |
| 998 NOTREACHED() << error; | 999 NOTREACHED() << error; |
| 999 // Note: in tests |param.id| has been observed to be empty (see comment | 1000 // Note: in tests |param.id| has been observed to be empty (see comment |
| 1000 // just below) so this isn't all that reliable. | 1001 // just below) so this isn't all that reliable. |
| 1001 extension_load_errors_[param.id] = error; | 1002 extension_load_errors_[param.id] = error; |
| 1002 continue; | 1003 continue; |
| 1003 } | 1004 } |
| 1004 | 1005 |
| 1005 RendererExtensionRegistry* extension_registry = | 1006 RendererExtensionRegistry* extension_registry = |
| 1006 RendererExtensionRegistry::Get(); | 1007 RendererExtensionRegistry::Get(); |
| 1008 extension_registry->SetWebviewPartitionID(webview_partition_id); |
| 1007 // TODO(kalman): This test is deliberately not a CHECK (though I wish it | 1009 // TODO(kalman): This test is deliberately not a CHECK (though I wish it |
| 1008 // could be) and uses extension->id() not params.id: | 1010 // could be) and uses extension->id() not params.id: |
| 1009 // 1. For some reason params.id can be empty. I've only seen it with | 1011 // 1. For some reason params.id can be empty. I've only seen it with |
| 1010 // the webstore extension, in tests, and I've spent some time trying to | 1012 // the webstore extension, in tests, and I've spent some time trying to |
| 1011 // figure out why - but cost/benefit won. | 1013 // figure out why - but cost/benefit won. |
| 1012 // 2. The browser only sends this IPC to RenderProcessHosts once, but the | 1014 // 2. The browser only sends this IPC to RenderProcessHosts once, but the |
| 1013 // Dispatcher is attached to a RenderThread. Presumably there is a | 1015 // Dispatcher is attached to a RenderThread. Presumably there is a |
| 1014 // mismatch there. In theory one would think it's possible for the | 1016 // mismatch there. In theory one would think it's possible for the |
| 1015 // browser to figure this out itself - but again, cost/benefit. | 1017 // browser to figure this out itself - but again, cost/benefit. |
| 1016 if (!extension_registry->Contains(extension->id())) | 1018 if (!extension_registry->Contains(extension->id())) |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 void Dispatcher::AddChannelSpecificFeatures() { | 1571 void Dispatcher::AddChannelSpecificFeatures() { |
| 1570 // chrome-extension: resources should be allowed to register a Service Worker. | 1572 // chrome-extension: resources should be allowed to register a Service Worker. |
| 1571 if (FeatureProvider::GetBehaviorFeature(BehaviorFeature::kServiceWorker) | 1573 if (FeatureProvider::GetBehaviorFeature(BehaviorFeature::kServiceWorker) |
| 1572 ->IsAvailableToEnvironment() | 1574 ->IsAvailableToEnvironment() |
| 1573 .is_available()) | 1575 .is_available()) |
| 1574 WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers( | 1576 WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers( |
| 1575 WebString::fromUTF8(kExtensionScheme)); | 1577 WebString::fromUTF8(kExtensionScheme)); |
| 1576 } | 1578 } |
| 1577 | 1579 |
| 1578 } // namespace extensions | 1580 } // namespace extensions |
| OLD | NEW |