Chromium Code Reviews| Index: chrome/browser/extensions/extension_preference_api.cc |
| diff --git a/chrome/browser/extensions/extension_preference_api.cc b/chrome/browser/extensions/extension_preference_api.cc |
| index 2f81eaf0cb0d4bc356d456f14362a664d01e8dc1..4c60348d7f34fe12ffc16f9dad086fc20d6a057c 100644 |
| --- a/chrome/browser/extensions/extension_preference_api.cc |
| +++ b/chrome/browser/extensions/extension_preference_api.cc |
| @@ -13,6 +13,7 @@ |
| #include "base/values.h" |
| #include "chrome/browser/extensions/extension_event_router.h" |
| #include "chrome/browser/extensions/extension_prefs.h" |
| +#include "chrome/browser/extensions/extension_prefs_scope.h" |
| #include "chrome/browser/extensions/extension_proxy_api.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/profiles/profile.h" |
| @@ -35,7 +36,10 @@ const char kControlledByThisExtension[] = "ControlledByThisExtension"; |
| const char kIncognito[] = "incognito"; |
| const char kIncognitoSpecific[] = "incognitoSpecific"; |
| +const char kScope[] = "scope"; |
| const char kLevelOfControl[] = "levelOfControl"; |
| +const char kRegular[] = "regular"; |
| +const char kIncognitoPersistent[] = "incognito_persistent"; |
| const char kValue[] = "value"; |
| const char kOnPrefChangeEffectiveFormat[] = |
| @@ -109,6 +113,18 @@ const char* GetLevelOfControl( |
| return kControlledByOtherExtensions; |
| } |
| +extension_prefs_scope::Scope StringToScope(const std::string& s) { |
| + if (s == kRegular) { |
| + return extension_prefs_scope::kRegular; |
| + } else if (s == kIncognitoPersistent) { |
| + return extension_prefs_scope::kIncognitoPersistent; |
| + } else { |
| + // The extension API checks that no invalid string can be passed. |
| + NOTREACHED(); |
| + return extension_prefs_scope::kRegular; |
| + } |
| +} |
| + |
| class PrefMapping { |
| public: |
| static PrefMapping* GetInstance() { |
| @@ -346,12 +362,12 @@ bool SetPreferenceFunction::RunImpl() { |
| Value* value = NULL; |
| EXTENSION_FUNCTION_VALIDATE(details->Get(kValue, &value)); |
| - bool incognito = false; |
| - |
| - // TODO(battre): enable incognito preferences again. |
| - // if (details->HasKey(kIncognito)) |
| - // EXTENSION_FUNCTION_VALIDATE(details->GetBoolean(kIncognito, &incognito)); |
| + std::string scope = kRegular; |
| + if (details->HasKey(kScope)) |
| + EXTENSION_FUNCTION_VALIDATE(details->GetString(kScope, &scope)); |
| + // TODO(battre): add kIncognitoSessionOnly |
| + bool incognito = (scope == kIncognitoPersistent); |
| if (incognito && !include_incognito()) { |
|
Matt Perry
2011/05/24 21:04:56
Hmm.. what is the desired behavior for the prefere
Bernhard Bauer
2011/05/24 21:16:25
My idea behind it was that for a split-mode incogn
battre
2011/05/25 11:31:45
I am not familiar with the split-mode preferences
Matt Perry
2011/05/25 18:40:42
bool incognito = (scope == ...);
if (incognito) {
battre
2011/05/25 19:47:44
Done.
|
| error_ = kIncognitoErrorMessage; |
| return false; |
| @@ -384,7 +400,7 @@ bool SetPreferenceFunction::RunImpl() { |
| } |
| prefs->SetExtensionControlledPref(extension_id(), |
| browser_pref, |
| - incognito, |
| + StringToScope(scope), |
| browserPrefValue); |
| return true; |
| } |
| @@ -397,11 +413,9 @@ bool ClearPreferenceFunction::RunImpl() { |
| DictionaryValue* details = NULL; |
| EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &details)); |
| - bool incognito = false; |
| - |
| - // TODO(battre): enable incognito preferences again. |
| - // if (details->HasKey(kIncognito)) |
| - // EXTENSION_FUNCTION_VALIDATE(details->GetBoolean(kIncognito, &incognito)); |
| + std::string scope = kRegular; |
| + if (details->HasKey(kScope)) |
| + EXTENSION_FUNCTION_VALIDATE(details->GetString(kScope, &scope)); |
| // We don't check incognito permissions here, as an extension should be always |
| // allowed to clear its own settings. |
| @@ -416,6 +430,7 @@ bool ClearPreferenceFunction::RunImpl() { |
| return false; |
| } |
| ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); |
| - prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, incognito); |
| + prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, |
| + StringToScope(scope)); |
| return true; |
| } |