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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // Processes default search provider policies. Returns true if the specified | 105 // Processes default search provider policies. Returns true if the specified |
106 // policy is a default search provider related policy. In that case, | 106 // policy is a default search provider related policy. In that case, |
107 // ApplyDefaultSearchPolicy takes ownership of |value|. | 107 // ApplyDefaultSearchPolicy takes ownership of |value|. |
108 bool ApplyDefaultSearchPolicy(ConfigurationPolicyType policy, Value* value); | 108 bool ApplyDefaultSearchPolicy(ConfigurationPolicyType policy, Value* value); |
109 | 109 |
110 // Processes incognito mode availability related policies. Returns true if the | 110 // Processes incognito mode availability related policies. Returns true if the |
111 // specified policy is pertinent to incognito mode availability. In that case, | 111 // specified policy is pertinent to incognito mode availability. In that case, |
112 // the function takes ownership of |value|. | 112 // the function takes ownership of |value|. |
113 bool ApplyIncognitoModePolicy(ConfigurationPolicyType policy, Value* value); | 113 bool ApplyIncognitoModePolicy(ConfigurationPolicyType policy, Value* value); |
114 | 114 |
| 115 // Processes a policy that can disable the bookmarks bar. It can also affect |
| 116 // other preferences. |
| 117 bool ApplyBookmarksPolicy(ConfigurationPolicyType policy, Value* value); |
| 118 |
115 // Make sure that the |path| if present in |prefs_|. If not, set it to | 119 // Make sure that the |path| if present in |prefs_|. If not, set it to |
116 // a blank string. | 120 // a blank string. |
117 void EnsureStringPrefExists(const std::string& path); | 121 void EnsureStringPrefExists(const std::string& path); |
118 | 122 |
119 // If the required entries for default search are specified and valid, | 123 // If the required entries for default search are specified and valid, |
120 // finalizes the policy-specified configuration by initializing the | 124 // finalizes the policy-specified configuration by initializing the |
121 // unspecified map entries. Otherwise wipes all default search related | 125 // unspecified map entries. Otherwise wipes all default search related |
122 // map entries from |prefs_|. | 126 // map entries from |prefs_|. |
123 void FinalizeDefaultSearchPolicySettings(); | 127 void FinalizeDefaultSearchPolicySettings(); |
124 | 128 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 { Value::TYPE_BOOLEAN, kPolicyInstantEnabled, prefs::kInstantEnabled }, | 280 { Value::TYPE_BOOLEAN, kPolicyInstantEnabled, prefs::kInstantEnabled }, |
277 { Value::TYPE_BOOLEAN, kPolicyDefaultBrowserSettingEnabled, | 281 { Value::TYPE_BOOLEAN, kPolicyDefaultBrowserSettingEnabled, |
278 prefs::kDefaultBrowserSettingEnabled }, | 282 prefs::kDefaultBrowserSettingEnabled }, |
279 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessClientFirewallTraversal, | 283 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessClientFirewallTraversal, |
280 prefs::kRemoteAccessClientFirewallTraversal }, | 284 prefs::kRemoteAccessClientFirewallTraversal }, |
281 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessHostFirewallTraversal, | 285 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessHostFirewallTraversal, |
282 prefs::kRemoteAccessHostFirewallTraversal }, | 286 prefs::kRemoteAccessHostFirewallTraversal }, |
283 { Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled, | 287 { Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled, |
284 prefs::kCloudPrintProxyEnabled }, | 288 prefs::kCloudPrintProxyEnabled }, |
285 { Value::TYPE_BOOLEAN, kPolicyTranslateEnabled, prefs::kEnableTranslate }, | 289 { Value::TYPE_BOOLEAN, kPolicyTranslateEnabled, prefs::kEnableTranslate }, |
286 { Value::TYPE_BOOLEAN, kPolicyBookmarkBarEnabled, prefs::kEnableBookmarkBar }, | |
287 { Value::TYPE_BOOLEAN, kPolicyAllowOutdatedPlugins, | 290 { Value::TYPE_BOOLEAN, kPolicyAllowOutdatedPlugins, |
288 prefs::kPluginsAllowOutdated }, | 291 prefs::kPluginsAllowOutdated }, |
289 { Value::TYPE_BOOLEAN, kPolicyAlwaysAuthorizePlugins, | 292 { Value::TYPE_BOOLEAN, kPolicyAlwaysAuthorizePlugins, |
290 prefs::kPluginsAlwaysAuthorize }, | 293 prefs::kPluginsAlwaysAuthorize }, |
291 { Value::TYPE_BOOLEAN, kPolicyEditBookmarksEnabled, | 294 { Value::TYPE_BOOLEAN, kPolicyEditBookmarksEnabled, |
292 prefs::kEditBookmarksEnabled }, | 295 prefs::kEditBookmarksEnabled }, |
293 { Value::TYPE_BOOLEAN, kPolicyAllowFileSelectionDialogs, | |
294 prefs::kAllowFileSelectionDialogs }, | |
295 { Value::TYPE_INTEGER, kPolicyMaxConnectionsPerProxy, | 296 { Value::TYPE_INTEGER, kPolicyMaxConnectionsPerProxy, |
296 prefs::kMaxConnectionsPerProxy }, | 297 prefs::kMaxConnectionsPerProxy }, |
297 | 298 |
298 #if defined(OS_CHROMEOS) | 299 #if defined(OS_CHROMEOS) |
299 { Value::TYPE_BOOLEAN, kPolicyChromeOsLockOnIdleSuspend, | 300 { Value::TYPE_BOOLEAN, kPolicyChromeOsLockOnIdleSuspend, |
300 prefs::kEnableScreenLock }, | 301 prefs::kEnableScreenLock }, |
301 { Value::TYPE_STRING, kPolicyChromeOsReleaseChannel, | 302 { Value::TYPE_STRING, kPolicyChromeOsReleaseChannel, |
302 prefs::kChromeOsReleaseChannel }, | 303 prefs::kChromeOsReleaseChannel }, |
303 #endif | 304 #endif |
304 }; | 305 }; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 355 } |
355 | 356 |
356 void ConfigurationPolicyPrefKeeper::GetDifferingPrefPaths( | 357 void ConfigurationPolicyPrefKeeper::GetDifferingPrefPaths( |
357 const ConfigurationPolicyPrefKeeper* other, | 358 const ConfigurationPolicyPrefKeeper* other, |
358 std::vector<std::string>* differing_prefs) const { | 359 std::vector<std::string>* differing_prefs) const { |
359 prefs_.GetDifferingKeys(&other->prefs_, differing_prefs); | 360 prefs_.GetDifferingKeys(&other->prefs_, differing_prefs); |
360 } | 361 } |
361 | 362 |
362 void ConfigurationPolicyPrefKeeper::Apply(ConfigurationPolicyType policy, | 363 void ConfigurationPolicyPrefKeeper::Apply(ConfigurationPolicyType policy, |
363 Value* value) { | 364 Value* value) { |
364 if (ApplyProxyPolicy(policy, value)) | 365 if (ApplyProxyPolicy(policy, value) || |
365 return; | 366 ApplySyncPolicy(policy, value) || |
366 | 367 ApplyAutofillPolicy(policy, value) || |
367 if (ApplySyncPolicy(policy, value)) | 368 ApplyDownloadDirPolicy(policy, value) || |
368 return; | 369 ApplyDiskCacheDirPolicy(policy, value) || |
369 | 370 ApplyFileSelectionDialogsPolicy(policy, value) || |
370 if (ApplyAutofillPolicy(policy, value)) | 371 ApplyDefaultSearchPolicy(policy, value) || |
371 return; | 372 ApplyIncognitoModePolicy(policy, value) || |
372 | 373 ApplyBookmarksPolicy(policy, value) || |
373 if (ApplyDownloadDirPolicy(policy, value)) | 374 ApplyPolicyFromMap(policy, value, kSimplePolicyMap, |
374 return; | |
375 | |
376 if (ApplyDiskCacheDirPolicy(policy, value)) | |
377 return; | |
378 | |
379 if (ApplyFileSelectionDialogsPolicy(policy, value)) | |
380 return; | |
381 | |
382 if (ApplyDefaultSearchPolicy(policy, value)) | |
383 return; | |
384 | |
385 if (ApplyIncognitoModePolicy(policy, value)) | |
386 return; | |
387 | |
388 if (ApplyPolicyFromMap(policy, value, kSimplePolicyMap, | |
389 arraysize(kSimplePolicyMap))) | 375 arraysize(kSimplePolicyMap))) |
390 return; | 376 return; |
391 | 377 |
392 // Other policy implementations go here. | 378 // Other policy implementations go here. |
393 NOTIMPLEMENTED(); | 379 NOTIMPLEMENTED(); |
394 delete value; | 380 delete value; |
395 } | 381 } |
396 | 382 |
397 bool ConfigurationPolicyPrefKeeper::RemovePreferencesOfMap( | 383 bool ConfigurationPolicyPrefKeeper::RemovePreferencesOfMap( |
398 const PolicyToPreferenceMapEntry* map, int table_size) { | 384 const PolicyToPreferenceMapEntry* map, int table_size) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 return true; | 582 return true; |
597 } | 583 } |
598 if (policy == kPolicyIncognitoEnabled) { | 584 if (policy == kPolicyIncognitoEnabled) { |
599 deprecated_incognito_enabled_.reset(value); | 585 deprecated_incognito_enabled_.reset(value); |
600 return true; | 586 return true; |
601 } | 587 } |
602 // The policy is not relevant to incognito. | 588 // The policy is not relevant to incognito. |
603 return false; | 589 return false; |
604 } | 590 } |
605 | 591 |
| 592 bool ConfigurationPolicyPrefKeeper::ApplyBookmarksPolicy( |
| 593 ConfigurationPolicyType policy, |
| 594 Value* value) { |
| 595 if (policy != kPolicyBookmarkBarEnabled) |
| 596 return false; |
| 597 DCHECK_EQ(Value::TYPE_BOOLEAN, value->GetType()); |
| 598 prefs_.SetValue(prefs::kEnableBookmarkBar, value); |
| 599 // kShowBookmarkBar is not managed directly by a policy, but when |
| 600 // kEnableBookmarkBar is managed, kShowBookmarkBar should be false so that |
| 601 // the bookmarks bar either is completely disabled or only shows on the NTP. |
| 602 // This also disables the checkbox for this preference in the prefs UI. |
| 603 prefs_.SetValue(prefs::kShowBookmarkBar, Value::CreateBooleanValue(false)); |
| 604 return true; |
| 605 } |
| 606 |
606 void ConfigurationPolicyPrefKeeper::EnsureStringPrefExists( | 607 void ConfigurationPolicyPrefKeeper::EnsureStringPrefExists( |
607 const std::string& path) { | 608 const std::string& path) { |
608 std::string value; | 609 std::string value; |
609 if (!prefs_.GetString(path, &value)) | 610 if (!prefs_.GetString(path, &value)) |
610 prefs_.SetString(path, value); | 611 prefs_.SetString(path, value); |
611 } | 612 } |
612 | 613 |
613 namespace { | 614 namespace { |
614 | 615 |
615 // Implementation of SearchTermsData just for validation. | 616 // Implementation of SearchTermsData just for validation. |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 // Update the initialization flag. | 1206 // Update the initialization flag. |
1206 if (!initialization_complete_ && | 1207 if (!initialization_complete_ && |
1207 provider_->IsInitializationComplete()) { | 1208 provider_->IsInitializationComplete()) { |
1208 initialization_complete_ = true; | 1209 initialization_complete_ = true; |
1209 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 1210 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, |
1210 OnInitializationCompleted(true)); | 1211 OnInitializationCompleted(true)); |
1211 } | 1212 } |
1212 } | 1213 } |
1213 | 1214 |
1214 } // namespace policy | 1215 } // namespace policy |
OLD | NEW |