Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: chrome/browser/policy/configuration_policy_pref_store.cc

Issue 8135001: Fixed behavior of the bookmark bar visibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DCHECK_EQ instead of DCHECK Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Processes default search provider policies. Returns true if the specified 99 // Processes default search provider policies. Returns true if the specified
100 // policy is a default search provider related policy. In that case, 100 // policy is a default search provider related policy. In that case,
101 // ApplyDefaultSearchPolicy takes ownership of |value|. 101 // ApplyDefaultSearchPolicy takes ownership of |value|.
102 bool ApplyDefaultSearchPolicy(ConfigurationPolicyType policy, Value* value); 102 bool ApplyDefaultSearchPolicy(ConfigurationPolicyType policy, Value* value);
103 103
104 // Processes incognito mode availability related policies. Returns true if the 104 // Processes incognito mode availability related policies. Returns true if the
105 // specified policy is pertinent to incognito mode availability. In that case, 105 // specified policy is pertinent to incognito mode availability. In that case,
106 // the function takes ownership of |value|. 106 // the function takes ownership of |value|.
107 bool ApplyIncognitoModePolicy(ConfigurationPolicyType policy, Value* value); 107 bool ApplyIncognitoModePolicy(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
113 // Make sure that the |path| if present in |prefs_|. If not, set it to 109 // Make sure that the |path| if present in |prefs_|. If not, set it to
114 // a blank string. 110 // a blank string.
115 void EnsureStringPrefExists(const std::string& path); 111 void EnsureStringPrefExists(const std::string& path);
116 112
117 // If the required entries for default search are specified and valid, 113 // If the required entries for default search are specified and valid,
118 // finalizes the policy-specified configuration by initializing the 114 // finalizes the policy-specified configuration by initializing the
119 // unspecified map entries. Otherwise wipes all default search related 115 // unspecified map entries. Otherwise wipes all default search related
120 // map entries from |prefs_|. 116 // map entries from |prefs_|.
121 void FinalizeDefaultSearchPolicySettings(); 117 void FinalizeDefaultSearchPolicySettings();
122 118
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 prefs::kRemoteAccessClientFirewallTraversal }, 280 prefs::kRemoteAccessClientFirewallTraversal },
285 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessHostFirewallTraversal, 281 { Value::TYPE_BOOLEAN, kPolicyRemoteAccessHostFirewallTraversal,
286 prefs::kRemoteAccessHostFirewallTraversal }, 282 prefs::kRemoteAccessHostFirewallTraversal },
287 { Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled, 283 { Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled,
288 prefs::kCloudPrintProxyEnabled }, 284 prefs::kCloudPrintProxyEnabled },
289 { Value::TYPE_BOOLEAN, kPolicyTranslateEnabled, prefs::kEnableTranslate }, 285 { Value::TYPE_BOOLEAN, kPolicyTranslateEnabled, prefs::kEnableTranslate },
290 { Value::TYPE_BOOLEAN, kPolicyAllowOutdatedPlugins, 286 { Value::TYPE_BOOLEAN, kPolicyAllowOutdatedPlugins,
291 prefs::kPluginsAllowOutdated }, 287 prefs::kPluginsAllowOutdated },
292 { Value::TYPE_BOOLEAN, kPolicyAlwaysAuthorizePlugins, 288 { Value::TYPE_BOOLEAN, kPolicyAlwaysAuthorizePlugins,
293 prefs::kPluginsAlwaysAuthorize }, 289 prefs::kPluginsAlwaysAuthorize },
290 { Value::TYPE_BOOLEAN, kPolicyBookmarkBarEnabled,
291 prefs::kShowBookmarkBar },
294 { Value::TYPE_BOOLEAN, kPolicyEditBookmarksEnabled, 292 { Value::TYPE_BOOLEAN, kPolicyEditBookmarksEnabled,
295 prefs::kEditBookmarksEnabled }, 293 prefs::kEditBookmarksEnabled },
296 { Value::TYPE_BOOLEAN, kPolicyAllowFileSelectionDialogs, 294 { Value::TYPE_BOOLEAN, kPolicyAllowFileSelectionDialogs,
297 prefs::kAllowFileSelectionDialogs }, 295 prefs::kAllowFileSelectionDialogs },
298 { Value::TYPE_BOOLEAN, kPolicyImportBookmarks, 296 { Value::TYPE_BOOLEAN, kPolicyImportBookmarks,
299 prefs::kImportBookmarks}, 297 prefs::kImportBookmarks},
300 { Value::TYPE_BOOLEAN, kPolicyImportHistory, 298 { Value::TYPE_BOOLEAN, kPolicyImportHistory,
301 prefs::kImportHistory}, 299 prefs::kImportHistory},
302 { Value::TYPE_BOOLEAN, kPolicyImportHomepage, 300 { Value::TYPE_BOOLEAN, kPolicyImportHomepage,
303 prefs::kImportHomepage}, 301 prefs::kImportHomepage},
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // policy settings. 386 // policy settings.
389 Value* value = current->second->DeepCopy(); 387 Value* value = current->second->DeepCopy();
390 if (ApplyProxyPolicy(current->first, value) || 388 if (ApplyProxyPolicy(current->first, value) ||
391 ApplySyncPolicy(current->first, value) || 389 ApplySyncPolicy(current->first, value) ||
392 ApplyAutofillPolicy(current->first, value) || 390 ApplyAutofillPolicy(current->first, value) ||
393 ApplyDownloadDirPolicy(current->first, value) || 391 ApplyDownloadDirPolicy(current->first, value) ||
394 ApplyDiskCacheDirPolicy(current->first, value) || 392 ApplyDiskCacheDirPolicy(current->first, value) ||
395 ApplyFileSelectionDialogsPolicy(current->first, value) || 393 ApplyFileSelectionDialogsPolicy(current->first, value) ||
396 ApplyDefaultSearchPolicy(current->first, value) || 394 ApplyDefaultSearchPolicy(current->first, value) ||
397 ApplyIncognitoModePolicy(current->first, value) || 395 ApplyIncognitoModePolicy(current->first, value) ||
398 ApplyBookmarksPolicy(current->first, value) ||
399 ApplyPolicyFromMap(current->first, value, 396 ApplyPolicyFromMap(current->first, value,
400 kSimplePolicyMap, arraysize(kSimplePolicyMap))) { 397 kSimplePolicyMap, arraysize(kSimplePolicyMap))) {
401 continue; 398 continue;
402 } 399 }
403 delete value; 400 delete value;
404 401
405 // Other policy implementations should go into the conditional above. 402 // Other policy implementations should go into the conditional above.
406 NOTIMPLEMENTED(); 403 NOTIMPLEMENTED();
407 } 404 }
408 } 405 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 return true; 611 return true;
615 } 612 }
616 if (policy == kPolicyIncognitoEnabled) { 613 if (policy == kPolicyIncognitoEnabled) {
617 deprecated_incognito_enabled_.reset(value); 614 deprecated_incognito_enabled_.reset(value);
618 return true; 615 return true;
619 } 616 }
620 // The policy is not relevant to incognito. 617 // The policy is not relevant to incognito.
621 return false; 618 return false;
622 } 619 }
623 620
624 bool ConfigurationPolicyPrefKeeper::ApplyBookmarksPolicy(
625 ConfigurationPolicyType policy,
626 Value* value) {
627 if (policy != kPolicyBookmarkBarEnabled)
628 return false;
629 DCHECK_EQ(Value::TYPE_BOOLEAN, value->GetType());
630 prefs_.SetValue(prefs::kEnableBookmarkBar, value);
631 // kShowBookmarkBar is not managed directly by a policy, but when
632 // kEnableBookmarkBar is managed, kShowBookmarkBar should be false so that
633 // the bookmarks bar either is completely disabled or only shows on the NTP.
634 // This also disables the checkbox for this preference in the prefs UI.
635 prefs_.SetValue(prefs::kShowBookmarkBar, Value::CreateBooleanValue(false));
636 return true;
637 }
638
639 void ConfigurationPolicyPrefKeeper::EnsureStringPrefExists( 621 void ConfigurationPolicyPrefKeeper::EnsureStringPrefExists(
640 const std::string& path) { 622 const std::string& path) {
641 std::string value; 623 std::string value;
642 if (!prefs_.GetString(path, &value)) 624 if (!prefs_.GetString(path, &value))
643 prefs_.SetString(path, value); 625 prefs_.SetString(path, value);
644 } 626 }
645 627
646 namespace { 628 namespace {
647 629
648 // Implementation of SearchTermsData just for validation. 630 // Implementation of SearchTermsData just for validation.
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 // Update the initialization flag. 1242 // Update the initialization flag.
1261 if (!initialization_complete_ && 1243 if (!initialization_complete_ &&
1262 provider_->IsInitializationComplete()) { 1244 provider_->IsInitializationComplete()) {
1263 initialization_complete_ = true; 1245 initialization_complete_ = true;
1264 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, 1246 FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
1265 OnInitializationCompleted(true)); 1247 OnInitializationCompleted(true));
1266 } 1248 }
1267 } 1249 }
1268 1250
1269 } // namespace policy 1251 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/importer/profile_writer.cc ('k') | chrome/browser/policy/configuration_policy_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698