Chromium Code Reviews| Index: chrome/browser/policy/configuration_policy_pref_store.cc |
| diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc |
| index 3f74a0137462f5aa2b69d064884410bdb46f64ba..c1d178748039de9c7a35ff6aee89a0bf9b2ee714 100644 |
| --- a/chrome/browser/policy/configuration_policy_pref_store.cc |
| +++ b/chrome/browser/policy/configuration_policy_pref_store.cc |
| @@ -21,6 +21,7 @@ |
| #include "chrome/browser/policy/browser_policy_connector.h" |
| #include "chrome/browser/policy/configuration_policy_provider.h" |
| #include "chrome/browser/policy/policy_path_parser.h" |
| +#include "chrome/browser/prefs/incognito_mode_availability_prefs.h" |
| #include "chrome/browser/prefs/pref_value_map.h" |
| #include "chrome/browser/prefs/proxy_config_dictionary.h" |
| #include "chrome/browser/search_engines/search_terms_data.h" |
| @@ -121,6 +122,11 @@ class ConfigurationPolicyPrefKeeper |
| // respective values in |prefs_|. |
| void FinalizeProxyPolicySettings(); |
| + // If the required entries for the Incognito mode availability settings |
| + // are specified and valid, finalizes the policy-specified configuration |
| + // by initializing the respective values in |prefs_|. |
| + void FinalizeIncognitoModeSettings(); |
| + |
| // Returns true if the policy values stored in proxy_* represent a valid proxy |
| // configuration, including the case in which there is no configuration at |
| // all. |
| @@ -193,8 +199,8 @@ const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry |
| prefs::kWebKitJavascriptEnabled }, |
| { Value::TYPE_BOOLEAN, kPolicyIncognitoEnabled, |
| prefs::kIncognitoEnabled }, |
| - { Value::TYPE_BOOLEAN, kPolicyIncognitoForced, |
| - prefs::kIncognitoForced }, |
| + { Value::TYPE_INTEGER, kPolicyIncognitoModeAvailability, |
| + prefs::kIncognitoModeAvailability }, |
| { Value::TYPE_BOOLEAN, kPolicySavingBrowserHistoryDisabled, |
| prefs::kSavingBrowserHistoryDisabled }, |
| { Value::TYPE_BOOLEAN, kPolicyClearSiteDataOnExit, |
| @@ -317,6 +323,7 @@ ConfigurationPolicyPrefKeeper::ConfigurationPolicyPrefKeeper( |
| LOG(WARNING) << "Failed to get policy from provider."; |
| FinalizeProxyPolicySettings(); |
| FinalizeDefaultSearchPolicySettings(); |
| + FinalizeIncognitoModeSettings(); |
| } |
| ConfigurationPolicyPrefKeeper::~ConfigurationPolicyPrefKeeper() { |
| @@ -637,6 +644,31 @@ void ConfigurationPolicyPrefKeeper::FinalizeDefaultSearchPolicySettings() { |
| arraysize(kDefaultSearchPolicyMap)); |
| } |
| +void ConfigurationPolicyPrefKeeper::FinalizeIncognitoModeSettings() { |
| + IncognitoModeAvailabilityPrefs::IncognitoModeAvailability available; |
| + int int_value; |
| + if (prefs_.GetInteger(prefs::kIncognitoModeAvailability, &int_value)) |
|
Mattias Nissler (ping if slow)
2011/07/28 11:08:50
need curlies due to multi-line block below
rustema
2011/07/29 06:49:23
Done.
|
| + IncognitoModeAvailabilityPrefs::IntToIngocnitoModeAvailability( |
|
Bernhard Bauer
2011/07/28 11:34:03
To be very thorough, you should also check the ret
rustema
2011/07/29 06:49:23
Done.
|
| + int_value, &available); |
| + else |
| + available = IncognitoModeAvailabilityPrefs::ENABLED; |
| + |
| + bool obsolete_incognito_enabled; |
| + if (!prefs_.GetBoolean(prefs::kIncognitoEnabled, &obsolete_incognito_enabled)) |
|
Mattias Nissler (ping if slow)
2011/07/28 11:08:50
we shouldn't have that pref any longer. Just remov
rustema
2011/07/29 06:49:23
Done.
|
| + obsolete_incognito_enabled = true; |
| + |
| + // If the user has set the obsolete IncognitoEnabled to false, override |
| + // the availability preference. |
| + // Note that kPolicyIncognitoModeAvailability trumps kPolicyIncognitoEnabled |
| + // in case the user wants to force Incognito through the former. |
| + if (!obsolete_incognito_enabled && |
| + available != IncognitoModeAvailabilityPrefs::FORCED) { |
| + available = IncognitoModeAvailabilityPrefs::DISABLED; |
| + } |
| + |
| + prefs_.SetInteger(prefs::kIncognitoModeAvailability, available); |
| +} |
| + |
| void ConfigurationPolicyPrefKeeper::FinalizeProxyPolicySettings() { |
| if (CheckProxySettings()) |
| ApplyProxySettings(); |
| @@ -999,7 +1031,8 @@ ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { |
| { kPolicyPrintingEnabled, Value::TYPE_BOOLEAN, key::kPrintingEnabled }, |
| { kPolicyJavascriptEnabled, Value::TYPE_BOOLEAN, key::kJavascriptEnabled }, |
| { kPolicyIncognitoEnabled, Value::TYPE_BOOLEAN, key::kIncognitoEnabled }, |
| - { kPolicyIncognitoForced, Value::TYPE_BOOLEAN, key::kIncognitoForced }, |
| + { kPolicyIncognitoModeAvailability, Value::TYPE_INTEGER, |
| + key::kIncognitoModeAvailability }, |
| { kPolicySavingBrowserHistoryDisabled, Value::TYPE_BOOLEAN, |
| key::kSavingBrowserHistoryDisabled }, |
| { kPolicyClearSiteDataOnExit, Value::TYPE_BOOLEAN, |