summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/extensions
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-11 20:30:19 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-11 20:30:19 +0000
commit7600428cfa774cfd645d503b50a3d9b4ce1780ac (patch)
tree8e9f84e57e2c303473ca3735c5281e10a4568950 /chrome/renderer/extensions
parent699f8748055aa448acf0e6dc4b59ce914688796d (diff)
downloadchromium_src-7600428cfa774cfd645d503b50a3d9b4ce1780ac.zip
chromium_src-7600428cfa774cfd645d503b50a3d9b4ce1780ac.tar.gz
chromium_src-7600428cfa774cfd645d503b50a3d9b4ce1780ac.tar.bz2
Revert "Looks like this introduced leaks in sync ui tests. Sigh."
This reverts commit 471e46f5060ce0fd9413b0bc5ffbe78a2e4c7d02. TBR=mpcomplete@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/extensions')
-rw-r--r--chrome/renderer/extensions/extension_dispatcher.cc29
-rw-r--r--chrome/renderer/extensions/extension_dispatcher.h8
2 files changed, 25 insertions, 12 deletions
diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc
index a2bb8c0..13339c3 100644
--- a/chrome/renderer/extensions/extension_dispatcher.cc
+++ b/chrome/renderer/extensions/extension_dispatcher.cc
@@ -35,7 +35,8 @@ using WebKit::WebFrame;
using WebKit::WebSecurityPolicy;
using WebKit::WebString;
-ExtensionDispatcher::ExtensionDispatcher() {
+ExtensionDispatcher::ExtensionDispatcher()
+ : is_webkit_initialized_(false) {
std::string type_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessType);
is_extension_process_ = type_str == switches::kExtensionProcess ||
@@ -88,6 +89,17 @@ 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() {
@@ -202,6 +214,11 @@ 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(),
@@ -210,13 +227,7 @@ void ExtensionDispatcher::OnActivateExtension(
false);
}
- SetHostPermissions(extension->url(),
- extension->host_permissions());
-}
-
-void ExtensionDispatcher::SetHostPermissions(
- const GURL& extension_url,
- const std::vector<URLPattern>& permissions) {
+ const URLPatternList& permissions = extension->host_permissions();
for (size_t i = 0; i < permissions.size(); ++i) {
const char* schemes[] = {
chrome::kHttpScheme,
@@ -227,7 +238,7 @@ void ExtensionDispatcher::SetHostPermissions(
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());
diff --git a/chrome/renderer/extensions/extension_dispatcher.h b/chrome/renderer/extensions/extension_dispatcher.h
index c966d37..bce3c0f 100644
--- a/chrome/renderer/extensions/extension_dispatcher.h
+++ b/chrome/renderer/extensions/extension_dispatcher.h
@@ -81,9 +81,8 @@ class ExtensionDispatcher : public RenderProcessObserver {
// extension is for Chrome Extensions only.
void RegisterExtension(v8::Extension* extension, bool restrict_to_extensions);
- // Sets the host permissions for a particular extension.
- void SetHostPermissions(const GURL& extension_url,
- const std::vector<URLPattern>& permissions);
+ // Sets up the host permissions for |extension|.
+ void InitHostPermissions(const Extension* extension);
// True if this renderer is running extensions.
bool is_extension_process_;
@@ -108,6 +107,9 @@ class ExtensionDispatcher : public RenderProcessObserver {
// The extensions that are active in this process.
std::set<std::string> active_extension_ids_;
+ // True once WebKit has been initialized (and it is therefore safe to poke).
+ bool is_webkit_initialized_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher);
};