Chromium Code Reviews| Index: extensions/renderer/dispatcher.cc |
| diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc |
| index e870f86b52338d30e4b2f81f49011ba8edf59c44..36804b7052318487e6635d192d6e1072290120e3 100644 |
| --- a/extensions/renderer/dispatcher.cc |
| +++ b/extensions/renderer/dispatcher.cc |
| @@ -70,6 +70,7 @@ |
| #include "extensions/renderer/print_native_handler.h" |
| #include "extensions/renderer/process_info_native_handler.h" |
| #include "extensions/renderer/render_frame_observer_natives.h" |
| +#include "extensions/renderer/renderer_extension_registry.h" |
| #include "extensions/renderer/request_sender.h" |
| #include "extensions/renderer/runtime_custom_bindings.h" |
| #include "extensions/renderer/safe_builtins.h" |
| @@ -201,11 +202,14 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate) |
| kInitialExtensionIdleHandlerDelayMs); |
| } |
| - script_context_set_.reset( |
| - new ScriptContextSet(&extensions_, &active_extension_ids_)); |
| - user_script_set_manager_.reset(new UserScriptSetManager(&extensions_)); |
| - script_injection_manager_.reset( |
| - new ScriptInjectionManager(&extensions_, user_script_set_manager_.get())); |
| + script_context_set_.reset(new ScriptContextSet( |
| + RendererExtensionRegistry::GetRegistry()->GetMainThreadExtensionSet(), |
|
not at google - send to devlin
2015/08/17 20:43:05
It's dangerous to be sending in a thread-unsafe ve
annekao
2015/08/17 23:51:10
Done. The main thread version has to be passed in
|
| + &active_extension_ids_)); |
| + user_script_set_manager_.reset(new UserScriptSetManager( |
| + RendererExtensionRegistry::GetRegistry()->GetMainThreadExtensionSet())); |
| + script_injection_manager_.reset(new ScriptInjectionManager( |
| + RendererExtensionRegistry::GetRegistry()->GetMainThreadExtensionSet(), |
| + user_script_set_manager_.get())); |
| user_script_set_manager_observer_.Add(user_script_set_manager_.get()); |
| request_sender_.reset(new RequestSender(this)); |
| PopulateSourceMap(); |
| @@ -222,7 +226,7 @@ bool Dispatcher::IsExtensionActive(const std::string& extension_id) const { |
| bool is_active = |
| active_extension_ids_.find(extension_id) != active_extension_ids_.end(); |
| if (is_active) |
| - CHECK(extensions_.Contains(extension_id)); |
| + CHECK(RendererExtensionRegistry::GetRegistry()->Contains(extension_id)); |
| return is_active; |
| } |
| @@ -330,7 +334,8 @@ void Dispatcher::DidCreateDocumentElement(blink::WebLocalFrame* frame) { |
| frame, frame->document().url(), true /* match_about_blank */); |
| const Extension* extension = |
| - extensions_.GetExtensionOrAppByURL(effective_document_url); |
| + RendererExtensionRegistry::GetRegistry()->GetExtensionOrAppByURL( |
| + effective_document_url); |
| if (extension && |
| (extension->is_extension() || extension->is_platform_app())) { |
| @@ -412,7 +417,8 @@ void Dispatcher::InvokeModuleSystemMethod(content::RenderFrame* render_frame, |
| // Tell the browser process when an event has been dispatched with a lazy |
| // background page active. |
| - const Extension* extension = extensions_.GetByID(extension_id); |
| + const Extension* extension = |
| + RendererExtensionRegistry::GetRegistry()->GetByID(extension_id); |
| if (extension && BackgroundInfo::HasLazyBackgroundPage(extension) && |
| module_name == kEventBindings && |
| function_name == kEventDispatchFunction) { |
| @@ -701,7 +707,7 @@ void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system, |
| } |
| void Dispatcher::LoadExtensionForTest(const Extension* extension) { |
| - CHECK(extensions_.Insert(extension)); |
| + CHECK(RendererExtensionRegistry::GetRegistry()->Insert(extension)); |
|
not at google - send to devlin
2015/08/17 20:43:05
You could even just delete LoadExtensionForTest an
annekao
2015/08/17 23:51:10
Done.
|
| } |
| bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) { |
| @@ -755,7 +761,8 @@ void Dispatcher::WebKitInitialized() { |
| // Initialize host permissions for any extensions that were activated before |
| // WebKit was initialized. |
| for (const std::string& extension_id : active_extension_ids_) { |
| - const Extension* extension = extensions_.GetByID(extension_id); |
| + const Extension* extension = |
| + RendererExtensionRegistry::GetRegistry()->GetByID(extension_id); |
| CHECK(extension); |
| InitOriginPermissions(extension); |
| } |
| @@ -789,7 +796,8 @@ void Dispatcher::OnRenderProcessShutdown() { |
| } |
| void Dispatcher::OnActivateExtension(const std::string& extension_id) { |
| - const Extension* extension = extensions_.GetByID(extension_id); |
| + const Extension* extension = |
| + RendererExtensionRegistry::GetRegistry()->GetByID(extension_id); |
| if (!extension) { |
| // Extension was activated but was never loaded. This probably means that |
| // the renderer failed to load it (or the browser failed to tell us when it |
| @@ -888,8 +896,8 @@ void Dispatcher::OnLoaded( |
| // Dispatcher is attached to a RenderThread. Presumably there is a |
| // mismatch there. In theory one would think it's possible for the |
| // browser to figure this out itself - but again, cost/benefit. |
| - if (!extensions_.Contains(extension->id())) |
| - extensions_.Insert(extension); |
| + if (!RendererExtensionRegistry::GetRegistry()->Contains(extension->id())) |
|
not at google - send to devlin
2015/08/17 20:43:05
When you use RendererExtensionRegistry multiple ti
annekao
2015/08/17 23:51:10
Done.
|
| + RendererExtensionRegistry::GetRegistry()->Insert(extension); |
| } |
| // Update the available bindings for all contexts. These may have changed if |
| @@ -952,7 +960,7 @@ void Dispatcher::OnTransferBlobs(const std::vector<std::string>& blob_uuids) { |
| void Dispatcher::OnUnloaded(const std::string& id) { |
| // See comment in OnLoaded for why it would be nice, but perhaps incorrect, |
| // to CHECK here rather than guarding. |
| - if (!extensions_.Remove(id)) |
| + if (!RendererExtensionRegistry::GetRegistry()->Remove(id)) |
| return; |
| active_extension_ids_.erase(id); |
| @@ -988,7 +996,8 @@ void Dispatcher::OnUnloaded(const std::string& id) { |
| void Dispatcher::OnUpdatePermissions( |
| const ExtensionMsg_UpdatePermissions_Params& params) { |
| - const Extension* extension = extensions_.GetByID(params.extension_id); |
| + const Extension* extension = |
| + RendererExtensionRegistry::GetRegistry()->GetByID(params.extension_id); |
| if (!extension) |
| return; |
| @@ -1013,7 +1022,8 @@ void Dispatcher::OnUpdateTabSpecificPermissions(const GURL& visible_url, |
| const URLPatternSet& new_hosts, |
| bool update_origin_whitelist, |
| int tab_id) { |
| - const Extension* extension = extensions_.GetByID(extension_id); |
| + const Extension* extension = |
| + RendererExtensionRegistry::GetRegistry()->GetByID(extension_id); |
| if (!extension) |
| return; |
| @@ -1039,7 +1049,8 @@ void Dispatcher::OnClearTabSpecificPermissions( |
| bool update_origin_whitelist, |
| int tab_id) { |
| for (const std::string& id : extension_ids) { |
| - const Extension* extension = extensions_.GetByID(id); |
| + const Extension* extension = |
| + RendererExtensionRegistry::GetRegistry()->GetByID(id); |
| if (extension) { |
| URLPatternSet old_effective = |
| extension->permissions_data()->GetEffectiveHostPermissions(); |
| @@ -1280,7 +1291,7 @@ bool Dispatcher::IsRuntimeAvailableToContext(ScriptContext* context) { |
| context->GetAvailability("surfaceWorkerInternal").is_available()) { |
| return true; |
| } |
| - for (const auto& extension : extensions_) { |
| + for (const auto& extension : *RendererExtensionRegistry::GetRegistry()) { |
| ExternallyConnectableInfo* info = static_cast<ExternallyConnectableInfo*>( |
| extension->GetManifestData(manifest_keys::kExternallyConnectable)); |
| if (info && info->matches.MatchesURL(context->GetURL())) |
| @@ -1291,7 +1302,7 @@ bool Dispatcher::IsRuntimeAvailableToContext(ScriptContext* context) { |
| void Dispatcher::UpdateContentCapabilities(ScriptContext* context) { |
| APIPermissionSet permissions; |
| - for (const auto& extension : extensions_) { |
| + for (const auto& extension : *RendererExtensionRegistry::GetRegistry()) { |
| const ContentCapabilitiesInfo& info = |
| ContentCapabilitiesInfo::Get(extension.get()); |
| if (info.url_patterns.MatchesURL(context->GetURL())) { |
| @@ -1318,7 +1329,8 @@ bool Dispatcher::IsWithinPlatformApp() { |
| for (std::set<std::string>::iterator iter = active_extension_ids_.begin(); |
| iter != active_extension_ids_.end(); |
| ++iter) { |
| - const Extension* extension = extensions_.GetByID(*iter); |
| + const Extension* extension = |
| + RendererExtensionRegistry::GetRegistry()->GetByID(*iter); |
| if (extension && extension->is_platform_app()) |
| return true; |
| } |