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

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

Issue 6002015: Policy: generate boilerplate policy type and constant code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nacl build Created 9 years, 11 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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/policy/configuration_policy_provider.h" 21 #include "chrome/browser/policy/configuration_policy_provider.h"
22 #include "chrome/browser/policy/configuration_policy_provider_keeper.h" 22 #include "chrome/browser/policy/configuration_policy_provider_keeper.h"
23 #include "chrome/browser/policy/device_management_policy_provider.h" 23 #include "chrome/browser/policy/device_management_policy_provider.h"
24 #include "chrome/browser/policy/profile_policy_context.h" 24 #include "chrome/browser/policy/profile_policy_context.h"
25 #include "chrome/browser/prefs/pref_value_map.h" 25 #include "chrome/browser/prefs/pref_value_map.h"
26 #include "chrome/browser/prefs/proxy_prefs.h" 26 #include "chrome/browser/prefs/proxy_prefs.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/search_engines/search_terms_data.h" 28 #include "chrome/browser/search_engines/search_terms_data.h"
29 #include "chrome/browser/search_engines/template_url.h" 29 #include "chrome/browser/search_engines/template_url.h"
30 #include "chrome/common/notification_service.h" 30 #include "chrome/common/notification_service.h"
31 #include "chrome/common/policy_constants.h"
32 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "policy/policy_constants.h"
33 33
34 namespace policy { 34 namespace policy {
35 35
36 // Accepts policy settings from a ConfigurationPolicyProvider, converts them 36 // Accepts policy settings from a ConfigurationPolicyProvider, converts them
37 // to preferences and caches the result. 37 // to preferences and caches the result.
38 class ConfigurationPolicyPrefKeeper 38 class ConfigurationPolicyPrefKeeper
39 : private ConfigurationPolicyStoreInterface { 39 : private ConfigurationPolicyStoreInterface {
40 public: 40 public:
41 explicit ConfigurationPolicyPrefKeeper(ConfigurationPolicyProvider* provider); 41 explicit ConfigurationPolicyPrefKeeper(ConfigurationPolicyProvider* provider);
42 virtual ~ConfigurationPolicyPrefKeeper(); 42 virtual ~ConfigurationPolicyPrefKeeper();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 static const PolicyToPreferenceMapEntry kSimplePolicyMap[]; 144 static const PolicyToPreferenceMapEntry kSimplePolicyMap[];
145 static const PolicyToPreferenceMapEntry kProxyPolicyMap[]; 145 static const PolicyToPreferenceMapEntry kProxyPolicyMap[];
146 static const PolicyToPreferenceMapEntry kDefaultSearchPolicyMap[]; 146 static const PolicyToPreferenceMapEntry kDefaultSearchPolicyMap[];
147 147
148 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefKeeper); 148 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefKeeper);
149 }; 149 };
150 150
151 const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry 151 const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry
152 ConfigurationPolicyPrefKeeper::kSimplePolicyMap[] = { 152 ConfigurationPolicyPrefKeeper::kSimplePolicyMap[] = {
153 { Value::TYPE_STRING, kPolicyHomePage, prefs::kHomePage }, 153 { Value::TYPE_STRING, kPolicyHomepageLocation, prefs::kHomePage },
154 { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage, 154 { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage,
155 prefs::kHomePageIsNewTabPage }, 155 prefs::kHomePageIsNewTabPage },
156 { Value::TYPE_INTEGER, kPolicyRestoreOnStartup, 156 { Value::TYPE_INTEGER, kPolicyRestoreOnStartup,
157 prefs::kRestoreOnStartup}, 157 prefs::kRestoreOnStartup},
158 { Value::TYPE_LIST, kPolicyURLsToRestoreOnStartup, 158 { Value::TYPE_LIST, kPolicyRestoreOnStartupURLs,
159 prefs::kURLsToRestoreOnStartup }, 159 prefs::kURLsToRestoreOnStartup },
160 { Value::TYPE_BOOLEAN, kPolicyAlternateErrorPagesEnabled, 160 { Value::TYPE_BOOLEAN, kPolicyAlternateErrorPagesEnabled,
161 prefs::kAlternateErrorPagesEnabled }, 161 prefs::kAlternateErrorPagesEnabled },
162 { Value::TYPE_BOOLEAN, kPolicySearchSuggestEnabled, 162 { Value::TYPE_BOOLEAN, kPolicySearchSuggestEnabled,
163 prefs::kSearchSuggestEnabled }, 163 prefs::kSearchSuggestEnabled },
164 { Value::TYPE_BOOLEAN, kPolicyDnsPrefetchingEnabled, 164 { Value::TYPE_BOOLEAN, kPolicyDnsPrefetchingEnabled,
165 prefs::kDnsPrefetchingEnabled }, 165 prefs::kDnsPrefetchingEnabled },
166 { Value::TYPE_BOOLEAN, kPolicyDisableSpdy, 166 { Value::TYPE_BOOLEAN, kPolicyDisableSpdy,
167 prefs::kDisableSpdy }, 167 prefs::kDisableSpdy },
168 { Value::TYPE_BOOLEAN, kPolicySafeBrowsingEnabled, 168 { Value::TYPE_BOOLEAN, kPolicySafeBrowsingEnabled,
169 prefs::kSafeBrowsingEnabled }, 169 prefs::kSafeBrowsingEnabled },
170 { Value::TYPE_BOOLEAN, kPolicyPasswordManagerEnabled, 170 { Value::TYPE_BOOLEAN, kPolicyPasswordManagerEnabled,
171 prefs::kPasswordManagerEnabled }, 171 prefs::kPasswordManagerEnabled },
172 { Value::TYPE_BOOLEAN, kPolicyPasswordManagerAllowShowPasswords, 172 { Value::TYPE_BOOLEAN, kPolicyPasswordManagerAllowShowPasswords,
173 prefs::kPasswordManagerAllowShowPasswords }, 173 prefs::kPasswordManagerAllowShowPasswords },
174 { Value::TYPE_BOOLEAN, kPolicyPrintingEnabled, 174 { Value::TYPE_BOOLEAN, kPolicyPrintingEnabled,
175 prefs::kPrintingEnabled }, 175 prefs::kPrintingEnabled },
176 { Value::TYPE_BOOLEAN, kPolicyMetricsReportingEnabled, 176 { Value::TYPE_BOOLEAN, kPolicyMetricsReportingEnabled,
177 prefs::kMetricsReportingEnabled }, 177 prefs::kMetricsReportingEnabled },
178 { Value::TYPE_STRING, kPolicyApplicationLocale, 178 { Value::TYPE_STRING, kPolicyApplicationLocaleValue,
179 prefs::kApplicationLocale}, 179 prefs::kApplicationLocale},
180 { Value::TYPE_LIST, kPolicyExtensionInstallAllowList, 180 { Value::TYPE_LIST, kPolicyExtensionInstallWhitelist,
181 prefs::kExtensionInstallAllowList}, 181 prefs::kExtensionInstallAllowList},
182 { Value::TYPE_LIST, kPolicyExtensionInstallDenyList, 182 { Value::TYPE_LIST, kPolicyExtensionInstallBlacklist,
183 prefs::kExtensionInstallDenyList}, 183 prefs::kExtensionInstallDenyList},
184 { Value::TYPE_LIST, kPolicyExtensionInstallForceList, 184 { Value::TYPE_LIST, kPolicyExtensionInstallForcelist,
185 prefs::kExtensionInstallForceList}, 185 prefs::kExtensionInstallForceList},
186 { Value::TYPE_LIST, kPolicyDisabledPlugins, 186 { Value::TYPE_LIST, kPolicyDisabledPlugins,
187 prefs::kPluginsPluginsBlacklist}, 187 prefs::kPluginsPluginsBlacklist},
188 { Value::TYPE_BOOLEAN, kPolicyShowHomeButton, 188 { Value::TYPE_BOOLEAN, kPolicyShowHomeButton,
189 prefs::kShowHomeButton }, 189 prefs::kShowHomeButton },
190 { Value::TYPE_BOOLEAN, kPolicyJavascriptEnabled, 190 { Value::TYPE_BOOLEAN, kPolicyJavascriptEnabled,
191 prefs::kWebKitJavascriptEnabled }, 191 prefs::kWebKitJavascriptEnabled },
192 { Value::TYPE_BOOLEAN, kPolicySavingBrowserHistoryDisabled, 192 { Value::TYPE_BOOLEAN, kPolicySavingBrowserHistoryDisabled,
193 prefs::kSavingBrowserHistoryDisabled }, 193 prefs::kSavingBrowserHistoryDisabled },
194 { Value::TYPE_BOOLEAN, kPolicyDeveloperToolsDisabled, 194 { Value::TYPE_BOOLEAN, kPolicyDeveloperToolsDisabled,
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore() { 738 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore() {
739 ConfigurationPolicyProviderKeeper* keeper = 739 ConfigurationPolicyProviderKeeper* keeper =
740 g_browser_process->configuration_policy_provider_keeper(); 740 g_browser_process->configuration_policy_provider_keeper();
741 return new ConfigurationPolicyPrefStore(keeper->recommended_provider()); 741 return new ConfigurationPolicyPrefStore(keeper->recommended_provider());
742 } 742 }
743 743
744 /* static */ 744 /* static */
745 const ConfigurationPolicyProvider::PolicyDefinitionList* 745 const ConfigurationPolicyProvider::PolicyDefinitionList*
746 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() { 746 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList() {
747 static ConfigurationPolicyProvider::PolicyDefinitionList::Entry entries[] = { 747 static ConfigurationPolicyProvider::PolicyDefinitionList::Entry entries[] = {
748 { kPolicyHomePage, Value::TYPE_STRING, key::kHomepageLocation }, 748 { kPolicyHomepageLocation, Value::TYPE_STRING, key::kHomepageLocation },
749 { kPolicyHomepageIsNewTabPage, Value::TYPE_BOOLEAN, 749 { kPolicyHomepageIsNewTabPage, Value::TYPE_BOOLEAN,
750 key::kHomepageIsNewTabPage }, 750 key::kHomepageIsNewTabPage },
751 { kPolicyRestoreOnStartup, Value::TYPE_INTEGER, key::kRestoreOnStartup }, 751 { kPolicyRestoreOnStartup, Value::TYPE_INTEGER, key::kRestoreOnStartup },
752 { kPolicyURLsToRestoreOnStartup, Value::TYPE_LIST, 752 { kPolicyRestoreOnStartupURLs, Value::TYPE_LIST,
753 key::kURLsToRestoreOnStartup }, 753 key::kRestoreOnStartupURLs },
754 { kPolicyDefaultSearchProviderEnabled, Value::TYPE_BOOLEAN, 754 { kPolicyDefaultSearchProviderEnabled, Value::TYPE_BOOLEAN,
755 key::kDefaultSearchProviderEnabled }, 755 key::kDefaultSearchProviderEnabled },
756 { kPolicyDefaultSearchProviderName, Value::TYPE_STRING, 756 { kPolicyDefaultSearchProviderName, Value::TYPE_STRING,
757 key::kDefaultSearchProviderName }, 757 key::kDefaultSearchProviderName },
758 { kPolicyDefaultSearchProviderKeyword, Value::TYPE_STRING, 758 { kPolicyDefaultSearchProviderKeyword, Value::TYPE_STRING,
759 key::kDefaultSearchProviderKeyword }, 759 key::kDefaultSearchProviderKeyword },
760 { kPolicyDefaultSearchProviderSearchURL, Value::TYPE_STRING, 760 { kPolicyDefaultSearchProviderSearchURL, Value::TYPE_STRING,
761 key::kDefaultSearchProviderSearchURL }, 761 key::kDefaultSearchProviderSearchURL },
762 { kPolicyDefaultSearchProviderSuggestURL, Value::TYPE_STRING, 762 { kPolicyDefaultSearchProviderSuggestURL, Value::TYPE_STRING,
763 key::kDefaultSearchProviderSuggestURL }, 763 key::kDefaultSearchProviderSuggestURL },
(...skipping 18 matching lines...) Expand all
782 { kPolicySafeBrowsingEnabled, Value::TYPE_BOOLEAN, 782 { kPolicySafeBrowsingEnabled, Value::TYPE_BOOLEAN,
783 key::kSafeBrowsingEnabled }, 783 key::kSafeBrowsingEnabled },
784 { kPolicyMetricsReportingEnabled, Value::TYPE_BOOLEAN, 784 { kPolicyMetricsReportingEnabled, Value::TYPE_BOOLEAN,
785 key::kMetricsReportingEnabled }, 785 key::kMetricsReportingEnabled },
786 { kPolicyPasswordManagerEnabled, Value::TYPE_BOOLEAN, 786 { kPolicyPasswordManagerEnabled, Value::TYPE_BOOLEAN,
787 key::kPasswordManagerEnabled }, 787 key::kPasswordManagerEnabled },
788 { kPolicyPasswordManagerAllowShowPasswords, Value::TYPE_BOOLEAN, 788 { kPolicyPasswordManagerAllowShowPasswords, Value::TYPE_BOOLEAN,
789 key::kPasswordManagerAllowShowPasswords }, 789 key::kPasswordManagerAllowShowPasswords },
790 { kPolicyAutoFillEnabled, Value::TYPE_BOOLEAN, key::kAutoFillEnabled }, 790 { kPolicyAutoFillEnabled, Value::TYPE_BOOLEAN, key::kAutoFillEnabled },
791 { kPolicyDisabledPlugins, Value::TYPE_LIST, key::kDisabledPlugins }, 791 { kPolicyDisabledPlugins, Value::TYPE_LIST, key::kDisabledPlugins },
792 { kPolicyApplicationLocale, Value::TYPE_STRING, 792 { kPolicyApplicationLocaleValue, Value::TYPE_STRING,
793 key::kApplicationLocaleValue }, 793 key::kApplicationLocaleValue },
794 { kPolicySyncDisabled, Value::TYPE_BOOLEAN, key::kSyncDisabled }, 794 { kPolicySyncDisabled, Value::TYPE_BOOLEAN, key::kSyncDisabled },
795 { kPolicyExtensionInstallAllowList, Value::TYPE_LIST, 795 { kPolicyExtensionInstallWhitelist, Value::TYPE_LIST,
796 key::kExtensionInstallAllowList }, 796 key::kExtensionInstallWhitelist },
797 { kPolicyExtensionInstallDenyList, Value::TYPE_LIST, 797 { kPolicyExtensionInstallBlacklist, Value::TYPE_LIST,
798 key::kExtensionInstallDenyList }, 798 key::kExtensionInstallBlacklist },
799 { kPolicyExtensionInstallForceList, Value::TYPE_LIST, 799 { kPolicyExtensionInstallForcelist, Value::TYPE_LIST,
800 key::kExtensionInstallForceList }, 800 key::kExtensionInstallForcelist },
801 { kPolicyShowHomeButton, Value::TYPE_BOOLEAN, key::kShowHomeButton }, 801 { kPolicyShowHomeButton, Value::TYPE_BOOLEAN, key::kShowHomeButton },
802 { kPolicyPrintingEnabled, Value::TYPE_BOOLEAN, key::kPrintingEnabled }, 802 { kPolicyPrintingEnabled, Value::TYPE_BOOLEAN, key::kPrintingEnabled },
803 { kPolicyJavascriptEnabled, Value::TYPE_BOOLEAN, key::kJavascriptEnabled }, 803 { kPolicyJavascriptEnabled, Value::TYPE_BOOLEAN, key::kJavascriptEnabled },
804 { kPolicySavingBrowserHistoryDisabled, Value::TYPE_BOOLEAN, 804 { kPolicySavingBrowserHistoryDisabled, Value::TYPE_BOOLEAN,
805 key::kSavingBrowserHistoryDisabled }, 805 key::kSavingBrowserHistoryDisabled },
806 { kPolicyDeveloperToolsDisabled, Value::TYPE_BOOLEAN, 806 { kPolicyDeveloperToolsDisabled, Value::TYPE_BOOLEAN,
807 key::kDeveloperToolsDisabled }, 807 key::kDeveloperToolsDisabled },
808 { kPolicyBlockThirdPartyCookies, Value::TYPE_BOOLEAN, 808 { kPolicyBlockThirdPartyCookies, Value::TYPE_BOOLEAN,
809 key::kBlockThirdPartyCookies }, 809 key::kBlockThirdPartyCookies },
810 { kPolicyDefaultCookiesSetting, Value::TYPE_INTEGER, 810 { kPolicyDefaultCookiesSetting, Value::TYPE_INTEGER,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 // Update the initialization flag. 870 // Update the initialization flag.
871 if (!initialization_complete_ && 871 if (!initialization_complete_ &&
872 provider_->IsInitializationComplete()) { 872 provider_->IsInitializationComplete()) {
873 initialization_complete_ = true; 873 initialization_complete_ = true;
874 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, 874 FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
875 OnInitializationCompleted()); 875 OnInitializationCompleted());
876 } 876 }
877 } 877 }
878 878
879 } // namespace policy 879 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698