| Index: chrome/browser/extensions/extension_preference_helpers.cc
|
| diff --git a/chrome/browser/extensions/extension_preference_helpers.cc b/chrome/browser/extensions/extension_preference_helpers.cc
|
| index 44fe036db95af8e20cfea3188ffdcd4183200c4f..bbfbd060fa66af726779f221da90f9b034a89ece 100644
|
| --- a/chrome/browser/extensions/extension_preference_helpers.cc
|
| +++ b/chrome/browser/extensions/extension_preference_helpers.cc
|
| @@ -51,6 +51,8 @@ const char* GetLevelOfControl(
|
| bool incognito) {
|
| PrefService* prefs = incognito ? profile->GetOffTheRecordPrefs()
|
| : profile->GetPrefs();
|
| + bool from_incognito = false;
|
| + bool* from_incognito_ptr = incognito ? &from_incognito : NULL;
|
| const PrefService::Preference* pref =
|
| prefs->FindPreference(browser_pref.c_str());
|
| CHECK(pref);
|
| @@ -59,8 +61,11 @@ const char* GetLevelOfControl(
|
| if (!pref->IsExtensionModifiable())
|
| return kNotControllable;
|
|
|
| - if (ep->DoesExtensionControlPref(extension_id, browser_pref, incognito))
|
| + if (ep->DoesExtensionControlPref(extension_id,
|
| + browser_pref,
|
| + from_incognito_ptr)) {
|
| return kControlledByThisExtension;
|
| + }
|
|
|
| if (ep->CanExtensionControlPref(extension_id, browser_pref, incognito))
|
| return kControllableByThisExtension;
|
| @@ -80,13 +85,15 @@ void DispatchEventToExtensions(
|
| return;
|
| ExtensionService* extension_service = profile->GetExtensionService();
|
| const ExtensionSet* extensions = extension_service->extensions();
|
| + ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
|
| for (ExtensionSet::const_iterator it = extensions->begin();
|
| it != extensions->end(); ++it) {
|
| std::string extension_id = (*it)->id();
|
| // TODO(bauerb): Only iterate over registered event listeners.
|
| if (router->ExtensionHasEventListener(extension_id, event_name) &&
|
| (*it)->HasAPIPermission(permission) &&
|
| - (!incognito || extension_service->CanCrossIncognito(*it))) {
|
| + (!incognito || (*it)->incognito_split_mode() ||
|
| + extension_service->CanCrossIncognito(*it))) {
|
| // Inject level of control key-value.
|
| DictionaryValue* dict;
|
| bool rv = args->GetDictionary(0, &dict);
|
| @@ -94,11 +101,30 @@ void DispatchEventToExtensions(
|
| std::string level_of_control =
|
| GetLevelOfControl(profile, extension_id, browser_pref, incognito);
|
| dict->SetString(kLevelOfControlKey, level_of_control);
|
| -
|
| std::string json_args;
|
| base::JSONWriter::Write(args, &json_args);
|
| +
|
| + // If the extension is in incognito split mode,
|
| + // a) incognito pref changes are visible only to the incognito tabs
|
| + // b) regular pref changes are visible only to the incognito tabs if the
|
| + // incognito pref has not alredy been set
|
| + Profile* restrict_to_profile = NULL;
|
| + bool from_incognito = false;
|
| + if ((*it)->incognito_split_mode()) {
|
| + if (incognito && extension_service->IsIncognitoEnabled(extension_id)) {
|
| + restrict_to_profile = profile->GetOffTheRecordProfile();
|
| + } else if (!incognito &&
|
| + extension_prefs->DoesExtensionControlPref(
|
| + extension_id,
|
| + browser_pref,
|
| + &from_incognito) &&
|
| + from_incognito) {
|
| + restrict_to_profile = profile;
|
| + }
|
| + }
|
| +
|
| router->DispatchEventToExtension(
|
| - extension_id, event_name, json_args, NULL, GURL());
|
| + extension_id, event_name, json_args, restrict_to_profile, GURL());
|
| }
|
| }
|
| }
|
|
|