Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / chrome / browser / policy / configuration_policy_handler_list_factory.cc
blob86bb63fe4fb5d684f35345a292725e2922bec734
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h"
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/prefs/pref_value_map.h"
11 #include "base/values.h"
12 #include "chrome/browser/net/proxy_policy_handler.h"
13 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h"
14 #include "chrome/browser/profiles/incognito_mode_policy_handler.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h"
17 #include "components/content_settings/core/common/pref_names.h"
18 #include "components/password_manager/core/common/password_manager_pref_names.h"
19 #include "components/policy/core/browser/autofill_policy_handler.h"
20 #include "components/policy/core/browser/configuration_policy_handler.h"
21 #include "components/policy/core/browser/configuration_policy_handler_list.h"
22 #include "components/policy/core/browser/configuration_policy_handler_parameters.h"
23 #include "components/policy/core/browser/url_blacklist_policy_handler.h"
24 #include "components/policy/core/common/policy_details.h"
25 #include "components/policy/core/common/policy_map.h"
26 #include "components/policy/core/common/policy_pref_names.h"
27 #include "components/policy/core/common/schema.h"
28 #include "components/search_engines/default_search_policy_handler.h"
29 #include "components/translate/core/common/translate_pref_names.h"
30 #include "policy/policy_constants.h"
32 #if defined(OS_ANDROID)
33 #include "chrome/browser/search/contextual_search_policy_handler_android.h"
34 #endif
36 #if !defined(OS_IOS)
37 #include "chrome/browser/net/disk_cache_dir_policy_handler.h"
38 #include "chrome/browser/policy/file_selection_dialogs_policy_handler.h"
39 #include "chrome/browser/policy/javascript_policy_handler.h"
40 #include "chrome/browser/policy/network_prediction_policy_handler.h"
41 #include "chrome/browser/sessions/restore_on_startup_policy_handler.h"
42 #include "chrome/browser/sync/sync_policy_handler.h"
43 #endif
45 #if defined(OS_CHROMEOS)
46 #include "chrome/browser/chromeos/drive/drive_pref_names.h"
47 #include "chrome/browser/chromeos/platform_keys/key_permissions_policy_handler.h"
48 #include "chrome/browser/chromeos/policy/configuration_policy_handler_chromeos.h"
49 #include "chromeos/chromeos_pref_names.h"
50 #include "chromeos/dbus/power_policy_controller.h"
51 #include "components/user_manager/user.h"
52 #include "components/user_manager/user_manager.h"
53 #include "ui/chromeos/accessibility_types.h"
54 #endif
56 #if !defined(OS_ANDROID) && !defined(OS_IOS)
57 #include "chrome/browser/download/download_dir_policy_handler.h"
58 #endif
60 #if defined(ENABLE_EXTENSIONS)
61 #include "chrome/browser/extensions/api/messaging/native_messaging_policy_handler.h"
62 #include "chrome/browser/extensions/extension_management_constants.h"
63 #include "chrome/browser/extensions/policy_handlers.h"
64 #include "extensions/browser/pref_names.h"
65 #include "extensions/common/manifest.h"
66 #endif
68 namespace policy {
70 namespace {
72 // List of policy types to preference names. This is used for simple policies
73 // that directly map to a single preference.
74 const PolicyToPreferenceMapEntry kSimplePolicyMap[] = {
75 { key::kHomepageLocation,
76 prefs::kHomePage,
77 base::Value::TYPE_STRING },
78 { key::kHomepageIsNewTabPage,
79 prefs::kHomePageIsNewTabPage,
80 base::Value::TYPE_BOOLEAN },
81 { key::kRestoreOnStartupURLs,
82 prefs::kURLsToRestoreOnStartup,
83 base::Value::TYPE_LIST },
84 { key::kAlternateErrorPagesEnabled,
85 prefs::kAlternateErrorPagesEnabled,
86 base::Value::TYPE_BOOLEAN },
87 { key::kSearchSuggestEnabled,
88 prefs::kSearchSuggestEnabled,
89 base::Value::TYPE_BOOLEAN },
90 { key::kBuiltInDnsClientEnabled,
91 prefs::kBuiltInDnsClientEnabled,
92 base::Value::TYPE_BOOLEAN },
93 { key::kWPADQuickCheckEnabled,
94 prefs::kQuickCheckEnabled,
95 base::Value::TYPE_BOOLEAN },
96 { key::kDisableSpdy,
97 prefs::kDisableSpdy,
98 base::Value::TYPE_BOOLEAN },
99 { key::kSafeBrowsingEnabled,
100 prefs::kSafeBrowsingEnabled,
101 base::Value::TYPE_BOOLEAN },
102 { key::kForceGoogleSafeSearch,
103 prefs::kForceGoogleSafeSearch,
104 base::Value::TYPE_BOOLEAN },
105 { key::kForceYouTubeSafetyMode,
106 prefs::kForceYouTubeSafetyMode,
107 base::Value::TYPE_BOOLEAN },
108 { key::kPasswordManagerEnabled,
109 password_manager::prefs::kPasswordManagerSavingEnabled,
110 base::Value::TYPE_BOOLEAN },
111 { key::kPasswordManagerAllowShowPasswords,
112 password_manager::prefs::kPasswordManagerAllowShowPasswords,
113 base::Value::TYPE_BOOLEAN },
114 { key::kPrintingEnabled,
115 prefs::kPrintingEnabled,
116 base::Value::TYPE_BOOLEAN },
117 { key::kDisablePrintPreview,
118 prefs::kPrintPreviewDisabled,
119 base::Value::TYPE_BOOLEAN },
120 { key::kMetricsReportingEnabled,
121 prefs::kMetricsReportingEnabled,
122 base::Value::TYPE_BOOLEAN },
123 { key::kApplicationLocaleValue,
124 prefs::kApplicationLocale,
125 base::Value::TYPE_STRING },
126 { key::kDisabledPlugins,
127 prefs::kPluginsDisabledPlugins,
128 base::Value::TYPE_LIST },
129 { key::kDisabledPluginsExceptions,
130 prefs::kPluginsDisabledPluginsExceptions,
131 base::Value::TYPE_LIST },
132 { key::kEnabledPlugins,
133 prefs::kPluginsEnabledPlugins,
134 base::Value::TYPE_LIST },
135 { key::kShowHomeButton,
136 prefs::kShowHomeButton,
137 base::Value::TYPE_BOOLEAN },
138 { key::kSavingBrowserHistoryDisabled,
139 prefs::kSavingBrowserHistoryDisabled,
140 base::Value::TYPE_BOOLEAN },
141 { key::kAllowDeletingBrowserHistory,
142 prefs::kAllowDeletingBrowserHistory,
143 base::Value::TYPE_BOOLEAN },
144 { key::kDeveloperToolsDisabled,
145 prefs::kDevToolsDisabled,
146 base::Value::TYPE_BOOLEAN },
147 { key::kBlockThirdPartyCookies,
148 prefs::kBlockThirdPartyCookies,
149 base::Value::TYPE_BOOLEAN },
150 { key::kDefaultCookiesSetting,
151 prefs::kManagedDefaultCookiesSetting,
152 base::Value::TYPE_INTEGER },
153 { key::kDefaultImagesSetting,
154 prefs::kManagedDefaultImagesSetting,
155 base::Value::TYPE_INTEGER },
156 { key::kDefaultPluginsSetting,
157 prefs::kManagedDefaultPluginsSetting,
158 base::Value::TYPE_INTEGER },
159 { key::kDefaultPopupsSetting,
160 prefs::kManagedDefaultPopupsSetting,
161 base::Value::TYPE_INTEGER },
162 { key::kAutoSelectCertificateForUrls,
163 prefs::kManagedAutoSelectCertificateForUrls,
164 base::Value::TYPE_LIST },
165 { key::kCookiesAllowedForUrls,
166 prefs::kManagedCookiesAllowedForUrls,
167 base::Value::TYPE_LIST },
168 { key::kCookiesBlockedForUrls,
169 prefs::kManagedCookiesBlockedForUrls,
170 base::Value::TYPE_LIST },
171 { key::kCookiesSessionOnlyForUrls,
172 prefs::kManagedCookiesSessionOnlyForUrls,
173 base::Value::TYPE_LIST },
174 { key::kImagesAllowedForUrls,
175 prefs::kManagedImagesAllowedForUrls,
176 base::Value::TYPE_LIST },
177 { key::kImagesBlockedForUrls,
178 prefs::kManagedImagesBlockedForUrls,
179 base::Value::TYPE_LIST },
180 { key::kJavaScriptAllowedForUrls,
181 prefs::kManagedJavaScriptAllowedForUrls,
182 base::Value::TYPE_LIST },
183 { key::kJavaScriptBlockedForUrls,
184 prefs::kManagedJavaScriptBlockedForUrls,
185 base::Value::TYPE_LIST },
186 { key::kPluginsAllowedForUrls,
187 prefs::kManagedPluginsAllowedForUrls,
188 base::Value::TYPE_LIST },
189 { key::kPluginsBlockedForUrls,
190 prefs::kManagedPluginsBlockedForUrls,
191 base::Value::TYPE_LIST },
192 { key::kPopupsAllowedForUrls,
193 prefs::kManagedPopupsAllowedForUrls,
194 base::Value::TYPE_LIST },
195 { key::kPopupsBlockedForUrls,
196 prefs::kManagedPopupsBlockedForUrls,
197 base::Value::TYPE_LIST },
198 { key::kNotificationsAllowedForUrls,
199 prefs::kManagedNotificationsAllowedForUrls,
200 base::Value::TYPE_LIST },
201 { key::kNotificationsBlockedForUrls,
202 prefs::kManagedNotificationsBlockedForUrls,
203 base::Value::TYPE_LIST },
204 { key::kDefaultNotificationsSetting,
205 prefs::kManagedDefaultNotificationsSetting,
206 base::Value::TYPE_INTEGER },
207 { key::kDefaultGeolocationSetting,
208 prefs::kManagedDefaultGeolocationSetting,
209 base::Value::TYPE_INTEGER },
210 { key::kSigninAllowed,
211 prefs::kSigninAllowed,
212 base::Value::TYPE_BOOLEAN },
213 { key::kDisableSSLRecordSplitting,
214 prefs::kDisableSSLRecordSplitting,
215 base::Value::TYPE_BOOLEAN },
216 { key::kEnableOnlineRevocationChecks,
217 prefs::kCertRevocationCheckingEnabled,
218 base::Value::TYPE_BOOLEAN },
219 { key::kRequireOnlineRevocationChecksForLocalAnchors,
220 prefs::kCertRevocationCheckingRequiredLocalAnchors,
221 base::Value::TYPE_BOOLEAN },
222 { key::kAuthSchemes,
223 prefs::kAuthSchemes,
224 base::Value::TYPE_STRING },
225 { key::kDisableAuthNegotiateCnameLookup,
226 prefs::kDisableAuthNegotiateCnameLookup,
227 base::Value::TYPE_BOOLEAN },
228 { key::kEnableAuthNegotiatePort,
229 prefs::kEnableAuthNegotiatePort,
230 base::Value::TYPE_BOOLEAN },
231 { key::kAuthServerWhitelist,
232 prefs::kAuthServerWhitelist,
233 base::Value::TYPE_STRING },
234 { key::kAuthNegotiateDelegateWhitelist,
235 prefs::kAuthNegotiateDelegateWhitelist,
236 base::Value::TYPE_STRING },
237 { key::kGSSAPILibraryName,
238 prefs::kGSSAPILibraryName,
239 base::Value::TYPE_STRING },
240 { key::kAllowCrossOriginAuthPrompt,
241 prefs::kAllowCrossOriginAuthPrompt,
242 base::Value::TYPE_BOOLEAN },
243 { key::kDisable3DAPIs,
244 prefs::kDisable3DAPIs,
245 base::Value::TYPE_BOOLEAN },
246 { key::kDisablePluginFinder,
247 prefs::kDisablePluginFinder,
248 base::Value::TYPE_BOOLEAN },
249 { key::kDiskCacheSize,
250 prefs::kDiskCacheSize,
251 base::Value::TYPE_INTEGER },
252 { key::kMediaCacheSize,
253 prefs::kMediaCacheSize,
254 base::Value::TYPE_INTEGER },
255 { key::kPolicyRefreshRate,
256 policy_prefs::kUserPolicyRefreshRate,
257 base::Value::TYPE_INTEGER },
258 { key::kDevicePolicyRefreshRate,
259 prefs::kDevicePolicyRefreshRate,
260 base::Value::TYPE_INTEGER },
261 { key::kDefaultBrowserSettingEnabled,
262 prefs::kDefaultBrowserSettingEnabled,
263 base::Value::TYPE_BOOLEAN },
264 { key::kCloudPrintProxyEnabled,
265 prefs::kCloudPrintProxyEnabled,
266 base::Value::TYPE_BOOLEAN },
267 { key::kCloudPrintSubmitEnabled,
268 prefs::kCloudPrintSubmitEnabled,
269 base::Value::TYPE_BOOLEAN },
270 { key::kTranslateEnabled,
271 prefs::kEnableTranslate,
272 base::Value::TYPE_BOOLEAN },
273 { key::kAllowOutdatedPlugins,
274 prefs::kPluginsAllowOutdated,
275 base::Value::TYPE_BOOLEAN },
276 { key::kAlwaysAuthorizePlugins,
277 prefs::kPluginsAlwaysAuthorize,
278 base::Value::TYPE_BOOLEAN },
279 { key::kBookmarkBarEnabled,
280 bookmarks::prefs::kShowBookmarkBar,
281 base::Value::TYPE_BOOLEAN },
282 { key::kEditBookmarksEnabled,
283 bookmarks::prefs::kEditBookmarksEnabled,
284 base::Value::TYPE_BOOLEAN },
285 { key::kShowAppsShortcutInBookmarkBar,
286 bookmarks::prefs::kShowAppsShortcutInBookmarkBar,
287 base::Value::TYPE_BOOLEAN },
288 { key::kAllowFileSelectionDialogs,
289 prefs::kAllowFileSelectionDialogs,
290 base::Value::TYPE_BOOLEAN },
291 { key::kImportBookmarks,
292 prefs::kImportBookmarks,
293 base::Value::TYPE_BOOLEAN },
294 { key::kImportHistory,
295 prefs::kImportHistory,
296 base::Value::TYPE_BOOLEAN },
297 { key::kImportHomepage,
298 prefs::kImportHomepage,
299 base::Value::TYPE_BOOLEAN },
300 { key::kImportSearchEngine,
301 prefs::kImportSearchEngine,
302 base::Value::TYPE_BOOLEAN },
303 { key::kImportSavedPasswords,
304 prefs::kImportSavedPasswords,
305 base::Value::TYPE_BOOLEAN },
306 { key::kImportAutofillFormData,
307 prefs::kImportAutofillFormData,
308 base::Value::TYPE_BOOLEAN },
309 { key::kMaxConnectionsPerProxy,
310 prefs::kMaxConnectionsPerProxy,
311 base::Value::TYPE_INTEGER },
312 { key::kURLWhitelist,
313 policy_prefs::kUrlWhitelist,
314 base::Value::TYPE_LIST },
315 { key::kRestrictSigninToPattern,
316 prefs::kGoogleServicesUsernamePattern,
317 base::Value::TYPE_STRING },
318 { key::kDefaultMediaStreamSetting,
319 prefs::kManagedDefaultMediaStreamSetting,
320 base::Value::TYPE_INTEGER },
321 { key::kDisableSafeBrowsingProceedAnyway,
322 prefs::kSafeBrowsingProceedAnywayDisabled,
323 base::Value::TYPE_BOOLEAN },
324 { key::kSafeBrowsingExtendedReportingOptInAllowed,
325 prefs::kSafeBrowsingExtendedReportingOptInAllowed,
326 base::Value::TYPE_BOOLEAN },
327 { key::kSSLErrorOverrideAllowed,
328 prefs::kSSLErrorOverrideAllowed,
329 base::Value::TYPE_BOOLEAN },
330 { key::kHardwareAccelerationModeEnabled,
331 prefs::kHardwareAccelerationModeEnabled,
332 base::Value::TYPE_BOOLEAN },
334 #if defined(ENABLE_SPELLCHECK)
335 { key::kSpellCheckServiceEnabled,
336 prefs::kSpellCheckUseSpellingService,
337 base::Value::TYPE_BOOLEAN },
338 #endif // defined(ENABLE_SPELLCHECK)
340 { key::kDisableScreenshots,
341 prefs::kDisableScreenshots,
342 base::Value::TYPE_BOOLEAN },
343 { key::kAudioCaptureAllowed,
344 prefs::kAudioCaptureAllowed,
345 base::Value::TYPE_BOOLEAN },
346 { key::kVideoCaptureAllowed,
347 prefs::kVideoCaptureAllowed,
348 base::Value::TYPE_BOOLEAN },
349 { key::kAudioCaptureAllowedUrls,
350 prefs::kAudioCaptureAllowedUrls,
351 base::Value::TYPE_LIST },
352 { key::kVideoCaptureAllowedUrls,
353 prefs::kVideoCaptureAllowedUrls,
354 base::Value::TYPE_LIST },
355 { key::kHideWebStoreIcon,
356 prefs::kHideWebStoreIcon,
357 base::Value::TYPE_BOOLEAN },
358 { key::kVariationsRestrictParameter,
359 prefs::kVariationsRestrictParameter,
360 base::Value::TYPE_STRING },
361 { key::kSupervisedUserCreationEnabled,
362 prefs::kSupervisedUserCreationAllowed,
363 base::Value::TYPE_BOOLEAN },
364 { key::kForceEphemeralProfiles,
365 prefs::kForceEphemeralProfiles,
366 base::Value::TYPE_BOOLEAN },
367 { key::kSSLVersionFallbackMin,
368 prefs::kSSLVersionFallbackMin,
369 base::Value::TYPE_STRING },
371 #if !defined(OS_MACOSX) && !defined(OS_IOS)
372 { key::kFullscreenAllowed,
373 prefs::kFullscreenAllowed,
374 base::Value::TYPE_BOOLEAN },
375 #if defined(ENABLE_EXTENSIONS)
376 { key::kFullscreenAllowed,
377 extensions::pref_names::kAppFullscreenAllowed,
378 base::Value::TYPE_BOOLEAN },
379 #endif // defined(ENABLE_EXTENSIONS)
380 #endif // !defined(OS_MACOSX) && !defined(OS_IOS)
382 #if defined(OS_CHROMEOS)
383 { key::kChromeOsLockOnIdleSuspend,
384 prefs::kEnableAutoScreenLock,
385 base::Value::TYPE_BOOLEAN },
386 { key::kChromeOsReleaseChannel,
387 prefs::kChromeOsReleaseChannel,
388 base::Value::TYPE_STRING },
389 { key::kDriveDisabled,
390 drive::prefs::kDisableDrive,
391 base::Value::TYPE_BOOLEAN },
392 { key::kDriveDisabledOverCellular,
393 drive::prefs::kDisableDriveOverCellular,
394 base::Value::TYPE_BOOLEAN },
395 { key::kExternalStorageDisabled,
396 prefs::kExternalStorageDisabled,
397 base::Value::TYPE_BOOLEAN },
398 { key::kAudioOutputAllowed,
399 chromeos::prefs::kAudioOutputAllowed,
400 base::Value::TYPE_BOOLEAN },
401 { key::kShowLogoutButtonInTray,
402 prefs::kShowLogoutButtonInTray,
403 base::Value::TYPE_BOOLEAN },
404 { key::kShelfAutoHideBehavior,
405 prefs::kShelfAutoHideBehaviorLocal,
406 base::Value::TYPE_STRING },
407 { key::kSessionLengthLimit,
408 prefs::kSessionLengthLimit,
409 base::Value::TYPE_INTEGER },
410 { key::kWaitForInitialUserActivity,
411 prefs::kSessionWaitForInitialUserActivity,
412 base::Value::TYPE_BOOLEAN },
413 { key::kPowerManagementUsesAudioActivity,
414 prefs::kPowerUseAudioActivity,
415 base::Value::TYPE_BOOLEAN },
416 { key::kPowerManagementUsesVideoActivity,
417 prefs::kPowerUseVideoActivity,
418 base::Value::TYPE_BOOLEAN },
419 { key::kAllowScreenWakeLocks,
420 prefs::kPowerAllowScreenWakeLocks,
421 base::Value::TYPE_BOOLEAN },
422 { key::kWaitForInitialUserActivity,
423 prefs::kPowerWaitForInitialUserActivity,
424 base::Value::TYPE_BOOLEAN },
425 { key::kTermsOfServiceURL,
426 prefs::kTermsOfServiceURL,
427 base::Value::TYPE_STRING },
428 { key::kShowAccessibilityOptionsInSystemTrayMenu,
429 prefs::kShouldAlwaysShowAccessibilityMenu,
430 base::Value::TYPE_BOOLEAN },
431 { key::kLargeCursorEnabled,
432 prefs::kAccessibilityLargeCursorEnabled,
433 base::Value::TYPE_BOOLEAN },
434 { key::kSpokenFeedbackEnabled,
435 prefs::kAccessibilitySpokenFeedbackEnabled,
436 base::Value::TYPE_BOOLEAN },
437 { key::kHighContrastEnabled,
438 prefs::kAccessibilityHighContrastEnabled,
439 base::Value::TYPE_BOOLEAN },
440 { key::kVirtualKeyboardEnabled,
441 prefs::kAccessibilityVirtualKeyboardEnabled,
442 base::Value::TYPE_BOOLEAN },
443 { key::kDeviceLoginScreenDefaultLargeCursorEnabled,
444 NULL,
445 base::Value::TYPE_BOOLEAN },
446 { key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled,
447 NULL,
448 base::Value::TYPE_BOOLEAN },
449 { key::kDeviceLoginScreenDefaultHighContrastEnabled,
450 NULL,
451 base::Value::TYPE_BOOLEAN },
452 { key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled,
453 NULL,
454 base::Value::TYPE_BOOLEAN },
455 { key::kRebootAfterUpdate,
456 prefs::kRebootAfterUpdate,
457 base::Value::TYPE_BOOLEAN },
458 { key::kAttestationEnabledForUser,
459 prefs::kAttestationEnabled,
460 base::Value::TYPE_BOOLEAN },
461 { key::kChromeOsMultiProfileUserBehavior,
462 prefs::kMultiProfileUserBehavior,
463 base::Value::TYPE_STRING },
464 { key::kKeyboardDefaultToFunctionKeys,
465 prefs::kLanguageSendFunctionKeys,
466 base::Value::TYPE_BOOLEAN },
467 { key::kTouchVirtualKeyboardEnabled,
468 prefs::kTouchVirtualKeyboardEnabled,
469 base::Value::TYPE_BOOLEAN },
470 { key::kEasyUnlockAllowed,
471 prefs::kEasyUnlockAllowed,
472 base::Value::TYPE_BOOLEAN },
473 { key::kCaptivePortalAuthenticationIgnoresProxy,
474 prefs::kCaptivePortalAuthenticationIgnoresProxy,
475 base::Value::TYPE_BOOLEAN },
476 { key::kForceMaximizeOnFirstRun,
477 prefs::kForceMaximizeOnFirstRun,
478 base::Value::TYPE_BOOLEAN },
479 #endif // defined(OS_CHROMEOS)
481 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
482 { key::kBackgroundModeEnabled,
483 prefs::kBackgroundModeEnabled,
484 base::Value::TYPE_BOOLEAN },
485 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
487 #if defined(OS_ANDROID)
488 { key::kDataCompressionProxyEnabled,
489 data_reduction_proxy::prefs::kDataReductionProxyEnabled,
490 base::Value::TYPE_BOOLEAN },
491 { key::kAuthAndroidNegotiateAccountType,
492 prefs::kAuthAndroidNegotiateAccountType,
493 base::Value::TYPE_STRING },
494 #endif // defined(OS_ANDROID)
496 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
497 { key::kNativeMessagingUserLevelHosts,
498 extensions::pref_names::kNativeMessagingUserLevelHosts,
499 base::Value::TYPE_BOOLEAN },
500 { key::kBrowserGuestModeEnabled,
501 prefs::kBrowserGuestModeEnabled,
502 base::Value::TYPE_BOOLEAN },
503 { key::kBrowserAddPersonEnabled,
504 prefs::kBrowserAddPersonEnabled,
505 base::Value::TYPE_BOOLEAN },
506 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
508 #if defined(OS_WIN)
509 { key::kWelcomePageOnOSUpgradeEnabled,
510 prefs::kWelcomePageOnOSUpgradeEnabled,
511 base::Value::TYPE_BOOLEAN },
512 #endif // OS_WIN
515 class ForceSafeSearchPolicyHandler : public TypeCheckingPolicyHandler {
516 public:
517 ForceSafeSearchPolicyHandler()
518 : TypeCheckingPolicyHandler(key::kForceSafeSearch,
519 base::Value::TYPE_BOOLEAN) {}
520 ~ForceSafeSearchPolicyHandler() override {}
522 // ConfigurationPolicyHandler implementation:
523 void ApplyPolicySettings(const PolicyMap& policies,
524 PrefValueMap* prefs) override {
525 // If either of the new GoogleSafeSearch or YouTubeSafetyMode policies is
526 // defined, then this one should be ignored. crbug.com/476908
527 // Note: Those policies are declared in kSimplePolicyMap above.
528 if (policies.GetValue(key::kForceGoogleSafeSearch) ||
529 policies.GetValue(key::kForceYouTubeSafetyMode)) {
530 return;
532 const base::Value* value = policies.GetValue(policy_name());
533 if (value) {
534 prefs->SetValue(prefs::kForceGoogleSafeSearch, value->CreateDeepCopy());
535 prefs->SetValue(prefs::kForceYouTubeSafetyMode, value->CreateDeepCopy());
539 private:
540 DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler);
543 #if defined(ENABLE_EXTENSIONS)
544 void GetExtensionAllowedTypesMap(
545 ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) {
546 // Mapping from extension type names to Manifest::Type.
547 for (size_t index = 0;
548 index < extensions::schema_constants::kAllowedTypesMapSize;
549 ++index) {
550 const extensions::schema_constants::AllowedTypesMapEntry& entry =
551 extensions::schema_constants::kAllowedTypesMap[index];
552 result->push_back(new StringMappingListPolicyHandler::MappingEntry(
553 entry.name,
554 scoped_ptr<base::Value>(
555 new base::FundamentalValue(entry.manifest_type))));
558 #endif
560 #if !defined(OS_IOS)
561 void GetDeprecatedFeaturesMap(
562 ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) {
563 // Maps feature tags as specified in policy to the corresponding switch to
564 // re-enable them.
566 #endif // !defined(OS_IOS)
568 } // namespace
570 void PopulatePolicyHandlerParameters(PolicyHandlerParameters* parameters) {
571 #if defined(OS_CHROMEOS)
572 if (user_manager::UserManager::IsInitialized()) {
573 const user_manager::User* user =
574 user_manager::UserManager::Get()->GetActiveUser();
575 if (user)
576 parameters->user_id_hash = user->username_hash();
578 #endif
581 scoped_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
582 const Schema& chrome_schema) {
583 scoped_ptr<ConfigurationPolicyHandlerList> handlers(
584 new ConfigurationPolicyHandlerList(
585 base::Bind(&PopulatePolicyHandlerParameters),
586 base::Bind(&GetChromePolicyDetails)));
587 for (size_t i = 0; i < arraysize(kSimplePolicyMap); ++i) {
588 handlers->AddHandler(make_scoped_ptr(new SimplePolicyHandler(
589 kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path,
590 kSimplePolicyMap[i].value_type)));
593 handlers->AddHandler(make_scoped_ptr(new AutofillPolicyHandler()));
594 handlers->AddHandler(make_scoped_ptr(new DefaultSearchPolicyHandler()));
595 handlers->AddHandler(make_scoped_ptr(new ForceSafeSearchPolicyHandler()));
596 handlers->AddHandler(make_scoped_ptr(new IncognitoModePolicyHandler()));
597 handlers->AddHandler(
598 make_scoped_ptr(new ManagedBookmarksPolicyHandler(chrome_schema)));
599 handlers->AddHandler(make_scoped_ptr(new ProxyPolicyHandler()));
600 handlers->AddHandler(make_scoped_ptr(new URLBlacklistPolicyHandler()));
602 #if defined(OS_ANDROID)
603 handlers->AddHandler(
604 make_scoped_ptr(new ContextualSearchPolicyHandlerAndroid()));
605 #endif
607 #if !defined(OS_IOS)
608 handlers->AddHandler(
609 make_scoped_ptr(new FileSelectionDialogsPolicyHandler()));
610 handlers->AddHandler(make_scoped_ptr(new JavascriptPolicyHandler()));
611 handlers->AddHandler(make_scoped_ptr(new NetworkPredictionPolicyHandler()));
612 handlers->AddHandler(make_scoped_ptr(new RestoreOnStartupPolicyHandler()));
613 handlers->AddHandler(make_scoped_ptr(new browser_sync::SyncPolicyHandler()));
615 handlers->AddHandler(make_scoped_ptr(new StringMappingListPolicyHandler(
616 key::kEnableDeprecatedWebPlatformFeatures,
617 prefs::kEnableDeprecatedWebPlatformFeatures,
618 base::Bind(GetDeprecatedFeaturesMap))));
619 #endif // !defined(OS_IOS)
621 #if defined(ENABLE_EXTENSIONS)
622 handlers->AddHandler(
623 make_scoped_ptr(new extensions::ExtensionListPolicyHandler(
624 key::kExtensionInstallWhitelist,
625 extensions::pref_names::kInstallAllowList, false)));
626 handlers->AddHandler(
627 make_scoped_ptr(new extensions::ExtensionListPolicyHandler(
628 key::kExtensionInstallBlacklist,
629 extensions::pref_names::kInstallDenyList, true)));
630 handlers->AddHandler(make_scoped_ptr(
631 new extensions::ExtensionInstallForcelistPolicyHandler()));
632 handlers->AddHandler(
633 make_scoped_ptr(new extensions::ExtensionURLPatternListPolicyHandler(
634 key::kExtensionInstallSources,
635 extensions::pref_names::kAllowedInstallSites)));
636 handlers->AddHandler(make_scoped_ptr(new StringMappingListPolicyHandler(
637 key::kExtensionAllowedTypes, extensions::pref_names::kAllowedTypes,
638 base::Bind(GetExtensionAllowedTypesMap))));
639 handlers->AddHandler(make_scoped_ptr(
640 new extensions::ExtensionSettingsPolicyHandler(chrome_schema)));
641 #endif
643 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
644 handlers->AddHandler(make_scoped_ptr(new DiskCacheDirPolicyHandler()));
646 handlers->AddHandler(
647 make_scoped_ptr(new extensions::NativeMessagingHostListPolicyHandler(
648 key::kNativeMessagingWhitelist,
649 extensions::pref_names::kNativeMessagingWhitelist, false)));
650 handlers->AddHandler(
651 make_scoped_ptr(new extensions::NativeMessagingHostListPolicyHandler(
652 key::kNativeMessagingBlacklist,
653 extensions::pref_names::kNativeMessagingBlacklist, true)));
654 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
656 #if !defined(OS_ANDROID) && !defined(OS_IOS)
657 handlers->AddHandler(make_scoped_ptr(new DownloadDirPolicyHandler));
659 handlers->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler(
660 key::kRegisteredProtocolHandlers,
661 prefs::kPolicyRegisteredProtocolHandlers, chrome_schema, SCHEMA_STRICT,
662 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED,
663 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED)));
664 #endif
666 #if defined(OS_CHROMEOS)
667 handlers->AddHandler(
668 make_scoped_ptr(new extensions::ExtensionListPolicyHandler(
669 key::kAttestationExtensionWhitelist,
670 prefs::kAttestationExtensionWhitelist, false)));
671 handlers->AddHandler(make_scoped_ptr(
672 NetworkConfigurationPolicyHandler::CreateForDevicePolicy()));
673 handlers->AddHandler(make_scoped_ptr(
674 NetworkConfigurationPolicyHandler::CreateForUserPolicy()));
675 handlers->AddHandler(make_scoped_ptr(new PinnedLauncherAppsPolicyHandler()));
676 handlers->AddHandler(make_scoped_ptr(new ScreenMagnifierPolicyHandler()));
677 handlers->AddHandler(make_scoped_ptr(
678 new LoginScreenPowerManagementPolicyHandler(chrome_schema)));
680 ScopedVector<ConfigurationPolicyHandler>
681 power_management_idle_legacy_policies;
682 power_management_idle_legacy_policies.push_back(
683 new IntRangePolicyHandler(key::kScreenDimDelayAC,
684 prefs::kPowerAcScreenDimDelayMs,
686 INT_MAX,
687 true));
688 power_management_idle_legacy_policies.push_back(
689 new IntRangePolicyHandler(key::kScreenOffDelayAC,
690 prefs::kPowerAcScreenOffDelayMs,
692 INT_MAX,
693 true));
694 power_management_idle_legacy_policies.push_back(
695 new IntRangePolicyHandler(key::kIdleWarningDelayAC,
696 prefs::kPowerAcIdleWarningDelayMs,
698 INT_MAX,
699 true));
700 power_management_idle_legacy_policies.push_back(new IntRangePolicyHandler(
701 key::kIdleDelayAC, prefs::kPowerAcIdleDelayMs, 0, INT_MAX, true));
702 power_management_idle_legacy_policies.push_back(
703 new IntRangePolicyHandler(key::kScreenDimDelayBattery,
704 prefs::kPowerBatteryScreenDimDelayMs,
706 INT_MAX,
707 true));
708 power_management_idle_legacy_policies.push_back(
709 new IntRangePolicyHandler(key::kScreenOffDelayBattery,
710 prefs::kPowerBatteryScreenOffDelayMs,
712 INT_MAX,
713 true));
714 power_management_idle_legacy_policies.push_back(
715 new IntRangePolicyHandler(key::kIdleWarningDelayBattery,
716 prefs::kPowerBatteryIdleWarningDelayMs,
718 INT_MAX,
719 true));
720 power_management_idle_legacy_policies.push_back(
721 new IntRangePolicyHandler(key::kIdleDelayBattery,
722 prefs::kPowerBatteryIdleDelayMs,
724 INT_MAX,
725 true));
726 power_management_idle_legacy_policies.push_back(new IntRangePolicyHandler(
727 key::kIdleActionAC,
728 prefs::kPowerAcIdleAction,
729 chromeos::PowerPolicyController::ACTION_SUSPEND,
730 chromeos::PowerPolicyController::ACTION_DO_NOTHING,
731 false));
732 power_management_idle_legacy_policies.push_back(new IntRangePolicyHandler(
733 key::kIdleActionBattery,
734 prefs::kPowerBatteryIdleAction,
735 chromeos::PowerPolicyController::ACTION_SUSPEND,
736 chromeos::PowerPolicyController::ACTION_DO_NOTHING,
737 false));
738 power_management_idle_legacy_policies.push_back(
739 new DeprecatedIdleActionHandler());
741 ScopedVector<ConfigurationPolicyHandler> screen_lock_legacy_policies;
742 screen_lock_legacy_policies.push_back(
743 new IntRangePolicyHandler(key::kScreenLockDelayAC,
744 prefs::kPowerAcScreenLockDelayMs,
746 INT_MAX,
747 true));
748 screen_lock_legacy_policies.push_back(
749 new IntRangePolicyHandler(key::kScreenLockDelayBattery,
750 prefs::kPowerBatteryScreenLockDelayMs,
752 INT_MAX,
753 true));
755 handlers->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
756 key::kSAMLOfflineSigninTimeLimit, prefs::kSAMLOfflineSigninTimeLimit, -1,
757 INT_MAX, true)));
758 handlers->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
759 key::kLidCloseAction, prefs::kPowerLidClosedAction,
760 chromeos::PowerPolicyController::ACTION_SUSPEND,
761 chromeos::PowerPolicyController::ACTION_DO_NOTHING, false)));
762 handlers->AddHandler(make_scoped_ptr(new IntPercentageToDoublePolicyHandler(
763 key::kPresentationScreenDimDelayScale,
764 prefs::kPowerPresentationScreenDimDelayFactor, 100, INT_MAX, true)));
765 handlers->AddHandler(make_scoped_ptr(new IntPercentageToDoublePolicyHandler(
766 key::kUserActivityScreenDimDelayScale,
767 prefs::kPowerUserActivityScreenDimDelayFactor, 100, INT_MAX, true)));
768 handlers->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
769 key::kUptimeLimit, prefs::kUptimeLimit, 3600, INT_MAX, true)));
770 handlers->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
771 key::kDeviceLoginScreenDefaultScreenMagnifierType, NULL, 0,
772 ui::MAGNIFIER_FULL, false)));
773 // TODO(binjin): Remove LegacyPoliciesDeprecatingPolicyHandler for these two
774 // policies once deprecation of legacy power management policies is done.
775 // http://crbug.com/346229
776 handlers->AddHandler(
777 make_scoped_ptr(new LegacyPoliciesDeprecatingPolicyHandler(
778 power_management_idle_legacy_policies.Pass(),
779 make_scoped_ptr(
780 new PowerManagementIdleSettingsPolicyHandler(chrome_schema)))));
781 handlers->AddHandler(
782 make_scoped_ptr(new LegacyPoliciesDeprecatingPolicyHandler(
783 screen_lock_legacy_policies.Pass(),
784 make_scoped_ptr(new ScreenLockDelayPolicyHandler(chrome_schema)))));
785 handlers->AddHandler(
786 make_scoped_ptr(new ExternalDataPolicyHandler(key::kUserAvatarImage)));
787 handlers->AddHandler(
788 make_scoped_ptr(new ExternalDataPolicyHandler(key::kWallpaperImage)));
789 handlers->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler(
790 key::kSessionLocales, NULL, chrome_schema, SCHEMA_STRICT,
791 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED,
792 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED)));
793 handlers->AddHandler(make_scoped_ptr(
794 new chromeos::KeyPermissionsPolicyHandler(chrome_schema)));
795 #endif // defined(OS_CHROMEOS)
797 return handlers.Pass();
800 } // namespace policy