OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 5 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/policy/browser_policy_connector.h" | 21 #include "chrome/browser/policy/browser_policy_connector.h" |
22 #include "chrome/browser/policy/configuration_policy_provider.h" | 22 #include "chrome/browser/policy/configuration_policy_provider.h" |
23 #include "chrome/browser/policy/policy_path_parser.h" | 23 #include "chrome/browser/policy/policy_path_parser.h" |
24 #include "chrome/browser/prefs/incognito_mode_availability_prefs.h" | |
24 #include "chrome/browser/prefs/pref_value_map.h" | 25 #include "chrome/browser/prefs/pref_value_map.h" |
25 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 26 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
26 #include "chrome/browser/search_engines/search_terms_data.h" | 27 #include "chrome/browser/search_engines/search_terms_data.h" |
27 #include "chrome/browser/search_engines/template_url.h" | 28 #include "chrome/browser/search_engines/template_url.h" |
28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
29 #include "content/common/notification_service.h" | 30 #include "content/common/notification_service.h" |
30 #include "policy/policy_constants.h" | 31 #include "policy/policy_constants.h" |
31 | 32 |
32 namespace policy { | 33 namespace policy { |
33 | 34 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 // finalizes the policy-specified configuration by initializing the | 115 // finalizes the policy-specified configuration by initializing the |
115 // unspecified map entries. Otherwise wipes all default search related | 116 // unspecified map entries. Otherwise wipes all default search related |
116 // map entries from |prefs_|. | 117 // map entries from |prefs_|. |
117 void FinalizeDefaultSearchPolicySettings(); | 118 void FinalizeDefaultSearchPolicySettings(); |
118 | 119 |
119 // If the required entries for the proxy settings are specified and valid, | 120 // If the required entries for the proxy settings are specified and valid, |
120 // finalizes the policy-specified configuration by initializing the | 121 // finalizes the policy-specified configuration by initializing the |
121 // respective values in |prefs_|. | 122 // respective values in |prefs_|. |
122 void FinalizeProxyPolicySettings(); | 123 void FinalizeProxyPolicySettings(); |
123 | 124 |
125 // If the required entries for the Incognito mode availability settings | |
126 // are specified and valid, finalizes the policy-specified configuration | |
127 // by initializing the respective values in |prefs_|. | |
128 void FinalizeIncognitoModeSettings(); | |
129 | |
124 // Returns true if the policy values stored in proxy_* represent a valid proxy | 130 // Returns true if the policy values stored in proxy_* represent a valid proxy |
125 // configuration, including the case in which there is no configuration at | 131 // configuration, including the case in which there is no configuration at |
126 // all. | 132 // all. |
127 bool CheckProxySettings(); | 133 bool CheckProxySettings(); |
128 | 134 |
129 // Assumes CheckProxySettings returns true and applies the values stored | 135 // Assumes CheckProxySettings returns true and applies the values stored |
130 // in proxy_*. | 136 // in proxy_*. |
131 void ApplyProxySettings(); | 137 void ApplyProxySettings(); |
132 | 138 |
133 bool HasProxyPolicy(ConfigurationPolicyType policy) const; | 139 bool HasProxyPolicy(ConfigurationPolicyType policy) const; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 { Value::TYPE_LIST, kPolicyDisabledPluginsExceptions, | 192 { Value::TYPE_LIST, kPolicyDisabledPluginsExceptions, |
187 prefs::kPluginsDisabledPluginsExceptions}, | 193 prefs::kPluginsDisabledPluginsExceptions}, |
188 { Value::TYPE_LIST, kPolicyEnabledPlugins, | 194 { Value::TYPE_LIST, kPolicyEnabledPlugins, |
189 prefs::kPluginsEnabledPlugins}, | 195 prefs::kPluginsEnabledPlugins}, |
190 { Value::TYPE_BOOLEAN, kPolicyShowHomeButton, | 196 { Value::TYPE_BOOLEAN, kPolicyShowHomeButton, |
191 prefs::kShowHomeButton }, | 197 prefs::kShowHomeButton }, |
192 { Value::TYPE_BOOLEAN, kPolicyJavascriptEnabled, | 198 { Value::TYPE_BOOLEAN, kPolicyJavascriptEnabled, |
193 prefs::kWebKitJavascriptEnabled }, | 199 prefs::kWebKitJavascriptEnabled }, |
194 { Value::TYPE_BOOLEAN, kPolicyIncognitoEnabled, | 200 { Value::TYPE_BOOLEAN, kPolicyIncognitoEnabled, |
195 prefs::kIncognitoEnabled }, | 201 prefs::kIncognitoEnabled }, |
196 { Value::TYPE_BOOLEAN, kPolicyIncognitoForced, | 202 { Value::TYPE_INTEGER, kPolicyIncognitoModeAvailability, |
197 prefs::kIncognitoForced }, | 203 prefs::kIncognitoModeAvailability }, |
198 { Value::TYPE_BOOLEAN, kPolicySavingBrowserHistoryDisabled, | 204 { Value::TYPE_BOOLEAN, kPolicySavingBrowserHistoryDisabled, |
199 prefs::kSavingBrowserHistoryDisabled }, | 205 prefs::kSavingBrowserHistoryDisabled }, |
200 { Value::TYPE_BOOLEAN, kPolicyClearSiteDataOnExit, | 206 { Value::TYPE_BOOLEAN, kPolicyClearSiteDataOnExit, |
201 prefs::kClearSiteDataOnExit }, | 207 prefs::kClearSiteDataOnExit }, |
202 { Value::TYPE_BOOLEAN, kPolicyDeveloperToolsDisabled, | 208 { Value::TYPE_BOOLEAN, kPolicyDeveloperToolsDisabled, |
203 prefs::kDevToolsDisabled }, | 209 prefs::kDevToolsDisabled }, |
204 { Value::TYPE_BOOLEAN, kPolicyBlockThirdPartyCookies, | 210 { Value::TYPE_BOOLEAN, kPolicyBlockThirdPartyCookies, |
205 prefs::kBlockThirdPartyCookies }, | 211 prefs::kBlockThirdPartyCookies }, |
206 { Value::TYPE_INTEGER, kPolicyDefaultCookiesSetting, | 212 { Value::TYPE_INTEGER, kPolicyDefaultCookiesSetting, |
207 prefs::kManagedDefaultCookiesSetting }, | 213 prefs::kManagedDefaultCookiesSetting }, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 { Value::TYPE_LIST, kPolicyDefaultSearchProviderEncodings, | 316 { Value::TYPE_LIST, kPolicyDefaultSearchProviderEncodings, |
311 prefs::kDefaultSearchProviderEncodings }, | 317 prefs::kDefaultSearchProviderEncodings }, |
312 }; | 318 }; |
313 | 319 |
314 ConfigurationPolicyPrefKeeper::ConfigurationPolicyPrefKeeper( | 320 ConfigurationPolicyPrefKeeper::ConfigurationPolicyPrefKeeper( |
315 ConfigurationPolicyProvider* provider) { | 321 ConfigurationPolicyProvider* provider) { |
316 if (!provider->Provide(this)) | 322 if (!provider->Provide(this)) |
317 LOG(WARNING) << "Failed to get policy from provider."; | 323 LOG(WARNING) << "Failed to get policy from provider."; |
318 FinalizeProxyPolicySettings(); | 324 FinalizeProxyPolicySettings(); |
319 FinalizeDefaultSearchPolicySettings(); | 325 FinalizeDefaultSearchPolicySettings(); |
326 FinalizeIncognitoModeSettings(); | |
320 } | 327 } |
321 | 328 |
322 ConfigurationPolicyPrefKeeper::~ConfigurationPolicyPrefKeeper() { | 329 ConfigurationPolicyPrefKeeper::~ConfigurationPolicyPrefKeeper() { |
323 DCHECK(proxy_policies_.empty()); | 330 DCHECK(proxy_policies_.empty()); |
324 } | 331 } |
325 | 332 |
326 PrefStore::ReadResult | 333 PrefStore::ReadResult |
327 ConfigurationPolicyPrefKeeper::GetValue(const std::string& key, | 334 ConfigurationPolicyPrefKeeper::GetValue(const std::string& key, |
328 const Value** result) const { | 335 const Value** result) const { |
329 const Value* stored_value = NULL; | 336 const Value* stored_value = NULL; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 prefs_.SetString(prefs::kDefaultSearchProviderPrepopulateID, | 637 prefs_.SetString(prefs::kDefaultSearchProviderPrepopulateID, |
631 std::string()); | 638 std::string()); |
632 return; | 639 return; |
633 } | 640 } |
634 } | 641 } |
635 // Required entries are not there. Remove any related entries. | 642 // Required entries are not there. Remove any related entries. |
636 RemovePreferencesOfMap(kDefaultSearchPolicyMap, | 643 RemovePreferencesOfMap(kDefaultSearchPolicyMap, |
637 arraysize(kDefaultSearchPolicyMap)); | 644 arraysize(kDefaultSearchPolicyMap)); |
638 } | 645 } |
639 | 646 |
647 void ConfigurationPolicyPrefKeeper::FinalizeIncognitoModeSettings() { | |
648 IncognitoModeAvailabilityPrefs::IncognitoModeAvailability available; | |
649 int int_value; | |
650 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.
| |
651 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.
| |
652 int_value, &available); | |
653 else | |
654 available = IncognitoModeAvailabilityPrefs::ENABLED; | |
655 | |
656 bool obsolete_incognito_enabled; | |
657 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.
| |
658 obsolete_incognito_enabled = true; | |
659 | |
660 // If the user has set the obsolete IncognitoEnabled to false, override | |
661 // the availability preference. | |
662 // Note that kPolicyIncognitoModeAvailability trumps kPolicyIncognitoEnabled | |
663 // in case the user wants to force Incognito through the former. | |
664 if (!obsolete_incognito_enabled && | |
665 available != IncognitoModeAvailabilityPrefs::FORCED) { | |
666 available = IncognitoModeAvailabilityPrefs::DISABLED; | |
667 } | |
668 | |
669 prefs_.SetInteger(prefs::kIncognitoModeAvailability, available); | |
670 } | |
671 | |
640 void ConfigurationPolicyPrefKeeper::FinalizeProxyPolicySettings() { | 672 void ConfigurationPolicyPrefKeeper::FinalizeProxyPolicySettings() { |
641 if (CheckProxySettings()) | 673 if (CheckProxySettings()) |
642 ApplyProxySettings(); | 674 ApplyProxySettings(); |
643 | 675 |
644 STLDeleteContainerPairSecondPointers(proxy_policies_.begin(), | 676 STLDeleteContainerPairSecondPointers(proxy_policies_.begin(), |
645 proxy_policies_.end()); | 677 proxy_policies_.end()); |
646 proxy_policies_.clear(); | 678 proxy_policies_.clear(); |
647 } | 679 } |
648 | 680 |
649 bool ConfigurationPolicyPrefKeeper::CheckProxySettings() { | 681 bool ConfigurationPolicyPrefKeeper::CheckProxySettings() { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
992 { kPolicyExtensionInstallWhitelist, Value::TYPE_LIST, | 1024 { kPolicyExtensionInstallWhitelist, Value::TYPE_LIST, |
993 key::kExtensionInstallWhitelist }, | 1025 key::kExtensionInstallWhitelist }, |
994 { kPolicyExtensionInstallBlacklist, Value::TYPE_LIST, | 1026 { kPolicyExtensionInstallBlacklist, Value::TYPE_LIST, |
995 key::kExtensionInstallBlacklist }, | 1027 key::kExtensionInstallBlacklist }, |
996 { kPolicyExtensionInstallForcelist, Value::TYPE_LIST, | 1028 { kPolicyExtensionInstallForcelist, Value::TYPE_LIST, |
997 key::kExtensionInstallForcelist }, | 1029 key::kExtensionInstallForcelist }, |
998 { kPolicyShowHomeButton, Value::TYPE_BOOLEAN, key::kShowHomeButton }, | 1030 { kPolicyShowHomeButton, Value::TYPE_BOOLEAN, key::kShowHomeButton }, |
999 { kPolicyPrintingEnabled, Value::TYPE_BOOLEAN, key::kPrintingEnabled }, | 1031 { kPolicyPrintingEnabled, Value::TYPE_BOOLEAN, key::kPrintingEnabled }, |
1000 { kPolicyJavascriptEnabled, Value::TYPE_BOOLEAN, key::kJavascriptEnabled }, | 1032 { kPolicyJavascriptEnabled, Value::TYPE_BOOLEAN, key::kJavascriptEnabled }, |
1001 { kPolicyIncognitoEnabled, Value::TYPE_BOOLEAN, key::kIncognitoEnabled }, | 1033 { kPolicyIncognitoEnabled, Value::TYPE_BOOLEAN, key::kIncognitoEnabled }, |
1002 { kPolicyIncognitoForced, Value::TYPE_BOOLEAN, key::kIncognitoForced }, | 1034 { kPolicyIncognitoModeAvailability, Value::TYPE_INTEGER, |
1035 key::kIncognitoModeAvailability }, | |
1003 { kPolicySavingBrowserHistoryDisabled, Value::TYPE_BOOLEAN, | 1036 { kPolicySavingBrowserHistoryDisabled, Value::TYPE_BOOLEAN, |
1004 key::kSavingBrowserHistoryDisabled }, | 1037 key::kSavingBrowserHistoryDisabled }, |
1005 { kPolicyClearSiteDataOnExit, Value::TYPE_BOOLEAN, | 1038 { kPolicyClearSiteDataOnExit, Value::TYPE_BOOLEAN, |
1006 key::kClearSiteDataOnExit }, | 1039 key::kClearSiteDataOnExit }, |
1007 { kPolicyDeveloperToolsDisabled, Value::TYPE_BOOLEAN, | 1040 { kPolicyDeveloperToolsDisabled, Value::TYPE_BOOLEAN, |
1008 key::kDeveloperToolsDisabled }, | 1041 key::kDeveloperToolsDisabled }, |
1009 { kPolicyBlockThirdPartyCookies, Value::TYPE_BOOLEAN, | 1042 { kPolicyBlockThirdPartyCookies, Value::TYPE_BOOLEAN, |
1010 key::kBlockThirdPartyCookies }, | 1043 key::kBlockThirdPartyCookies }, |
1011 { kPolicyDefaultCookiesSetting, Value::TYPE_INTEGER, | 1044 { kPolicyDefaultCookiesSetting, Value::TYPE_INTEGER, |
1012 key::kDefaultCookiesSetting }, | 1045 key::kDefaultCookiesSetting }, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1138 // Update the initialization flag. | 1171 // Update the initialization flag. |
1139 if (!initialization_complete_ && | 1172 if (!initialization_complete_ && |
1140 provider_->IsInitializationComplete()) { | 1173 provider_->IsInitializationComplete()) { |
1141 initialization_complete_ = true; | 1174 initialization_complete_ = true; |
1142 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 1175 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, |
1143 OnInitializationCompleted(true)); | 1176 OnInitializationCompleted(true)); |
1144 } | 1177 } |
1145 } | 1178 } |
1146 | 1179 |
1147 } // namespace policy | 1180 } // namespace policy |
OLD | NEW |