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> |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 // ApplyFileSelectionDialogsPolicy assumes the ownership of |value| in the | 99 // ApplyFileSelectionDialogsPolicy assumes the ownership of |value| in the |
100 // case that the policy is recognized. | 100 // case that the policy is recognized. |
101 bool ApplyFileSelectionDialogsPolicy(ConfigurationPolicyType policy, | 101 bool ApplyFileSelectionDialogsPolicy(ConfigurationPolicyType policy, |
102 Value* value); | 102 Value* value); |
103 | 103 |
104 // Processes default search provider policies. Returns true if the specified | 104 // Processes default search provider policies. Returns true if the specified |
105 // policy is a default search provider related policy. In that case, | 105 // policy is a default search provider related policy. In that case, |
106 // ApplyDefaultSearchPolicy takes ownership of |value|. | 106 // ApplyDefaultSearchPolicy takes ownership of |value|. |
107 bool ApplyDefaultSearchPolicy(ConfigurationPolicyType policy, Value* value); | 107 bool ApplyDefaultSearchPolicy(ConfigurationPolicyType policy, Value* value); |
108 | 108 |
109 // Processes a policy that can disable the bookmarks bar. It can also affect | |
110 // other preferences. | |
111 bool ApplyBookmarksPolicy(ConfigurationPolicyType policy, Value* value); | |
112 | |
109 // Make sure that the |path| if present in |prefs_|. If not, set it to | 113 // Make sure that the |path| if present in |prefs_|. If not, set it to |
110 // a blank string. | 114 // a blank string. |
111 void EnsureStringPrefExists(const std::string& path); | 115 void EnsureStringPrefExists(const std::string& path); |
112 | 116 |
113 // If the required entries for default search are specified and valid, | 117 // If the required entries for default search are specified and valid, |
114 // finalizes the policy-specified configuration by initializing the | 118 // finalizes the policy-specified configuration by initializing the |
115 // unspecified map entries. Otherwise wipes all default search related | 119 // unspecified map entries. Otherwise wipes all default search related |
116 // map entries from |prefs_|. | 120 // map entries from |prefs_|. |
117 void FinalizeDefaultSearchPolicySettings(); | 121 void FinalizeDefaultSearchPolicySettings(); |
118 | 122 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 { Value::TYPE_BOOLEAN, kPolicyInstantEnabled, prefs::kInstantEnabled }, | 268 { Value::TYPE_BOOLEAN, kPolicyInstantEnabled, prefs::kInstantEnabled }, |
265 { Value::TYPE_BOOLEAN, kPolicyDefaultBrowserSettingEnabled, | 269 { Value::TYPE_BOOLEAN, kPolicyDefaultBrowserSettingEnabled, |
266 prefs::kDefaultBrowserSettingEnabled }, | 270 prefs::kDefaultBrowserSettingEnabled }, |
267 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessClientFirewallTraversal, | 271 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessClientFirewallTraversal, |
268 prefs::kRemoteAccessClientFirewallTraversal }, | 272 prefs::kRemoteAccessClientFirewallTraversal }, |
269 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessHostFirewallTraversal, | 273 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessHostFirewallTraversal, |
270 prefs::kRemoteAccessHostFirewallTraversal }, | 274 prefs::kRemoteAccessHostFirewallTraversal }, |
271 { Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled, | 275 { Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled, |
272 prefs::kCloudPrintProxyEnabled }, | 276 prefs::kCloudPrintProxyEnabled }, |
273 { Value::TYPE_BOOLEAN, kPolicyTranslateEnabled, prefs::kEnableTranslate }, | 277 { Value::TYPE_BOOLEAN, kPolicyTranslateEnabled, prefs::kEnableTranslate }, |
274 { Value::TYPE_BOOLEAN, kPolicyBookmarkBarEnabled, prefs::kEnableBookmarkBar }, | |
275 { Value::TYPE_BOOLEAN, kPolicyAllowOutdatedPlugins, | 278 { Value::TYPE_BOOLEAN, kPolicyAllowOutdatedPlugins, |
276 prefs::kPluginsAllowOutdated }, | 279 prefs::kPluginsAllowOutdated }, |
277 { Value::TYPE_BOOLEAN, kPolicyAlwaysAuthorizePlugins, | 280 { Value::TYPE_BOOLEAN, kPolicyAlwaysAuthorizePlugins, |
278 prefs::kPluginsAlwaysAuthorize }, | 281 prefs::kPluginsAlwaysAuthorize }, |
279 { Value::TYPE_BOOLEAN, kPolicyEditBookmarksEnabled, | 282 { Value::TYPE_BOOLEAN, kPolicyEditBookmarksEnabled, |
280 prefs::kEditBookmarksEnabled }, | 283 prefs::kEditBookmarksEnabled }, |
281 { Value::TYPE_BOOLEAN, kPolicyAllowFileSelectionDialogs, | |
282 prefs::kAllowFileSelectionDialogs }, | |
283 { Value::TYPE_INTEGER, kPolicyMaxConnectionsPerProxy, | 284 { Value::TYPE_INTEGER, kPolicyMaxConnectionsPerProxy, |
284 prefs::kMaxConnectionsPerProxy }, | 285 prefs::kMaxConnectionsPerProxy }, |
285 | 286 |
286 #if defined(OS_CHROMEOS) | 287 #if defined(OS_CHROMEOS) |
287 { Value::TYPE_BOOLEAN, kPolicyChromeOsLockOnIdleSuspend, | 288 { Value::TYPE_BOOLEAN, kPolicyChromeOsLockOnIdleSuspend, |
288 prefs::kEnableScreenLock }, | 289 prefs::kEnableScreenLock }, |
289 { Value::TYPE_STRING, kPolicyChromeOsReleaseChannel, | 290 { Value::TYPE_STRING, kPolicyChromeOsReleaseChannel, |
290 prefs::kChromeOsReleaseChannel }, | 291 prefs::kChromeOsReleaseChannel }, |
291 #endif | 292 #endif |
292 }; | 293 }; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 | 363 |
363 if (ApplyDiskCacheDirPolicy(policy, value)) | 364 if (ApplyDiskCacheDirPolicy(policy, value)) |
364 return; | 365 return; |
365 | 366 |
366 if (ApplyFileSelectionDialogsPolicy(policy, value)) | 367 if (ApplyFileSelectionDialogsPolicy(policy, value)) |
367 return; | 368 return; |
368 | 369 |
369 if (ApplyDefaultSearchPolicy(policy, value)) | 370 if (ApplyDefaultSearchPolicy(policy, value)) |
370 return; | 371 return; |
371 | 372 |
373 if (ApplyBookmarksPolicy(policy, value)) | |
Peter Kasting
2011/08/04 18:44:43
Nit: Shorter would be
if (ApplyXYZPolicy(policy,
Joao da Silva
2011/08/05 09:24:11
Done.
| |
374 return; | |
375 | |
372 if (ApplyPolicyFromMap(policy, value, kSimplePolicyMap, | 376 if (ApplyPolicyFromMap(policy, value, kSimplePolicyMap, |
373 arraysize(kSimplePolicyMap))) | 377 arraysize(kSimplePolicyMap))) |
374 return; | 378 return; |
375 | 379 |
376 // Other policy implementations go here. | 380 // Other policy implementations go here. |
377 NOTIMPLEMENTED(); | 381 NOTIMPLEMENTED(); |
378 delete value; | 382 delete value; |
379 } | 383 } |
380 | 384 |
381 bool ConfigurationPolicyPrefKeeper::RemovePreferencesOfMap( | 385 bool ConfigurationPolicyPrefKeeper::RemovePreferencesOfMap( |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 return true; | 553 return true; |
550 } | 554 } |
551 | 555 |
552 if (ApplyPolicyFromMap(policy, value, kDefaultSearchPolicyMap, | 556 if (ApplyPolicyFromMap(policy, value, kDefaultSearchPolicyMap, |
553 arraysize(kDefaultSearchPolicyMap))) { | 557 arraysize(kDefaultSearchPolicyMap))) { |
554 return true; | 558 return true; |
555 } | 559 } |
556 return false; | 560 return false; |
557 } | 561 } |
558 | 562 |
563 bool ConfigurationPolicyPrefKeeper::ApplyBookmarksPolicy( | |
564 ConfigurationPolicyType policy, | |
565 Value* value) { | |
566 if (policy != kPolicyBookmarkBarEnabled) | |
567 return false; | |
568 DCHECK_EQ(Value::TYPE_BOOLEAN, value->GetType()); | |
569 prefs_.SetValue(prefs::kEnableBookmarkBar, value); | |
570 // kShowBookmarkBar is not managed directly by a policy, but when | |
571 // kEnableBookmarkBar is managed, kShowBookmarkBar should be false so that | |
572 // the bookmarks bar either is completely disabled or only shows on the NTP. | |
Peter Kasting
2011/08/04 18:44:43
There's no policy configuration that corresponds t
Joao da Silva
2011/08/05 09:24:11
The "always show the bookmarks bar" preference jus
| |
573 // This also disables the checkbox for this preference in the prefs UI. | |
574 prefs_.SetValue(prefs::kShowBookmarkBar, Value::CreateBooleanValue(false)); | |
575 return true; | |
576 } | |
577 | |
559 void ConfigurationPolicyPrefKeeper::EnsureStringPrefExists( | 578 void ConfigurationPolicyPrefKeeper::EnsureStringPrefExists( |
560 const std::string& path) { | 579 const std::string& path) { |
561 std::string value; | 580 std::string value; |
562 if (!prefs_.GetString(path, &value)) | 581 if (!prefs_.GetString(path, &value)) |
563 prefs_.SetString(path, value); | 582 prefs_.SetString(path, value); |
564 } | 583 } |
565 | 584 |
566 namespace { | 585 namespace { |
567 | 586 |
568 // Implementation of SearchTermsData just for validation. | 587 // Implementation of SearchTermsData just for validation. |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1138 // Update the initialization flag. | 1157 // Update the initialization flag. |
1139 if (!initialization_complete_ && | 1158 if (!initialization_complete_ && |
1140 provider_->IsInitializationComplete()) { | 1159 provider_->IsInitializationComplete()) { |
1141 initialization_complete_ = true; | 1160 initialization_complete_ = true; |
1142 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 1161 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, |
1143 OnInitializationCompleted(true)); | 1162 OnInitializationCompleted(true)); |
1144 } | 1163 } |
1145 } | 1164 } |
1146 | 1165 |
1147 } // namespace policy | 1166 } // namespace policy |
OLD | NEW |