summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-03 21:37:05 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-03 21:37:05 +0000
commit2a8f24e3021fbddb8b48c5f1d7a8002b1d6c78e4 (patch)
tree6db0afb317d65451452cfbaeac331bb8a46d3f6b /chrome/browser/extensions
parent0daa69b89baf4369da28bfcfa3e06e3715afb9cb (diff)
downloadchromium_src-2a8f24e3021fbddb8b48c5f1d7a8002b1d6c78e4.zip
chromium_src-2a8f24e3021fbddb8b48c5f1d7a8002b1d6c78e4.tar.gz
chromium_src-2a8f24e3021fbddb8b48c5f1d7a8002b1d6c78e4.tar.bz2
Fix some UI issues with omnibox extensions in incognito.
Also moved a shared method from ExtensionEventRouter to ExtensionsService. BUG=58210 TEST=Install the extension in chrome/common/extensions/docs/examples/extensions/chrome_search. You should not see the UI artifacts described in the bug. Review URL: http://codereview.chromium.org/4234004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_event_router.cc5
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc3
-rw-r--r--chrome/browser/extensions/extensions_service.cc7
-rw-r--r--chrome/browser/extensions/extensions_service.h4
4 files changed, 16 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc
index c033454..4fc48e3 100644
--- a/chrome/browser/extensions/extension_event_router.cc
+++ b/chrome/browser/extensions/extension_event_router.cc
@@ -168,6 +168,7 @@ void ExtensionEventRouter::DispatchEventImpl(
return;
std::set<EventListener>& listeners = it->second;
+ ExtensionsService* service = profile_->GetExtensionsService();
// Send the event only to renderers that are listening for it.
for (std::set<EventListener>::iterator listener = listeners.begin();
@@ -185,7 +186,9 @@ void ExtensionEventRouter::DispatchEventImpl(
// incognito tab event sent to a normal process, or vice versa).
bool cross_incognito = restrict_to_profile &&
listener->process->profile() != restrict_to_profile;
- if (cross_incognito && !CanCrossIncognito(profile_, listener->extension_id))
+ const Extension* extension = service->GetExtensionById(
+ listener->extension_id, false);
+ if (cross_incognito && !service->CanCrossIncognito(extension))
continue;
DispatchEvent(listener->process, listener->extension_id,
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 783a8bf..d402962 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -450,8 +450,7 @@ void ExtensionFunctionDispatcher::HandleRequest(
DCHECK(service);
const Extension* extension = service->GetExtensionById(extension_id(), false);
DCHECK(extension);
- function->set_include_incognito(service->IsIncognitoEnabled(extension) &&
- !extension->incognito_split_mode());
+ function->set_include_incognito(service->CanCrossIncognito(extension));
if (!service->ExtensionBindingsAllowed(function->source_url()) ||
!extension->HasApiPermission(function->name())) {
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 98681de..734bdef 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -1336,6 +1336,13 @@ void ExtensionsService::SetIsIncognitoEnabled(const Extension* extension,
}
}
+bool ExtensionsService::CanCrossIncognito(const Extension* extension) {
+ // We allow the extension to see events and data from another profile iff it
+ // uses "spanning" behavior and it has incognito access. "split" mode
+ // extensions only see events for a matching profile.
+ return IsIncognitoEnabled(extension) && !extension->incognito_split_mode();
+}
+
bool ExtensionsService::AllowFileAccess(const Extension* extension) {
return (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableExtensionsFileAccessCheck) ||
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index 213471c..7cc2c9d 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -181,6 +181,10 @@ class ExtensionsService
bool IsIncognitoEnabled(const Extension* extension);
void SetIsIncognitoEnabled(const Extension* extension, bool enabled);
+ // Returns true if the given extension can see events and data from another
+ // sub-profile (incognito to original profile, or vice versa).
+ bool CanCrossIncognito(const Extension* extension);
+
// Whether this extension can inject scripts into pages with file URLs.
bool AllowFileAccess(const Extension* extension);
void SetAllowFileAccess(const Extension* extension, bool allow);