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 #endif // defined(OS_CHROMEOS)
482 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
483 { key::kBackgroundModeEnabled
,
484 prefs::kBackgroundModeEnabled
,
485 base::Value::TYPE_BOOLEAN
},
486 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
488 #if defined(OS_ANDROID)
489 { key::kDataCompressionProxyEnabled
,
490 data_reduction_proxy::prefs::kDataReductionProxyEnabled
,
491 base::Value::TYPE_BOOLEAN
},
492 { key::kAuthAndroidNegotiateAccountType
,
493 prefs::kAuthAndroidNegotiateAccountType
,
494 base::Value::TYPE_STRING
},
495 #endif // defined(OS_ANDROID)
497 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
498 { key::kNativeMessagingUserLevelHosts
,
499 extensions::pref_names::kNativeMessagingUserLevelHosts
,
500 base::Value::TYPE_BOOLEAN
},
501 { key::kBrowserGuestModeEnabled
,
502 prefs::kBrowserGuestModeEnabled
,
503 base::Value::TYPE_BOOLEAN
},
504 { key::kBrowserAddPersonEnabled
,
505 prefs::kBrowserAddPersonEnabled
,
506 base::Value::TYPE_BOOLEAN
},
507 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
510 { key::kWelcomePageOnOSUpgradeEnabled
,
511 prefs::kWelcomePageOnOSUpgradeEnabled
,
512 base::Value::TYPE_BOOLEAN
},
516 class ForceSafeSearchPolicyHandler
: public TypeCheckingPolicyHandler
{
518 ForceSafeSearchPolicyHandler()
519 : TypeCheckingPolicyHandler(key::kForceSafeSearch
,
520 base::Value::TYPE_BOOLEAN
) {}
521 ~ForceSafeSearchPolicyHandler() override
{}
523 // ConfigurationPolicyHandler implementation:
524 void ApplyPolicySettings(const PolicyMap
& policies
,
525 PrefValueMap
* prefs
) override
{
526 // If either of the new GoogleSafeSearch or YouTubeSafetyMode policies is
527 // defined, then this one should be ignored. crbug.com/476908
528 // Note: Those policies are declared in kSimplePolicyMap above.
529 if (policies
.GetValue(key::kForceGoogleSafeSearch
) ||
530 policies
.GetValue(key::kForceYouTubeSafetyMode
)) {
533 const base::Value
* value
= policies
.GetValue(policy_name());
535 prefs
->SetValue(prefs::kForceGoogleSafeSearch
, value
->CreateDeepCopy());
536 prefs
->SetValue(prefs::kForceYouTubeSafetyMode
, value
->CreateDeepCopy());
541 DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler
);
544 #if defined(ENABLE_EXTENSIONS)
545 void GetExtensionAllowedTypesMap(
546 ScopedVector
<StringMappingListPolicyHandler::MappingEntry
>* result
) {
547 // Mapping from extension type names to Manifest::Type.
548 for (size_t index
= 0;
549 index
< extensions::schema_constants::kAllowedTypesMapSize
;
551 const extensions::schema_constants::AllowedTypesMapEntry
& entry
=
552 extensions::schema_constants::kAllowedTypesMap
[index
];
553 result
->push_back(new StringMappingListPolicyHandler::MappingEntry(
555 scoped_ptr
<base::Value
>(
556 new base::FundamentalValue(entry
.manifest_type
))));
562 void GetDeprecatedFeaturesMap(
563 ScopedVector
<StringMappingListPolicyHandler::MappingEntry
>* result
) {
564 // Maps feature tags as specified in policy to the corresponding switch to
567 #endif // !defined(OS_IOS)
571 void PopulatePolicyHandlerParameters(PolicyHandlerParameters
* parameters
) {
572 #if defined(OS_CHROMEOS)
573 if (user_manager::UserManager::IsInitialized()) {
574 const user_manager::User
* user
=
575 user_manager::UserManager::Get()->GetActiveUser();
577 parameters
->user_id_hash
= user
->username_hash();
582 scoped_ptr
<ConfigurationPolicyHandlerList
> BuildHandlerList(
583 const Schema
& chrome_schema
) {
584 scoped_ptr
<ConfigurationPolicyHandlerList
> handlers(
585 new ConfigurationPolicyHandlerList(
586 base::Bind(&PopulatePolicyHandlerParameters
),
587 base::Bind(&GetChromePolicyDetails
)));
588 for (size_t i
= 0; i
< arraysize(kSimplePolicyMap
); ++i
) {
589 handlers
->AddHandler(make_scoped_ptr(new SimplePolicyHandler(
590 kSimplePolicyMap
[i
].policy_name
, kSimplePolicyMap
[i
].preference_path
,
591 kSimplePolicyMap
[i
].value_type
)));
594 handlers
->AddHandler(make_scoped_ptr(new AutofillPolicyHandler()));
595 handlers
->AddHandler(make_scoped_ptr(new DefaultSearchPolicyHandler()));
596 handlers
->AddHandler(make_scoped_ptr(new ForceSafeSearchPolicyHandler()));
597 handlers
->AddHandler(make_scoped_ptr(new IncognitoModePolicyHandler()));
598 handlers
->AddHandler(
599 make_scoped_ptr(new ManagedBookmarksPolicyHandler(chrome_schema
)));
600 handlers
->AddHandler(make_scoped_ptr(new ProxyPolicyHandler()));
601 handlers
->AddHandler(make_scoped_ptr(new URLBlacklistPolicyHandler()));
603 #if defined(OS_ANDROID)
604 handlers
->AddHandler(
605 make_scoped_ptr(new ContextualSearchPolicyHandlerAndroid()));
609 handlers
->AddHandler(
610 make_scoped_ptr(new FileSelectionDialogsPolicyHandler()));
611 handlers
->AddHandler(make_scoped_ptr(new JavascriptPolicyHandler()));
612 handlers
->AddHandler(make_scoped_ptr(new NetworkPredictionPolicyHandler()));
613 handlers
->AddHandler(make_scoped_ptr(new RestoreOnStartupPolicyHandler()));
614 handlers
->AddHandler(make_scoped_ptr(new sync_driver::SyncPolicyHandler()));
616 handlers
->AddHandler(make_scoped_ptr(new StringMappingListPolicyHandler(
617 key::kEnableDeprecatedWebPlatformFeatures
,
618 prefs::kEnableDeprecatedWebPlatformFeatures
,
619 base::Bind(GetDeprecatedFeaturesMap
))));
620 #endif // !defined(OS_IOS)
622 #if defined(ENABLE_EXTENSIONS)
623 handlers
->AddHandler(
624 make_scoped_ptr(new extensions::ExtensionListPolicyHandler(
625 key::kExtensionInstallWhitelist
,
626 extensions::pref_names::kInstallAllowList
, false)));
627 handlers
->AddHandler(
628 make_scoped_ptr(new extensions::ExtensionListPolicyHandler(
629 key::kExtensionInstallBlacklist
,
630 extensions::pref_names::kInstallDenyList
, true)));
631 handlers
->AddHandler(make_scoped_ptr(
632 new extensions::ExtensionInstallForcelistPolicyHandler()));
633 handlers
->AddHandler(
634 make_scoped_ptr(new extensions::ExtensionURLPatternListPolicyHandler(
635 key::kExtensionInstallSources
,
636 extensions::pref_names::kAllowedInstallSites
)));
637 handlers
->AddHandler(make_scoped_ptr(new StringMappingListPolicyHandler(
638 key::kExtensionAllowedTypes
, extensions::pref_names::kAllowedTypes
,
639 base::Bind(GetExtensionAllowedTypesMap
))));
640 handlers
->AddHandler(make_scoped_ptr(
641 new extensions::ExtensionSettingsPolicyHandler(chrome_schema
)));
644 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
645 handlers
->AddHandler(make_scoped_ptr(new DiskCacheDirPolicyHandler()));
647 handlers
->AddHandler(
648 make_scoped_ptr(new extensions::NativeMessagingHostListPolicyHandler(
649 key::kNativeMessagingWhitelist
,
650 extensions::pref_names::kNativeMessagingWhitelist
, false)));
651 handlers
->AddHandler(
652 make_scoped_ptr(new extensions::NativeMessagingHostListPolicyHandler(
653 key::kNativeMessagingBlacklist
,
654 extensions::pref_names::kNativeMessagingBlacklist
, true)));
655 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
657 #if !defined(OS_ANDROID) && !defined(OS_IOS)
658 handlers
->AddHandler(make_scoped_ptr(new DownloadDirPolicyHandler
));
660 handlers
->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler(
661 key::kRegisteredProtocolHandlers
,
662 prefs::kPolicyRegisteredProtocolHandlers
, chrome_schema
, SCHEMA_STRICT
,
663 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED
,
664 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED
)));
667 #if defined(OS_CHROMEOS)
668 handlers
->AddHandler(
669 make_scoped_ptr(new extensions::ExtensionListPolicyHandler(
670 key::kAttestationExtensionWhitelist
,
671 prefs::kAttestationExtensionWhitelist
, false)));
672 handlers
->AddHandler(make_scoped_ptr(
673 NetworkConfigurationPolicyHandler::CreateForDevicePolicy()));
674 handlers
->AddHandler(make_scoped_ptr(
675 NetworkConfigurationPolicyHandler::CreateForUserPolicy()));
676 handlers
->AddHandler(make_scoped_ptr(new PinnedLauncherAppsPolicyHandler()));
677 handlers
->AddHandler(make_scoped_ptr(new ScreenMagnifierPolicyHandler()));
678 handlers
->AddHandler(make_scoped_ptr(
679 new LoginScreenPowerManagementPolicyHandler(chrome_schema
)));
681 ScopedVector
<ConfigurationPolicyHandler
>
682 power_management_idle_legacy_policies
;
683 power_management_idle_legacy_policies
.push_back(
684 new IntRangePolicyHandler(key::kScreenDimDelayAC
,
685 prefs::kPowerAcScreenDimDelayMs
,
689 power_management_idle_legacy_policies
.push_back(
690 new IntRangePolicyHandler(key::kScreenOffDelayAC
,
691 prefs::kPowerAcScreenOffDelayMs
,
695 power_management_idle_legacy_policies
.push_back(
696 new IntRangePolicyHandler(key::kIdleWarningDelayAC
,
697 prefs::kPowerAcIdleWarningDelayMs
,
701 power_management_idle_legacy_policies
.push_back(new IntRangePolicyHandler(
702 key::kIdleDelayAC
, prefs::kPowerAcIdleDelayMs
, 0, INT_MAX
, true));
703 power_management_idle_legacy_policies
.push_back(
704 new IntRangePolicyHandler(key::kScreenDimDelayBattery
,
705 prefs::kPowerBatteryScreenDimDelayMs
,
709 power_management_idle_legacy_policies
.push_back(
710 new IntRangePolicyHandler(key::kScreenOffDelayBattery
,
711 prefs::kPowerBatteryScreenOffDelayMs
,
715 power_management_idle_legacy_policies
.push_back(
716 new IntRangePolicyHandler(key::kIdleWarningDelayBattery
,
717 prefs::kPowerBatteryIdleWarningDelayMs
,
721 power_management_idle_legacy_policies
.push_back(
722 new IntRangePolicyHandler(key::kIdleDelayBattery
,
723 prefs::kPowerBatteryIdleDelayMs
,
727 power_management_idle_legacy_policies
.push_back(new IntRangePolicyHandler(
729 prefs::kPowerAcIdleAction
,
730 chromeos::PowerPolicyController::ACTION_SUSPEND
,
731 chromeos::PowerPolicyController::ACTION_DO_NOTHING
,
733 power_management_idle_legacy_policies
.push_back(new IntRangePolicyHandler(
734 key::kIdleActionBattery
,
735 prefs::kPowerBatteryIdleAction
,
736 chromeos::PowerPolicyController::ACTION_SUSPEND
,
737 chromeos::PowerPolicyController::ACTION_DO_NOTHING
,
739 power_management_idle_legacy_policies
.push_back(
740 new DeprecatedIdleActionHandler());
742 ScopedVector
<ConfigurationPolicyHandler
> screen_lock_legacy_policies
;
743 screen_lock_legacy_policies
.push_back(
744 new IntRangePolicyHandler(key::kScreenLockDelayAC
,
745 prefs::kPowerAcScreenLockDelayMs
,
749 screen_lock_legacy_policies
.push_back(
750 new IntRangePolicyHandler(key::kScreenLockDelayBattery
,
751 prefs::kPowerBatteryScreenLockDelayMs
,
756 handlers
->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
757 key::kSAMLOfflineSigninTimeLimit
, prefs::kSAMLOfflineSigninTimeLimit
, -1,
759 handlers
->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
760 key::kLidCloseAction
, prefs::kPowerLidClosedAction
,
761 chromeos::PowerPolicyController::ACTION_SUSPEND
,
762 chromeos::PowerPolicyController::ACTION_DO_NOTHING
, false)));
763 handlers
->AddHandler(make_scoped_ptr(new IntPercentageToDoublePolicyHandler(
764 key::kPresentationScreenDimDelayScale
,
765 prefs::kPowerPresentationScreenDimDelayFactor
, 100, INT_MAX
, true)));
766 handlers
->AddHandler(make_scoped_ptr(new IntPercentageToDoublePolicyHandler(
767 key::kUserActivityScreenDimDelayScale
,
768 prefs::kPowerUserActivityScreenDimDelayFactor
, 100, INT_MAX
, true)));
769 handlers
->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
770 key::kUptimeLimit
, prefs::kUptimeLimit
, 3600, INT_MAX
, true)));
771 handlers
->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
772 key::kDeviceLoginScreenDefaultScreenMagnifierType
, NULL
, 0,
773 ui::MAGNIFIER_FULL
, false)));
774 // TODO(binjin): Remove LegacyPoliciesDeprecatingPolicyHandler for these two
775 // policies once deprecation of legacy power management policies is done.
776 // http://crbug.com/346229
777 handlers
->AddHandler(
778 make_scoped_ptr(new LegacyPoliciesDeprecatingPolicyHandler(
779 power_management_idle_legacy_policies
.Pass(),
781 new PowerManagementIdleSettingsPolicyHandler(chrome_schema
)))));
782 handlers
->AddHandler(
783 make_scoped_ptr(new LegacyPoliciesDeprecatingPolicyHandler(
784 screen_lock_legacy_policies
.Pass(),
785 make_scoped_ptr(new ScreenLockDelayPolicyHandler(chrome_schema
)))));
786 handlers
->AddHandler(
787 make_scoped_ptr(new ExternalDataPolicyHandler(key::kUserAvatarImage
)));
788 handlers
->AddHandler(
789 make_scoped_ptr(new ExternalDataPolicyHandler(key::kWallpaperImage
)));
790 handlers
->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler(
791 key::kSessionLocales
, NULL
, chrome_schema
, SCHEMA_STRICT
,
792 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED
,
793 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED
)));
794 handlers
->AddHandler(make_scoped_ptr(
795 new chromeos::KeyPermissionsPolicyHandler(chrome_schema
)));
796 #endif // defined(OS_CHROMEOS)
798 return handlers
.Pass();
801 } // namespace policy