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/password_manager/core/common/password_manager_pref_names.h"
18 #include "components/policy/core/browser/autofill_policy_handler.h"
19 #include "components/policy/core/browser/configuration_policy_handler.h"
20 #include "components/policy/core/browser/configuration_policy_handler_list.h"
21 #include "components/policy/core/browser/configuration_policy_handler_parameters.h"
22 #include "components/policy/core/browser/url_blacklist_policy_handler.h"
23 #include "components/policy/core/common/policy_details.h"
24 #include "components/policy/core/common/policy_map.h"
25 #include "components/policy/core/common/policy_pref_names.h"
26 #include "components/policy/core/common/schema.h"
27 #include "components/search_engines/default_search_policy_handler.h"
28 #include "components/translate/core/common/translate_pref_names.h"
29 #include "policy/policy_constants.h"
31 #if defined(OS_ANDROID)
32 #include "chrome/browser/search/contextual_search_policy_handler_android.h"
36 #include "chrome/browser/net/disk_cache_dir_policy_handler.h"
37 #include "chrome/browser/policy/file_selection_dialogs_policy_handler.h"
38 #include "chrome/browser/policy/javascript_policy_handler.h"
39 #include "chrome/browser/policy/network_prediction_policy_handler.h"
40 #include "chrome/browser/sessions/restore_on_startup_policy_handler.h"
41 #include "chrome/browser/sync/sync_policy_handler.h"
44 #if defined(OS_CHROMEOS)
45 #include "chrome/browser/chromeos/policy/configuration_policy_handler_chromeos.h"
46 #include "chromeos/chromeos_pref_names.h"
47 #include "chromeos/dbus/power_policy_controller.h"
48 #include "components/user_manager/user.h"
49 #include "components/user_manager/user_manager.h"
50 #include "ui/chromeos/accessibility_types.h"
53 #if !defined(OS_ANDROID) && !defined(OS_IOS)
54 #include "chrome/browser/download/download_dir_policy_handler.h"
57 #if defined(ENABLE_EXTENSIONS)
58 #include "chrome/browser/extensions/api/messaging/native_messaging_policy_handler.h"
59 #include "chrome/browser/extensions/extension_management_constants.h"
60 #include "chrome/browser/extensions/policy_handlers.h"
61 #include "extensions/browser/pref_names.h"
62 #include "extensions/common/manifest.h"
65 #if defined(ENABLE_PLUGINS)
66 #include "chrome/browser/plugins/enable_npapi_plugins_policy_handler.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
},
332 #if defined(ENABLE_SPELLCHECK)
333 { key::kSpellCheckServiceEnabled
,
334 prefs::kSpellCheckUseSpellingService
,
335 base::Value::TYPE_BOOLEAN
},
336 #endif // defined(ENABLE_SPELLCHECK)
338 { key::kDisableScreenshots
,
339 prefs::kDisableScreenshots
,
340 base::Value::TYPE_BOOLEAN
},
341 { key::kAudioCaptureAllowed
,
342 prefs::kAudioCaptureAllowed
,
343 base::Value::TYPE_BOOLEAN
},
344 { key::kVideoCaptureAllowed
,
345 prefs::kVideoCaptureAllowed
,
346 base::Value::TYPE_BOOLEAN
},
347 { key::kAudioCaptureAllowedUrls
,
348 prefs::kAudioCaptureAllowedUrls
,
349 base::Value::TYPE_LIST
},
350 { key::kVideoCaptureAllowedUrls
,
351 prefs::kVideoCaptureAllowedUrls
,
352 base::Value::TYPE_LIST
},
353 { key::kHideWebStoreIcon
,
354 prefs::kHideWebStoreIcon
,
355 base::Value::TYPE_BOOLEAN
},
356 { key::kVariationsRestrictParameter
,
357 prefs::kVariationsRestrictParameter
,
358 base::Value::TYPE_STRING
},
359 { key::kSupervisedUserCreationEnabled
,
360 prefs::kSupervisedUserCreationAllowed
,
361 base::Value::TYPE_BOOLEAN
},
362 { key::kForceEphemeralProfiles
,
363 prefs::kForceEphemeralProfiles
,
364 base::Value::TYPE_BOOLEAN
},
365 { key::kSSLVersionMin
,
366 prefs::kSSLVersionMin
,
367 base::Value::TYPE_STRING
},
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 prefs::kDisableDrive
,
392 base::Value::TYPE_BOOLEAN
},
393 { key::kDriveDisabledOverCellular
,
394 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 #endif // defined(OS_ANDROID)
494 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
495 { key::kNativeMessagingUserLevelHosts
,
496 extensions::pref_names::kNativeMessagingUserLevelHosts
,
497 base::Value::TYPE_BOOLEAN
},
498 { key::kBrowserGuestModeEnabled
,
499 prefs::kBrowserGuestModeEnabled
,
500 base::Value::TYPE_BOOLEAN
},
501 { key::kBrowserAddPersonEnabled
,
502 prefs::kBrowserAddPersonEnabled
,
503 base::Value::TYPE_BOOLEAN
},
504 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
507 class ForceSafeSearchPolicyHandler
: public TypeCheckingPolicyHandler
{
509 ForceSafeSearchPolicyHandler()
510 : TypeCheckingPolicyHandler(key::kForceSafeSearch
,
511 base::Value::TYPE_BOOLEAN
) {}
512 ~ForceSafeSearchPolicyHandler() override
{}
514 // ConfigurationPolicyHandler implementation:
515 void ApplyPolicySettings(const PolicyMap
& policies
,
516 PrefValueMap
* prefs
) override
{
517 // If either of the new GoogleSafeSearch or YouTubeSafetyMode policies is
518 // defined, then this one should be ignored. crbug.com/476908
519 // Note: Those policies are declared in kSimplePolicyMap above.
520 if (policies
.GetValue(key::kForceGoogleSafeSearch
) ||
521 policies
.GetValue(key::kForceYouTubeSafetyMode
)) {
524 const base::Value
* value
= policies
.GetValue(policy_name());
526 prefs
->SetValue(prefs::kForceGoogleSafeSearch
, value
->DeepCopy());
527 prefs
->SetValue(prefs::kForceYouTubeSafetyMode
, value
->DeepCopy());
532 DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler
);
535 #if defined(ENABLE_EXTENSIONS)
536 void GetExtensionAllowedTypesMap(
537 ScopedVector
<StringMappingListPolicyHandler::MappingEntry
>* result
) {
538 // Mapping from extension type names to Manifest::Type.
539 for (size_t index
= 0;
540 index
< extensions::schema_constants::kAllowedTypesMapSize
;
542 const extensions::schema_constants::AllowedTypesMapEntry
& entry
=
543 extensions::schema_constants::kAllowedTypesMap
[index
];
544 result
->push_back(new StringMappingListPolicyHandler::MappingEntry(
546 scoped_ptr
<base::Value
>(
547 new base::FundamentalValue(entry
.manifest_type
))));
553 void GetDeprecatedFeaturesMap(
554 ScopedVector
<StringMappingListPolicyHandler::MappingEntry
>* result
) {
555 // Maps feature tags as specified in policy to the corresponding switch to
558 #endif // !defined(OS_IOS)
562 void PopulatePolicyHandlerParameters(PolicyHandlerParameters
* parameters
) {
563 #if defined(OS_CHROMEOS)
564 if (user_manager::UserManager::IsInitialized()) {
565 const user_manager::User
* user
=
566 user_manager::UserManager::Get()->GetActiveUser();
568 parameters
->user_id_hash
= user
->username_hash();
573 scoped_ptr
<ConfigurationPolicyHandlerList
> BuildHandlerList(
574 const Schema
& chrome_schema
) {
575 scoped_ptr
<ConfigurationPolicyHandlerList
> handlers(
576 new ConfigurationPolicyHandlerList(
577 base::Bind(&PopulatePolicyHandlerParameters
),
578 base::Bind(&GetChromePolicyDetails
)));
579 for (size_t i
= 0; i
< arraysize(kSimplePolicyMap
); ++i
) {
580 handlers
->AddHandler(make_scoped_ptr(new SimplePolicyHandler(
581 kSimplePolicyMap
[i
].policy_name
, kSimplePolicyMap
[i
].preference_path
,
582 kSimplePolicyMap
[i
].value_type
)));
585 handlers
->AddHandler(make_scoped_ptr(new AutofillPolicyHandler()));
586 handlers
->AddHandler(make_scoped_ptr(new DefaultSearchPolicyHandler()));
587 handlers
->AddHandler(make_scoped_ptr(new ForceSafeSearchPolicyHandler()));
588 handlers
->AddHandler(make_scoped_ptr(new IncognitoModePolicyHandler()));
589 handlers
->AddHandler(
590 make_scoped_ptr(new ManagedBookmarksPolicyHandler(chrome_schema
)));
591 handlers
->AddHandler(make_scoped_ptr(new ProxyPolicyHandler()));
592 handlers
->AddHandler(make_scoped_ptr(new URLBlacklistPolicyHandler()));
594 #if defined(OS_ANDROID)
595 handlers
->AddHandler(
596 make_scoped_ptr(new ContextualSearchPolicyHandlerAndroid()));
600 handlers
->AddHandler(
601 make_scoped_ptr(new FileSelectionDialogsPolicyHandler()));
602 handlers
->AddHandler(make_scoped_ptr(new JavascriptPolicyHandler()));
603 handlers
->AddHandler(make_scoped_ptr(new NetworkPredictionPolicyHandler()));
604 handlers
->AddHandler(make_scoped_ptr(new RestoreOnStartupPolicyHandler()));
605 handlers
->AddHandler(make_scoped_ptr(new browser_sync::SyncPolicyHandler()));
607 handlers
->AddHandler(make_scoped_ptr(new StringMappingListPolicyHandler(
608 key::kEnableDeprecatedWebPlatformFeatures
,
609 prefs::kEnableDeprecatedWebPlatformFeatures
,
610 base::Bind(GetDeprecatedFeaturesMap
))));
611 #endif // !defined(OS_IOS)
613 #if defined(ENABLE_EXTENSIONS)
614 handlers
->AddHandler(
615 make_scoped_ptr(new extensions::ExtensionListPolicyHandler(
616 key::kExtensionInstallWhitelist
,
617 extensions::pref_names::kInstallAllowList
, false)));
618 handlers
->AddHandler(
619 make_scoped_ptr(new extensions::ExtensionListPolicyHandler(
620 key::kExtensionInstallBlacklist
,
621 extensions::pref_names::kInstallDenyList
, true)));
622 handlers
->AddHandler(make_scoped_ptr(
623 new extensions::ExtensionInstallForcelistPolicyHandler()));
624 handlers
->AddHandler(
625 make_scoped_ptr(new extensions::ExtensionURLPatternListPolicyHandler(
626 key::kExtensionInstallSources
,
627 extensions::pref_names::kAllowedInstallSites
)));
628 handlers
->AddHandler(make_scoped_ptr(new StringMappingListPolicyHandler(
629 key::kExtensionAllowedTypes
, extensions::pref_names::kAllowedTypes
,
630 base::Bind(GetExtensionAllowedTypesMap
))));
631 handlers
->AddHandler(make_scoped_ptr(
632 new extensions::ExtensionSettingsPolicyHandler(chrome_schema
)));
635 #if defined(ENABLE_PLUGINS)
636 handlers
->AddHandler(make_scoped_ptr(new EnableNpapiPluginsPolicyHandler()));
639 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
640 handlers
->AddHandler(make_scoped_ptr(new DiskCacheDirPolicyHandler()));
642 handlers
->AddHandler(
643 make_scoped_ptr(new extensions::NativeMessagingHostListPolicyHandler(
644 key::kNativeMessagingWhitelist
,
645 extensions::pref_names::kNativeMessagingWhitelist
, false)));
646 handlers
->AddHandler(
647 make_scoped_ptr(new extensions::NativeMessagingHostListPolicyHandler(
648 key::kNativeMessagingBlacklist
,
649 extensions::pref_names::kNativeMessagingBlacklist
, true)));
650 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
652 #if !defined(OS_ANDROID) && !defined(OS_IOS)
653 handlers
->AddHandler(make_scoped_ptr(new DownloadDirPolicyHandler
));
655 handlers
->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler(
656 key::kRegisteredProtocolHandlers
,
657 prefs::kPolicyRegisteredProtocolHandlers
, chrome_schema
, SCHEMA_STRICT
,
658 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED
,
659 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED
)));
662 #if defined(OS_CHROMEOS)
663 handlers
->AddHandler(
664 make_scoped_ptr(new extensions::ExtensionListPolicyHandler(
665 key::kAttestationExtensionWhitelist
,
666 prefs::kAttestationExtensionWhitelist
, false)));
667 handlers
->AddHandler(make_scoped_ptr(
668 NetworkConfigurationPolicyHandler::CreateForDevicePolicy()));
669 handlers
->AddHandler(make_scoped_ptr(
670 NetworkConfigurationPolicyHandler::CreateForUserPolicy()));
671 handlers
->AddHandler(make_scoped_ptr(new PinnedLauncherAppsPolicyHandler()));
672 handlers
->AddHandler(make_scoped_ptr(new ScreenMagnifierPolicyHandler()));
673 handlers
->AddHandler(make_scoped_ptr(
674 new LoginScreenPowerManagementPolicyHandler(chrome_schema
)));
676 ScopedVector
<ConfigurationPolicyHandler
>
677 power_management_idle_legacy_policies
;
678 power_management_idle_legacy_policies
.push_back(
679 new IntRangePolicyHandler(key::kScreenDimDelayAC
,
680 prefs::kPowerAcScreenDimDelayMs
,
684 power_management_idle_legacy_policies
.push_back(
685 new IntRangePolicyHandler(key::kScreenOffDelayAC
,
686 prefs::kPowerAcScreenOffDelayMs
,
690 power_management_idle_legacy_policies
.push_back(
691 new IntRangePolicyHandler(key::kIdleWarningDelayAC
,
692 prefs::kPowerAcIdleWarningDelayMs
,
696 power_management_idle_legacy_policies
.push_back(new IntRangePolicyHandler(
697 key::kIdleDelayAC
, prefs::kPowerAcIdleDelayMs
, 0, INT_MAX
, true));
698 power_management_idle_legacy_policies
.push_back(
699 new IntRangePolicyHandler(key::kScreenDimDelayBattery
,
700 prefs::kPowerBatteryScreenDimDelayMs
,
704 power_management_idle_legacy_policies
.push_back(
705 new IntRangePolicyHandler(key::kScreenOffDelayBattery
,
706 prefs::kPowerBatteryScreenOffDelayMs
,
710 power_management_idle_legacy_policies
.push_back(
711 new IntRangePolicyHandler(key::kIdleWarningDelayBattery
,
712 prefs::kPowerBatteryIdleWarningDelayMs
,
716 power_management_idle_legacy_policies
.push_back(
717 new IntRangePolicyHandler(key::kIdleDelayBattery
,
718 prefs::kPowerBatteryIdleDelayMs
,
722 power_management_idle_legacy_policies
.push_back(new IntRangePolicyHandler(
724 prefs::kPowerAcIdleAction
,
725 chromeos::PowerPolicyController::ACTION_SUSPEND
,
726 chromeos::PowerPolicyController::ACTION_DO_NOTHING
,
728 power_management_idle_legacy_policies
.push_back(new IntRangePolicyHandler(
729 key::kIdleActionBattery
,
730 prefs::kPowerBatteryIdleAction
,
731 chromeos::PowerPolicyController::ACTION_SUSPEND
,
732 chromeos::PowerPolicyController::ACTION_DO_NOTHING
,
734 power_management_idle_legacy_policies
.push_back(
735 new DeprecatedIdleActionHandler());
737 ScopedVector
<ConfigurationPolicyHandler
> screen_lock_legacy_policies
;
738 screen_lock_legacy_policies
.push_back(
739 new IntRangePolicyHandler(key::kScreenLockDelayAC
,
740 prefs::kPowerAcScreenLockDelayMs
,
744 screen_lock_legacy_policies
.push_back(
745 new IntRangePolicyHandler(key::kScreenLockDelayBattery
,
746 prefs::kPowerBatteryScreenLockDelayMs
,
751 handlers
->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
752 key::kSAMLOfflineSigninTimeLimit
, prefs::kSAMLOfflineSigninTimeLimit
, -1,
754 handlers
->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
755 key::kLidCloseAction
, prefs::kPowerLidClosedAction
,
756 chromeos::PowerPolicyController::ACTION_SUSPEND
,
757 chromeos::PowerPolicyController::ACTION_DO_NOTHING
, false)));
758 handlers
->AddHandler(make_scoped_ptr(new IntPercentageToDoublePolicyHandler(
759 key::kPresentationScreenDimDelayScale
,
760 prefs::kPowerPresentationScreenDimDelayFactor
, 100, INT_MAX
, true)));
761 handlers
->AddHandler(make_scoped_ptr(new IntPercentageToDoublePolicyHandler(
762 key::kUserActivityScreenDimDelayScale
,
763 prefs::kPowerUserActivityScreenDimDelayFactor
, 100, INT_MAX
, true)));
764 handlers
->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
765 key::kUptimeLimit
, prefs::kUptimeLimit
, 3600, INT_MAX
, true)));
766 handlers
->AddHandler(make_scoped_ptr(new IntRangePolicyHandler(
767 key::kDeviceLoginScreenDefaultScreenMagnifierType
, NULL
, 0,
768 ui::MAGNIFIER_FULL
, false)));
769 // TODO(binjin): Remove LegacyPoliciesDeprecatingPolicyHandler for these two
770 // policies once deprecation of legacy power management policies is done.
771 // http://crbug.com/346229
772 handlers
->AddHandler(
773 make_scoped_ptr(new LegacyPoliciesDeprecatingPolicyHandler(
774 power_management_idle_legacy_policies
.Pass(),
776 new PowerManagementIdleSettingsPolicyHandler(chrome_schema
)))));
777 handlers
->AddHandler(
778 make_scoped_ptr(new LegacyPoliciesDeprecatingPolicyHandler(
779 screen_lock_legacy_policies
.Pass(),
780 make_scoped_ptr(new ScreenLockDelayPolicyHandler(chrome_schema
)))));
781 handlers
->AddHandler(
782 make_scoped_ptr(new ExternalDataPolicyHandler(key::kUserAvatarImage
)));
783 handlers
->AddHandler(
784 make_scoped_ptr(new ExternalDataPolicyHandler(key::kWallpaperImage
)));
785 handlers
->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler(
786 key::kSessionLocales
, NULL
, chrome_schema
, SCHEMA_STRICT
,
787 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED
,
788 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED
)));
789 #endif // defined(OS_CHROMEOS)
791 return handlers
.Pass();
794 } // namespace policy