| Index: chrome/renderer/extensions/extension_process_bindings.cc
|
| diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
|
| index f0da91dfbaec65677fadac818a318147f0d64cdb..7e999dd38264ede5ebd697761d97a2d495d13f69 100644
|
| --- a/chrome/renderer/extensions/extension_process_bindings.cc
|
| +++ b/chrome/renderer/extensions/extension_process_bindings.cc
|
| @@ -62,8 +62,9 @@ typedef std::map<std::string, bool> PermissionsMap;
|
| // A map of extension ID to permissions map.
|
| typedef std::map<std::string, PermissionsMap> ExtensionPermissionsMap;
|
|
|
| -// 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[] = {
|
| @@ -94,7 +95,7 @@ struct SingletonData {
|
| std::set<std::string> function_names_;
|
| PageActionIdMap page_action_ids_;
|
| ExtensionPermissionsMap permissions_;
|
| - IncognitoEnabledMap incognito_enabled_map_;
|
| + CrossProfileAccessMap cross_profile_access_map_;
|
| };
|
|
|
| static std::set<std::string>* GetFunctionNameSet() {
|
| @@ -109,8 +110,8 @@ static PermissionsMap* GetPermissionsMap(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) {
|
| @@ -264,6 +265,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);
|
| @@ -562,6 +565,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
|
| @@ -582,14 +592,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
|
|
|