diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-07 00:42:37 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-07 00:42:37 +0000 |
commit | 6a3d8ce4de591ece61446f506eb8b722240c731e (patch) | |
tree | 43bc9bd9cfc1d25ed5581377b216a5dbec1c04fb /extensions | |
parent | 528885e55ad3cb7b5b8b89110666ae6ac4d4a26a (diff) | |
download | chromium_src-6a3d8ce4de591ece61446f506eb8b722240c731e.zip chromium_src-6a3d8ce4de591ece61446f506eb8b722240c731e.tar.gz chromium_src-6a3d8ce4de591ece61446f506eb8b722240c731e.tar.bz2 |
Make ExtensionsBrowserClient wrap some utility functions.
Add IsExtensionIncognitoEnabled() and
CanExtensionCrossIncognito() to ExtensionsBrowserClient to
break extensions/browser's dependency on
chrome/browser/extensions/extension_util.h.
BUG=315853
Review URL: https://codereview.chromium.org/152513010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/browser/DEPS | 1 | ||||
-rw-r--r-- | extensions/browser/event_router.cc | 4 | ||||
-rw-r--r-- | extensions/browser/extension_prefs.h | 4 | ||||
-rw-r--r-- | extensions/browser/extensions_browser_client.h | 13 | ||||
-rw-r--r-- | extensions/browser/process_manager.cc | 4 |
5 files changed, 19 insertions, 7 deletions
diff --git a/extensions/browser/DEPS b/extensions/browser/DEPS index 97d8cdb..7a5f4e1 100644 --- a/extensions/browser/DEPS +++ b/extensions/browser/DEPS @@ -19,7 +19,6 @@ include_rules = [ "+chrome/browser/extensions/extension_host.h", "+chrome/browser/extensions/extension_service.h", "+chrome/browser/extensions/extension_system_factory.h", - "+chrome/browser/extensions/extension_util.h", "+chrome/browser/renderer_host/chrome_render_message_filter.h", "+chrome/common/extensions/extension_messages.h", "+chrome/common/extensions/features/feature_channel.h", diff --git a/extensions/browser/event_router.cc b/extensions/browser/event_router.cc index d145059..58cbf24 100644 --- a/extensions/browser/event_router.cc +++ b/extensions/browser/event_router.cc @@ -13,7 +13,6 @@ #include "base/values.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_util.h" #include "chrome/common/extensions/extension_messages.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_process_host.h" @@ -558,7 +557,8 @@ bool EventRouter::CanDispatchEventToBrowserContext( context != event->restrict_to_browser_context; if (!cross_incognito) return true; - return util::CanCrossIncognito(extension, context); + return ExtensionsBrowserClient::Get()->CanExtensionCrossIncognito( + extension, context); } bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent( diff --git a/extensions/browser/extension_prefs.h b/extensions/browser/extension_prefs.h index 1128cd4..6d5ac2d 100644 --- a/extensions/browser/extension_prefs.h +++ b/extensions/browser/extension_prefs.h @@ -383,7 +383,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, // Returns true if the user enabled this extension to be loaded in incognito // mode. // - // IMPORTANT: you probably want to use extension_utils::IsIncognitoEnabled + // IMPORTANT: you probably want to use extensions::util::IsIncognitoEnabled // instead of this method. bool IsIncognitoEnabled(const std::string& extension_id) const; void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); @@ -391,7 +391,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, // Returns true if the user has chosen to allow this extension to inject // scripts into pages with file URLs. // - // IMPORTANT: you probably want to use extension_utils::AllowFileAccess + // IMPORTANT: you probably want to use extensions::util::AllowFileAccess // instead of this method. bool AllowFileAccess(const std::string& extension_id) const; void SetAllowFileAccess(const std::string& extension_id, bool allow); diff --git a/extensions/browser/extensions_browser_client.h b/extensions/browser/extensions_browser_client.h index 7cff76d..a132678 100644 --- a/extensions/browser/extensions_browser_client.h +++ b/extensions/browser/extensions_browser_client.h @@ -5,6 +5,7 @@ #ifndef EXTENSIONS_BROWSER_EXTENSIONS_BROWSER_CLIENT_H_ #define EXTENSIONS_BROWSER_EXTENSIONS_BROWSER_CLIENT_H_ +#include <string> #include <vector> #include "base/memory/scoped_ptr.h" @@ -23,6 +24,7 @@ namespace extensions { class ApiActivityMonitor; class AppSorting; +class Extension; class ExtensionSystem; // Interface to allow the extensions module to make browser-process-specific @@ -66,6 +68,17 @@ class ExtensionsBrowserClient { virtual content::BrowserContext* GetOriginalContext( content::BrowserContext* context) = 0; + // Returns true if |extension_id| can run in an incognito window. + virtual bool IsExtensionIncognitoEnabled( + const std::string& extension_id, + content::BrowserContext* context) const = 0; + + // Returns true if |extension| can see events and data from another + // sub-profile (incognito to original profile, or vice versa). + virtual bool CanExtensionCrossIncognito( + const extensions::Extension* extension, + content::BrowserContext* context) const = 0; + // Returns the PrefService associated with |context|. virtual PrefService* GetPrefServiceForContext( content::BrowserContext* context) = 0; diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc index 53d39fdc..89f2809 100644 --- a/extensions/browser/process_manager.cc +++ b/extensions/browser/process_manager.cc @@ -17,7 +17,6 @@ #include "chrome/browser/extensions/api/runtime/runtime_api.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/extensions/extension_util.h" #include "chrome/common/extensions/extension_messages.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" @@ -869,7 +868,8 @@ IncognitoProcessManager::IncognitoProcessManager( ExtensionHost* IncognitoProcessManager::CreateBackgroundHost( const Extension* extension, const GURL& url) { if (IncognitoInfo::IsSplitMode(extension)) { - if (util::IsIncognitoEnabled(extension->id(), GetBrowserContext())) + if (ExtensionsBrowserClient::Get()->IsExtensionIncognitoEnabled( + extension->id(), GetBrowserContext())) return ProcessManager::CreateBackgroundHost(extension, url); } else { // Do nothing. If an extension is spanning, then its original-profile |