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