diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 18:40:32 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 18:40:32 +0000 |
commit | bc535ee5bb4eece29f5d88bcc688613b3b208b27 (patch) | |
tree | 37b90c6bbbe98732c81515b35f02f8b835ac5df7 /chrome/renderer/extensions/extension_process_bindings.cc | |
parent | 7566dbf757617f9e77f4a7f9f031402eb7818b04 (diff) | |
download | chromium_src-bc535ee5bb4eece29f5d88bcc688613b3b208b27.zip chromium_src-bc535ee5bb4eece29f5d88bcc688613b3b208b27.tar.gz chromium_src-bc535ee5bb4eece29f5d88bcc688613b3b208b27.tar.bz2 |
Add support for a "split" incognito behavior for extensions.
- On by default for apps, off by default for extensions.
- Split mode means "run incognito extensions in a separate process if the user
says OK, and the two processes can only see their own profile."
- Spanning mode is what we have now, and means "run a single extension process,
but allow it to access both profiles if the user says OK."
BUG=49232
BUG=49114
TEST=extensions still work in incognito when you check "Allow in Incognito".
Review URL: http://codereview.chromium.org/3210007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58033 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/extensions/extension_process_bindings.cc')
-rw-r--r-- | chrome/renderer/extensions/extension_process_bindings.cc | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc index 38d2919..340502f 100644 --- a/chrome/renderer/extensions/extension_process_bindings.cc +++ b/chrome/renderer/extensions/extension_process_bindings.cc @@ -63,8 +63,9 @@ typedef std::vector<std::string> PermissionsList; // A map of extension ID to permissions map. typedef std::map<std::string, PermissionsList> ExtensionPermissionsList; -// A map of extension ID to whether this extension was enabled in incognito. -typedef std::map<std::string, bool> IncognitoEnabledMap; +// A map of extension ID to whether this extension can access data from other +// profiles. +typedef std::map<std::string, bool> CrossProfileAccessMap; const char kExtensionName[] = "chrome/ExtensionProcessBindings"; const char* kExtensionDeps[] = { @@ -79,7 +80,7 @@ struct SingletonData { std::set<std::string> function_names_; PageActionIdMap page_action_ids_; ExtensionPermissionsList permissions_; - IncognitoEnabledMap incognito_enabled_map_; + CrossProfileAccessMap cross_profile_access_map_; }; static std::set<std::string>* GetFunctionNameSet() { @@ -94,8 +95,8 @@ static PermissionsList* GetPermissionsList(const std::string& extension_id) { return &Singleton<SingletonData>()->permissions_[extension_id]; } -static IncognitoEnabledMap* GetIncognitoEnabledMap() { - return &Singleton<SingletonData>()->incognito_enabled_map_; +static CrossProfileAccessMap* GetCrossProfileAccessMap() { + return &Singleton<SingletonData>()->cross_profile_access_map_; } static void GetActiveExtensionIDs(std::set<std::string>* extension_ids) { @@ -249,6 +250,8 @@ class ExtensionImpl : public ExtensionBase { return v8::FunctionTemplate::New(SetIconCommon); } else if (name->Equals(v8::String::New("IsExtensionProcess"))) { return v8::FunctionTemplate::New(IsExtensionProcess); + } else if (name->Equals(v8::String::New("IsIncognitoProcess"))) { + return v8::FunctionTemplate::New(IsIncognitoProcess); } return ExtensionBase::GetNativeFunction(name); @@ -547,6 +550,13 @@ class ExtensionImpl : public ExtensionBase { retval = EventBindings::GetRenderThread()->IsExtensionProcess(); return v8::Boolean::New(retval); } + + static v8::Handle<v8::Value> IsIncognitoProcess(const v8::Arguments& args) { + bool retval = false; + if (EventBindings::GetRenderThread()) + retval = EventBindings::GetRenderThread()->IsIncognitoProcess(); + return v8::Boolean::New(retval); + } }; } // namespace @@ -567,14 +577,18 @@ void ExtensionProcessBindings::SetFunctionNames( } void ExtensionProcessBindings::SetIncognitoEnabled( - const std::string& extension_id, bool enabled) { - (*GetIncognitoEnabledMap())[extension_id] = enabled; + const std::string& extension_id, bool enabled, bool incognito_split_mode) { + // 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. + (*GetCrossProfileAccessMap())[extension_id] = + enabled && !incognito_split_mode; } // static -bool ExtensionProcessBindings::HasIncognitoEnabled( +bool ExtensionProcessBindings::AllowCrossProfile( const std::string& extension_id) { - return (!extension_id.empty() && (*GetIncognitoEnabledMap())[extension_id]); + return (!extension_id.empty() && (*GetCrossProfileAccessMap())[extension_id]); } // static |