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

Unified Diff: chrome/browser/policy/configuration_policy_pref_store.cc

Issue 7564011: Prevent accelerators from toggling the bookmark bar when disabled by policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewed, rebased Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/browser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 99a15aeadfacf6ff84d8462a7e56f8bea89f77da..ff913b3e587059a9dae9ca1ac2d262c641e94ca8 100644
--- a/chrome/browser/policy/configuration_policy_pref_store.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store.cc
@@ -112,6 +112,10 @@ class ConfigurationPolicyPrefKeeper
// the function takes ownership of |value|.
bool ApplyIncognitoModePolicy(ConfigurationPolicyType policy, Value* value);
+ // Processes a policy that can disable the bookmarks bar. It can also affect
+ // other preferences.
+ bool ApplyBookmarksPolicy(ConfigurationPolicyType policy, Value* value);
+
// Make sure that the |path| if present in |prefs_|. If not, set it to
// a blank string.
void EnsureStringPrefExists(const std::string& path);
@@ -283,15 +287,12 @@ const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry
{ Value::TYPE_BOOLEAN, kPolicyCloudPrintProxyEnabled,
prefs::kCloudPrintProxyEnabled },
{ Value::TYPE_BOOLEAN, kPolicyTranslateEnabled, prefs::kEnableTranslate },
- { Value::TYPE_BOOLEAN, kPolicyBookmarkBarEnabled, prefs::kEnableBookmarkBar },
{ Value::TYPE_BOOLEAN, kPolicyAllowOutdatedPlugins,
prefs::kPluginsAllowOutdated },
{ Value::TYPE_BOOLEAN, kPolicyAlwaysAuthorizePlugins,
prefs::kPluginsAlwaysAuthorize },
{ Value::TYPE_BOOLEAN, kPolicyEditBookmarksEnabled,
prefs::kEditBookmarksEnabled },
- { Value::TYPE_BOOLEAN, kPolicyAllowFileSelectionDialogs,
- prefs::kAllowFileSelectionDialogs },
{ Value::TYPE_INTEGER, kPolicyMaxConnectionsPerProxy,
prefs::kMaxConnectionsPerProxy },
@@ -361,31 +362,16 @@ void ConfigurationPolicyPrefKeeper::GetDifferingPrefPaths(
void ConfigurationPolicyPrefKeeper::Apply(ConfigurationPolicyType policy,
Value* value) {
- if (ApplyProxyPolicy(policy, value))
- return;
-
- if (ApplySyncPolicy(policy, value))
- return;
-
- if (ApplyAutofillPolicy(policy, value))
- return;
-
- if (ApplyDownloadDirPolicy(policy, value))
- return;
-
- if (ApplyDiskCacheDirPolicy(policy, value))
- return;
-
- if (ApplyFileSelectionDialogsPolicy(policy, value))
- return;
-
- if (ApplyDefaultSearchPolicy(policy, value))
- return;
-
- if (ApplyIncognitoModePolicy(policy, value))
- return;
-
- if (ApplyPolicyFromMap(policy, value, kSimplePolicyMap,
+ if (ApplyProxyPolicy(policy, value) ||
+ ApplySyncPolicy(policy, value) ||
+ ApplyAutofillPolicy(policy, value) ||
+ ApplyDownloadDirPolicy(policy, value) ||
+ ApplyDiskCacheDirPolicy(policy, value) ||
+ ApplyFileSelectionDialogsPolicy(policy, value) ||
+ ApplyDefaultSearchPolicy(policy, value) ||
+ ApplyIncognitoModePolicy(policy, value) ||
+ ApplyBookmarksPolicy(policy, value) ||
+ ApplyPolicyFromMap(policy, value, kSimplePolicyMap,
arraysize(kSimplePolicyMap)))
return;
@@ -603,6 +589,21 @@ bool ConfigurationPolicyPrefKeeper::ApplyIncognitoModePolicy(
return false;
}
+bool ConfigurationPolicyPrefKeeper::ApplyBookmarksPolicy(
+ ConfigurationPolicyType policy,
+ Value* value) {
+ if (policy != kPolicyBookmarkBarEnabled)
+ return false;
+ DCHECK_EQ(Value::TYPE_BOOLEAN, value->GetType());
+ prefs_.SetValue(prefs::kEnableBookmarkBar, value);
+ // kShowBookmarkBar is not managed directly by a policy, but when
+ // kEnableBookmarkBar is managed, kShowBookmarkBar should be false so that
+ // the bookmarks bar either is completely disabled or only shows on the NTP.
+ // This also disables the checkbox for this preference in the prefs UI.
+ prefs_.SetValue(prefs::kShowBookmarkBar, Value::CreateBooleanValue(false));
+ return true;
+}
+
void ConfigurationPolicyPrefKeeper::EnsureStringPrefExists(
const std::string& path) {
std::string value;
« no previous file with comments | « no previous file | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698