Chromium Code Reviews| 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..0c2346e213acb39c1f4bed54238cc65b35f7bc41 100644 |
| --- a/chrome/browser/extensions/extension_preference_helpers.cc |
| +++ b/chrome/browser/extensions/extension_preference_helpers.cc |
| @@ -80,13 +80,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))) { |
|
Bernhard Bauer
2012/06/19 01:12:56
Nit: I think this needs to be indented by one less
mitchellwrosen
2012/06/20 18:28:26
Done.
|
| // Inject level of control key-value. |
| DictionaryValue* dict; |
| bool rv = args->GetDictionary(0, &dict); |
| @@ -94,11 +96,27 @@ 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 chanes are visible only to the incognito tabs if the |
|
Bernhard Bauer
2012/06/19 01:12:56
Nit: "pref changes"
mitchellwrosen
2012/06/20 18:28:26
Done.
|
| + // incognito pref has not alredy been set |
| + Profile* restrict_to_profile = NULL; |
| + if ((*it)->incognito_split_mode()) { |
| + if (incognito && extension_service->IsIncognitoEnabled(extension_id)) { |
| + restrict_to_profile = profile->GetOffTheRecordProfile(); |
| + } else if (!incognito && |
| + extension_prefs->DoesExtensionControlIncognitoPref( |
| + extension_id, |
| + browser_pref)) { |
| + restrict_to_profile = profile; |
| + } |
| + } |
| + |
| router->DispatchEventToExtension( |
| - extension_id, event_name, json_args, NULL, GURL()); |
| + extension_id, event_name, json_args, restrict_to_profile, GURL()); |
| } |
| } |
| } |