diff options
Diffstat (limited to 'chrome/renderer/extensions/extension_dispatcher.cc')
-rw-r--r-- | chrome/renderer/extensions/extension_dispatcher.cc | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc index 13339c3..a2bb8c0 100644 --- a/chrome/renderer/extensions/extension_dispatcher.cc +++ b/chrome/renderer/extensions/extension_dispatcher.cc @@ -35,8 +35,7 @@ using WebKit::WebFrame; using WebKit::WebSecurityPolicy; using WebKit::WebString; -ExtensionDispatcher::ExtensionDispatcher() - : is_webkit_initialized_(false) { +ExtensionDispatcher::ExtensionDispatcher() { std::string type_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( switches::kProcessType); is_extension_process_ = type_str == switches::kExtensionProcess || @@ -89,17 +88,6 @@ void ExtensionDispatcher::WebKitInitialized() { RegisterExtension(EventBindings::Get(this), true); RegisterExtension(RendererExtensionBindings::Get(this), true); RegisterExtension(ExtensionApiTestV8Extension::Get(), true); - - // Initialize host permissions for any extensions that were activated before - // WebKit was initialized. - for (std::set<std::string>::iterator iter = active_extension_ids_.begin(); - iter != active_extension_ids_.end(); ++iter) { - const Extension* extension = extensions_.GetByID(*iter); - if (extension) - InitHostPermissions(extension); - } - - is_webkit_initialized_ = true; } void ExtensionDispatcher::IdleNotification() { @@ -214,11 +202,6 @@ void ExtensionDispatcher::OnActivateExtension( if (!extension) return; - if (is_webkit_initialized_) - InitHostPermissions(extension); -} - -void ExtensionDispatcher::InitHostPermissions(const Extension* extension) { if (extension->HasApiPermission(Extension::kManagementPermission)) { WebSecurityPolicy::addOriginAccessWhitelistEntry( extension->url(), @@ -227,7 +210,13 @@ void ExtensionDispatcher::InitHostPermissions(const Extension* extension) { false); } - const URLPatternList& permissions = extension->host_permissions(); + SetHostPermissions(extension->url(), + extension->host_permissions()); +} + +void ExtensionDispatcher::SetHostPermissions( + const GURL& extension_url, + const std::vector<URLPattern>& permissions) { for (size_t i = 0; i < permissions.size(); ++i) { const char* schemes[] = { chrome::kHttpScheme, @@ -238,7 +227,7 @@ void ExtensionDispatcher::InitHostPermissions(const Extension* extension) { for (size_t j = 0; j < arraysize(schemes); ++j) { if (permissions[i].MatchesScheme(schemes[j])) { WebSecurityPolicy::addOriginAccessWhitelistEntry( - extension->url(), + extension_url, WebString::fromUTF8(schemes[j]), WebString::fromUTF8(permissions[i].host()), permissions[i].match_subdomains()); |