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/values.h"
11 #include "chrome/browser/net/proxy_policy_handler.h"
12 #include "chrome/browser/profiles/incognito_mode_policy_handler.h"
13 #include "chrome/browser/search_engines/default_search_policy_handler.h"
14 #include "chrome/common/pref_names.h"
15 #include "components/password_manager/core/common/password_manager_pref_names.h"
16 #include "components/policy/core/browser/autofill_policy_handler.h"
17 #include "components/policy/core/browser/configuration_policy_handler.h"
18 #include "components/policy/core/browser/configuration_policy_handler_list.h"
19 #include "components/policy/core/browser/configuration_policy_handler_parameters.h"
20 #include "components/policy/core/browser/url_blacklist_policy_handler.h"
21 #include "components/policy/core/common/policy_details.h"
22 #include "components/policy/core/common/policy_map.h"
23 #include "components/policy/core/common/policy_pref_names.h"
24 #include "components/policy/core/common/schema.h"
25 #include "components/translate/core/common/translate_pref_names.h"
26 #include "grit/component_strings.h"
27 #include "policy/policy_constants.h"
30 #include "chrome/browser/extensions/api/messaging/native_messaging_policy_handler.h"
31 #include "chrome/browser/extensions/policy_handlers.h"
32 #include "chrome/browser/net/disk_cache_dir_policy_handler.h"
33 #include "chrome/browser/policy/file_selection_dialogs_policy_handler.h"
34 #include "chrome/browser/policy/javascript_policy_handler.h"
35 #include "chrome/browser/sessions/restore_on_startup_policy_handler.h"
36 #include "chrome/browser/sync/sync_policy_handler.h"
37 #include "extensions/browser/pref_names.h"
38 #include "extensions/common/manifest.h"
41 #if defined(OS_CHROMEOS)
42 #include "ash/magnifier/magnifier_constants.h"
43 #include "chrome/browser/chromeos/login/user.h"
44 #include "chrome/browser/chromeos/login/user_manager.h"
45 #include "chrome/browser/chromeos/policy/configuration_policy_handler_chromeos.h"
46 #include "chromeos/dbus/power_policy_controller.h"
49 #if defined(OS_ANDROID) || defined(OS_IOS)
50 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h"
53 #if !defined(OS_ANDROID) && !defined(OS_IOS)
54 #include "chrome/browser/download/download_dir_policy_handler.h"
57 #if !defined(OS_MACOSX) && !defined(OS_IOS)
58 #include "apps/pref_names.h"
65 // List of policy types to preference names. This is used for simple policies
66 // that directly map to a single preference.
67 const PolicyToPreferenceMapEntry kSimplePolicyMap
[] = {
68 { key::kHomepageLocation
,
70 base::Value::TYPE_STRING
},
71 { key::kHomepageIsNewTabPage
,
72 prefs::kHomePageIsNewTabPage
,
73 base::Value::TYPE_BOOLEAN
},
74 { key::kRestoreOnStartupURLs
,
75 prefs::kURLsToRestoreOnStartup
,
76 base::Value::TYPE_LIST
},
77 { key::kAlternateErrorPagesEnabled
,
78 prefs::kAlternateErrorPagesEnabled
,
79 base::Value::TYPE_BOOLEAN
},
80 { key::kSearchSuggestEnabled
,
81 prefs::kSearchSuggestEnabled
,
82 base::Value::TYPE_BOOLEAN
},
83 { key::kDnsPrefetchingEnabled
,
84 prefs::kNetworkPredictionEnabled
,
85 base::Value::TYPE_BOOLEAN
},
86 { key::kBuiltInDnsClientEnabled
,
87 prefs::kBuiltInDnsClientEnabled
,
88 base::Value::TYPE_BOOLEAN
},
89 { key::kWPADQuickCheckEnabled
,
90 prefs::kQuickCheckEnabled
,
91 base::Value::TYPE_BOOLEAN
},
94 base::Value::TYPE_BOOLEAN
},
95 { key::kSafeBrowsingEnabled
,
96 prefs::kSafeBrowsingEnabled
,
97 base::Value::TYPE_BOOLEAN
},
98 { key::kForceSafeSearch
,
99 prefs::kForceSafeSearch
,
100 base::Value::TYPE_BOOLEAN
},
101 { key::kPasswordManagerEnabled
,
102 password_manager::prefs::kPasswordManagerEnabled
,
103 base::Value::TYPE_BOOLEAN
},
104 { key::kPasswordManagerAllowShowPasswords
,
105 password_manager::prefs::kPasswordManagerAllowShowPasswords
,
106 base::Value::TYPE_BOOLEAN
},
107 { key::kPrintingEnabled
,
108 prefs::kPrintingEnabled
,
109 base::Value::TYPE_BOOLEAN
},
110 { key::kDisablePrintPreview
,
111 prefs::kPrintPreviewDisabled
,
112 base::Value::TYPE_BOOLEAN
},
113 { key::kMetricsReportingEnabled
,
114 prefs::kMetricsReportingEnabled
,
115 base::Value::TYPE_BOOLEAN
},
116 { key::kApplicationLocaleValue
,
117 prefs::kApplicationLocale
,
118 base::Value::TYPE_STRING
},
119 { key::kDisabledPlugins
,
120 prefs::kPluginsDisabledPlugins
,
121 base::Value::TYPE_LIST
},
122 { key::kDisabledPluginsExceptions
,
123 prefs::kPluginsDisabledPluginsExceptions
,
124 base::Value::TYPE_LIST
},
125 { key::kEnabledPlugins
,
126 prefs::kPluginsEnabledPlugins
,
127 base::Value::TYPE_LIST
},
128 { key::kShowHomeButton
,
129 prefs::kShowHomeButton
,
130 base::Value::TYPE_BOOLEAN
},
131 { key::kSavingBrowserHistoryDisabled
,
132 prefs::kSavingBrowserHistoryDisabled
,
133 base::Value::TYPE_BOOLEAN
},
134 { key::kAllowDeletingBrowserHistory
,
135 prefs::kAllowDeletingBrowserHistory
,
136 base::Value::TYPE_BOOLEAN
},
137 { key::kDeveloperToolsDisabled
,
138 prefs::kDevToolsDisabled
,
139 base::Value::TYPE_BOOLEAN
},
140 { key::kBlockThirdPartyCookies
,
141 prefs::kBlockThirdPartyCookies
,
142 base::Value::TYPE_BOOLEAN
},
143 { key::kDefaultCookiesSetting
,
144 prefs::kManagedDefaultCookiesSetting
,
145 base::Value::TYPE_INTEGER
},
146 { key::kDefaultImagesSetting
,
147 prefs::kManagedDefaultImagesSetting
,
148 base::Value::TYPE_INTEGER
},
149 { key::kDefaultPluginsSetting
,
150 prefs::kManagedDefaultPluginsSetting
,
151 base::Value::TYPE_INTEGER
},
152 { key::kDefaultPopupsSetting
,
153 prefs::kManagedDefaultPopupsSetting
,
154 base::Value::TYPE_INTEGER
},
155 { key::kAutoSelectCertificateForUrls
,
156 prefs::kManagedAutoSelectCertificateForUrls
,
157 base::Value::TYPE_LIST
},
158 { key::kCookiesAllowedForUrls
,
159 prefs::kManagedCookiesAllowedForUrls
,
160 base::Value::TYPE_LIST
},
161 { key::kCookiesBlockedForUrls
,
162 prefs::kManagedCookiesBlockedForUrls
,
163 base::Value::TYPE_LIST
},
164 { key::kCookiesSessionOnlyForUrls
,
165 prefs::kManagedCookiesSessionOnlyForUrls
,
166 base::Value::TYPE_LIST
},
167 { key::kImagesAllowedForUrls
,
168 prefs::kManagedImagesAllowedForUrls
,
169 base::Value::TYPE_LIST
},
170 { key::kImagesBlockedForUrls
,
171 prefs::kManagedImagesBlockedForUrls
,
172 base::Value::TYPE_LIST
},
173 { key::kJavaScriptAllowedForUrls
,
174 prefs::kManagedJavaScriptAllowedForUrls
,
175 base::Value::TYPE_LIST
},
176 { key::kJavaScriptBlockedForUrls
,
177 prefs::kManagedJavaScriptBlockedForUrls
,
178 base::Value::TYPE_LIST
},
179 { key::kPluginsAllowedForUrls
,
180 prefs::kManagedPluginsAllowedForUrls
,
181 base::Value::TYPE_LIST
},
182 { key::kPluginsBlockedForUrls
,
183 prefs::kManagedPluginsBlockedForUrls
,
184 base::Value::TYPE_LIST
},
185 { key::kPopupsAllowedForUrls
,
186 prefs::kManagedPopupsAllowedForUrls
,
187 base::Value::TYPE_LIST
},
188 { key::kPopupsBlockedForUrls
,
189 prefs::kManagedPopupsBlockedForUrls
,
190 base::Value::TYPE_LIST
},
191 { key::kNotificationsAllowedForUrls
,
192 prefs::kManagedNotificationsAllowedForUrls
,
193 base::Value::TYPE_LIST
},
194 { key::kNotificationsBlockedForUrls
,
195 prefs::kManagedNotificationsBlockedForUrls
,
196 base::Value::TYPE_LIST
},
197 { key::kDefaultNotificationsSetting
,
198 prefs::kManagedDefaultNotificationsSetting
,
199 base::Value::TYPE_INTEGER
},
200 { key::kDefaultGeolocationSetting
,
201 prefs::kManagedDefaultGeolocationSetting
,
202 base::Value::TYPE_INTEGER
},
203 { key::kSigninAllowed
,
204 prefs::kSigninAllowed
,
205 base::Value::TYPE_BOOLEAN
},
206 { key::kDisableSSLRecordSplitting
,
207 prefs::kDisableSSLRecordSplitting
,
208 base::Value::TYPE_BOOLEAN
},
209 { key::kEnableOnlineRevocationChecks
,
210 prefs::kCertRevocationCheckingEnabled
,
211 base::Value::TYPE_BOOLEAN
},
212 { key::kRequireOnlineRevocationChecksForLocalAnchors
,
213 prefs::kCertRevocationCheckingRequiredLocalAnchors
,
214 base::Value::TYPE_BOOLEAN
},
217 base::Value::TYPE_STRING
},
218 { key::kDisableAuthNegotiateCnameLookup
,
219 prefs::kDisableAuthNegotiateCnameLookup
,
220 base::Value::TYPE_BOOLEAN
},
221 { key::kEnableAuthNegotiatePort
,
222 prefs::kEnableAuthNegotiatePort
,
223 base::Value::TYPE_BOOLEAN
},
224 { key::kAuthServerWhitelist
,
225 prefs::kAuthServerWhitelist
,
226 base::Value::TYPE_STRING
},
227 { key::kAuthNegotiateDelegateWhitelist
,
228 prefs::kAuthNegotiateDelegateWhitelist
,
229 base::Value::TYPE_STRING
},
230 { key::kGSSAPILibraryName
,
231 prefs::kGSSAPILibraryName
,
232 base::Value::TYPE_STRING
},
233 { key::kAllowCrossOriginAuthPrompt
,
234 prefs::kAllowCrossOriginAuthPrompt
,
235 base::Value::TYPE_BOOLEAN
},
236 { key::kDisable3DAPIs
,
237 prefs::kDisable3DAPIs
,
238 base::Value::TYPE_BOOLEAN
},
239 { key::kDisablePluginFinder
,
240 prefs::kDisablePluginFinder
,
241 base::Value::TYPE_BOOLEAN
},
242 { key::kDiskCacheSize
,
243 prefs::kDiskCacheSize
,
244 base::Value::TYPE_INTEGER
},
245 { key::kMediaCacheSize
,
246 prefs::kMediaCacheSize
,
247 base::Value::TYPE_INTEGER
},
248 { key::kPolicyRefreshRate
,
249 policy_prefs::kUserPolicyRefreshRate
,
250 base::Value::TYPE_INTEGER
},
251 { key::kDevicePolicyRefreshRate
,
252 prefs::kDevicePolicyRefreshRate
,
253 base::Value::TYPE_INTEGER
},
254 { key::kDefaultBrowserSettingEnabled
,
255 prefs::kDefaultBrowserSettingEnabled
,
256 base::Value::TYPE_BOOLEAN
},
257 { key::kRemoteAccessHostFirewallTraversal
,
258 prefs::kRemoteAccessHostFirewallTraversal
,
259 base::Value::TYPE_BOOLEAN
},
260 { key::kRemoteAccessHostRequireTwoFactor
,
261 prefs::kRemoteAccessHostRequireTwoFactor
,
262 base::Value::TYPE_BOOLEAN
},
263 { key::kRemoteAccessHostDomain
,
264 prefs::kRemoteAccessHostDomain
,
265 base::Value::TYPE_STRING
},
266 { key::kRemoteAccessHostTalkGadgetPrefix
,
267 prefs::kRemoteAccessHostTalkGadgetPrefix
,
268 base::Value::TYPE_STRING
},
269 { key::kRemoteAccessHostRequireCurtain
,
270 prefs::kRemoteAccessHostRequireCurtain
,
271 base::Value::TYPE_BOOLEAN
},
272 { key::kRemoteAccessHostAllowClientPairing
,
273 prefs::kRemoteAccessHostAllowClientPairing
,
274 base::Value::TYPE_BOOLEAN
},
275 { key::kRemoteAccessHostAllowGnubbyAuth
,
276 prefs::kRemoteAccessHostAllowGnubbyAuth
,
277 base::Value::TYPE_BOOLEAN
},
278 { key::kRemoteAccessHostAllowRelayedConnection
,
279 prefs::kRemoteAccessHostAllowRelayedConnection
,
280 base::Value::TYPE_BOOLEAN
},
281 { key::kRemoteAccessHostUdpPortRange
,
282 prefs::kRemoteAccessHostUdpPortRange
,
283 base::Value::TYPE_STRING
},
284 { key::kCloudPrintProxyEnabled
,
285 prefs::kCloudPrintProxyEnabled
,
286 base::Value::TYPE_BOOLEAN
},
287 { key::kCloudPrintSubmitEnabled
,
288 prefs::kCloudPrintSubmitEnabled
,
289 base::Value::TYPE_BOOLEAN
},
290 { key::kTranslateEnabled
,
291 prefs::kEnableTranslate
,
292 base::Value::TYPE_BOOLEAN
},
293 { key::kAllowOutdatedPlugins
,
294 prefs::kPluginsAllowOutdated
,
295 base::Value::TYPE_BOOLEAN
},
296 { key::kAlwaysAuthorizePlugins
,
297 prefs::kPluginsAlwaysAuthorize
,
298 base::Value::TYPE_BOOLEAN
},
299 { key::kBookmarkBarEnabled
,
300 prefs::kShowBookmarkBar
,
301 base::Value::TYPE_BOOLEAN
},
302 { key::kEditBookmarksEnabled
,
303 prefs::kEditBookmarksEnabled
,
304 base::Value::TYPE_BOOLEAN
},
305 { key::kAllowFileSelectionDialogs
,
306 prefs::kAllowFileSelectionDialogs
,
307 base::Value::TYPE_BOOLEAN
},
308 { key::kImportBookmarks
,
309 prefs::kImportBookmarks
,
310 base::Value::TYPE_BOOLEAN
},
311 { key::kImportHistory
,
312 prefs::kImportHistory
,
313 base::Value::TYPE_BOOLEAN
},
314 { key::kImportHomepage
,
315 prefs::kImportHomepage
,
316 base::Value::TYPE_BOOLEAN
},
317 { key::kImportSearchEngine
,
318 prefs::kImportSearchEngine
,
319 base::Value::TYPE_BOOLEAN
},
320 { key::kImportSavedPasswords
,
321 prefs::kImportSavedPasswords
,
322 base::Value::TYPE_BOOLEAN
},
323 { key::kMaxConnectionsPerProxy
,
324 prefs::kMaxConnectionsPerProxy
,
325 base::Value::TYPE_INTEGER
},
326 { key::kURLWhitelist
,
327 policy_prefs::kUrlWhitelist
,
328 base::Value::TYPE_LIST
},
329 { key::kRestrictSigninToPattern
,
330 prefs::kGoogleServicesUsernamePattern
,
331 base::Value::TYPE_STRING
},
332 { key::kDefaultMediaStreamSetting
,
333 prefs::kManagedDefaultMediaStreamSetting
,
334 base::Value::TYPE_INTEGER
},
335 { key::kDisableSafeBrowsingProceedAnyway
,
336 prefs::kSafeBrowsingProceedAnywayDisabled
,
337 base::Value::TYPE_BOOLEAN
},
338 { key::kSpellCheckServiceEnabled
,
339 prefs::kSpellCheckUseSpellingService
,
340 base::Value::TYPE_BOOLEAN
},
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 prefs::kVariationsRestrictParameter
,
361 base::Value::TYPE_STRING
},
362 { key::kSupervisedUserCreationEnabled
,
363 prefs::kManagedUserCreationAllowed
,
364 base::Value::TYPE_BOOLEAN
},
365 { key::kForceEphemeralProfiles
,
366 prefs::kForceEphemeralProfiles
,
367 base::Value::TYPE_BOOLEAN
},
369 #if !defined(OS_MACOSX) && !defined(OS_IOS)
370 { key::kFullscreenAllowed
,
371 prefs::kFullscreenAllowed
,
372 base::Value::TYPE_BOOLEAN
},
373 { key::kFullscreenAllowed
,
374 apps::prefs::kAppFullscreenAllowed
,
375 base::Value::TYPE_BOOLEAN
},
376 #endif // !defined(OS_MACOSX) && !defined(OS_IOS)
378 #if defined(OS_CHROMEOS)
379 { key::kChromeOsLockOnIdleSuspend
,
380 prefs::kEnableAutoScreenLock
,
381 base::Value::TYPE_BOOLEAN
},
382 { key::kChromeOsReleaseChannel
,
383 prefs::kChromeOsReleaseChannel
,
384 base::Value::TYPE_STRING
},
385 { key::kDriveDisabled
,
386 prefs::kDisableDrive
,
387 base::Value::TYPE_BOOLEAN
},
388 { key::kDriveDisabledOverCellular
,
389 prefs::kDisableDriveOverCellular
,
390 base::Value::TYPE_BOOLEAN
},
391 { key::kExternalStorageDisabled
,
392 prefs::kExternalStorageDisabled
,
393 base::Value::TYPE_BOOLEAN
},
394 { key::kAudioOutputAllowed
,
395 prefs::kAudioOutputAllowed
,
396 base::Value::TYPE_BOOLEAN
},
397 { key::kShowLogoutButtonInTray
,
398 prefs::kShowLogoutButtonInTray
,
399 base::Value::TYPE_BOOLEAN
},
400 { key::kShelfAutoHideBehavior
,
401 prefs::kShelfAutoHideBehaviorLocal
,
402 base::Value::TYPE_STRING
},
403 { key::kSessionLengthLimit
,
404 prefs::kSessionLengthLimit
,
405 base::Value::TYPE_INTEGER
},
406 { key::kWaitForInitialUserActivity
,
407 prefs::kSessionWaitForInitialUserActivity
,
408 base::Value::TYPE_BOOLEAN
},
409 { key::kPowerManagementUsesAudioActivity
,
410 prefs::kPowerUseAudioActivity
,
411 base::Value::TYPE_BOOLEAN
},
412 { key::kPowerManagementUsesVideoActivity
,
413 prefs::kPowerUseVideoActivity
,
414 base::Value::TYPE_BOOLEAN
},
415 { key::kAllowScreenWakeLocks
,
416 prefs::kPowerAllowScreenWakeLocks
,
417 base::Value::TYPE_BOOLEAN
},
418 { key::kWaitForInitialUserActivity
,
419 prefs::kPowerWaitForInitialUserActivity
,
420 base::Value::TYPE_BOOLEAN
},
421 { key::kTermsOfServiceURL
,
422 prefs::kTermsOfServiceURL
,
423 base::Value::TYPE_STRING
},
424 { key::kShowAccessibilityOptionsInSystemTrayMenu
,
425 prefs::kShouldAlwaysShowAccessibilityMenu
,
426 base::Value::TYPE_BOOLEAN
},
427 { key::kLargeCursorEnabled
,
428 prefs::kLargeCursorEnabled
,
429 base::Value::TYPE_BOOLEAN
},
430 { key::kSpokenFeedbackEnabled
,
431 prefs::kSpokenFeedbackEnabled
,
432 base::Value::TYPE_BOOLEAN
},
433 { key::kHighContrastEnabled
,
434 prefs::kHighContrastEnabled
,
435 base::Value::TYPE_BOOLEAN
},
436 { key::kVirtualKeyboardEnabled
,
437 prefs::kVirtualKeyboardEnabled
,
438 base::Value::TYPE_BOOLEAN
},
439 { key::kDeviceLoginScreenDefaultLargeCursorEnabled
,
441 base::Value::TYPE_BOOLEAN
},
442 { key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled
,
444 base::Value::TYPE_BOOLEAN
},
445 { key::kDeviceLoginScreenDefaultHighContrastEnabled
,
447 base::Value::TYPE_BOOLEAN
},
448 { key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled
,
450 base::Value::TYPE_BOOLEAN
},
451 { key::kRebootAfterUpdate
,
452 prefs::kRebootAfterUpdate
,
453 base::Value::TYPE_BOOLEAN
},
454 { key::kAttestationEnabledForUser
,
455 prefs::kAttestationEnabled
,
456 base::Value::TYPE_BOOLEAN
},
457 { key::kChromeOsMultiProfileUserBehavior
,
458 prefs::kMultiProfileUserBehavior
,
459 base::Value::TYPE_STRING
},
460 { key::kKeyboardDefaultToFunctionKeys
,
461 prefs::kLanguageSendFunctionKeys
,
462 base::Value::TYPE_BOOLEAN
},
463 #endif // defined(OS_CHROMEOS)
465 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
466 { key::kBackgroundModeEnabled
,
467 prefs::kBackgroundModeEnabled
,
468 base::Value::TYPE_BOOLEAN
},
469 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
471 #if defined(OS_ANDROID)
472 { key::kDataCompressionProxyEnabled
,
473 data_reduction_proxy::prefs::kDataReductionProxyEnabled
,
474 base::Value::TYPE_BOOLEAN
},
475 #endif // defined(OS_ANDROID)
477 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
478 { key::kNativeMessagingUserLevelHosts
,
479 extensions::pref_names::kNativeMessagingUserLevelHosts
,
480 base::Value::TYPE_BOOLEAN
},
481 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
485 // Mapping from extension type names to Manifest::Type.
486 StringToIntEnumListPolicyHandler::MappingEntry kExtensionAllowedTypesMap
[] = {
487 { "extension", extensions::Manifest::TYPE_EXTENSION
},
488 { "theme", extensions::Manifest::TYPE_THEME
},
489 { "user_script", extensions::Manifest::TYPE_USER_SCRIPT
},
490 { "hosted_app", extensions::Manifest::TYPE_HOSTED_APP
},
491 { "legacy_packaged_app", extensions::Manifest::TYPE_LEGACY_PACKAGED_APP
},
492 { "platform_app", extensions::Manifest::TYPE_PLATFORM_APP
},
494 #endif // !defined(OS_IOS)
498 void PopulatePolicyHandlerParameters(PolicyHandlerParameters
* parameters
) {
499 #if defined(OS_CHROMEOS)
500 if (chromeos::UserManager::IsInitialized()) {
501 const chromeos::User
* user
= chromeos::UserManager::Get()->GetActiveUser();
503 parameters
->user_id_hash
= user
->username_hash();
508 scoped_ptr
<ConfigurationPolicyHandlerList
> BuildHandlerList(
509 const Schema
& chrome_schema
) {
510 scoped_ptr
<ConfigurationPolicyHandlerList
> handlers(
511 new ConfigurationPolicyHandlerList(
512 base::Bind(&PopulatePolicyHandlerParameters
),
513 base::Bind(&GetChromePolicyDetails
)));
514 for (size_t i
= 0; i
< arraysize(kSimplePolicyMap
); ++i
) {
515 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
516 new SimplePolicyHandler(kSimplePolicyMap
[i
].policy_name
,
517 kSimplePolicyMap
[i
].preference_path
,
518 kSimplePolicyMap
[i
].value_type
)));
521 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
522 new AutofillPolicyHandler()));
523 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
524 new DefaultSearchPolicyHandler()));
525 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
526 new IncognitoModePolicyHandler()));
527 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
528 new ProxyPolicyHandler()));
529 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
530 new URLBlacklistPolicyHandler()));
533 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
534 new FileSelectionDialogsPolicyHandler()));
535 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
536 new JavascriptPolicyHandler()));
537 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
538 new RestoreOnStartupPolicyHandler()));
539 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
540 new browser_sync::SyncPolicyHandler()));
542 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
543 new extensions::ExtensionListPolicyHandler(
544 key::kExtensionInstallWhitelist
,
545 extensions::pref_names::kInstallAllowList
,
547 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
548 new extensions::ExtensionListPolicyHandler(
549 key::kExtensionInstallBlacklist
,
550 extensions::pref_names::kInstallDenyList
,
552 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
553 new extensions::ExtensionInstallForcelistPolicyHandler()));
554 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
555 new extensions::ExtensionURLPatternListPolicyHandler(
556 key::kExtensionInstallSources
,
557 extensions::pref_names::kAllowedInstallSites
)));
558 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
559 new StringToIntEnumListPolicyHandler(
560 key::kExtensionAllowedTypes
,
561 extensions::pref_names::kAllowedTypes
,
562 kExtensionAllowedTypesMap
,
563 kExtensionAllowedTypesMap
+ arraysize(kExtensionAllowedTypesMap
))));
564 #endif // !defined(OS_IOS)
566 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
567 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
568 new DiskCacheDirPolicyHandler()));
570 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
571 new extensions::NativeMessagingHostListPolicyHandler(
572 key::kNativeMessagingWhitelist
,
573 extensions::pref_names::kNativeMessagingWhitelist
,
575 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
576 new extensions::NativeMessagingHostListPolicyHandler(
577 key::kNativeMessagingBlacklist
,
578 extensions::pref_names::kNativeMessagingBlacklist
,
580 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
582 #if !defined(OS_ANDROID) && !defined(OS_IOS)
583 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
584 new DownloadDirPolicyHandler
));
587 #if defined(OS_CHROMEOS)
588 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
589 new extensions::ExtensionListPolicyHandler(
590 key::kAttestationExtensionWhitelist
,
591 prefs::kAttestationExtensionWhitelist
,
593 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
594 NetworkConfigurationPolicyHandler::CreateForDevicePolicy()));
595 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
596 NetworkConfigurationPolicyHandler::CreateForUserPolicy()));
597 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
598 new PinnedLauncherAppsPolicyHandler()));
599 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
600 new ScreenMagnifierPolicyHandler()));
601 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
602 new LoginScreenPowerManagementPolicyHandler(chrome_schema
)));
604 ScopedVector
<ConfigurationPolicyHandler
>
605 power_management_idle_legacy_policies
;
606 power_management_idle_legacy_policies
.push_back(
607 new IntRangePolicyHandler(key::kScreenDimDelayAC
,
608 prefs::kPowerAcScreenDimDelayMs
,
612 power_management_idle_legacy_policies
.push_back(
613 new IntRangePolicyHandler(key::kScreenOffDelayAC
,
614 prefs::kPowerAcScreenOffDelayMs
,
618 power_management_idle_legacy_policies
.push_back(
619 new IntRangePolicyHandler(key::kIdleWarningDelayAC
,
620 prefs::kPowerAcIdleWarningDelayMs
,
624 power_management_idle_legacy_policies
.push_back(new IntRangePolicyHandler(
625 key::kIdleDelayAC
, prefs::kPowerAcIdleDelayMs
, 0, INT_MAX
, true));
626 power_management_idle_legacy_policies
.push_back(
627 new IntRangePolicyHandler(key::kScreenDimDelayBattery
,
628 prefs::kPowerBatteryScreenDimDelayMs
,
632 power_management_idle_legacy_policies
.push_back(
633 new IntRangePolicyHandler(key::kScreenOffDelayBattery
,
634 prefs::kPowerBatteryScreenOffDelayMs
,
638 power_management_idle_legacy_policies
.push_back(
639 new IntRangePolicyHandler(key::kIdleWarningDelayBattery
,
640 prefs::kPowerBatteryIdleWarningDelayMs
,
644 power_management_idle_legacy_policies
.push_back(
645 new IntRangePolicyHandler(key::kIdleDelayBattery
,
646 prefs::kPowerBatteryIdleDelayMs
,
650 power_management_idle_legacy_policies
.push_back(new IntRangePolicyHandler(
652 prefs::kPowerAcIdleAction
,
653 chromeos::PowerPolicyController::ACTION_SUSPEND
,
654 chromeos::PowerPolicyController::ACTION_DO_NOTHING
,
656 power_management_idle_legacy_policies
.push_back(new IntRangePolicyHandler(
657 key::kIdleActionBattery
,
658 prefs::kPowerBatteryIdleAction
,
659 chromeos::PowerPolicyController::ACTION_SUSPEND
,
660 chromeos::PowerPolicyController::ACTION_DO_NOTHING
,
662 power_management_idle_legacy_policies
.push_back(
663 new DeprecatedIdleActionHandler());
665 ScopedVector
<ConfigurationPolicyHandler
> screen_lock_legacy_policies
;
666 screen_lock_legacy_policies
.push_back(
667 new IntRangePolicyHandler(key::kScreenLockDelayAC
,
668 prefs::kPowerAcScreenLockDelayMs
,
672 screen_lock_legacy_policies
.push_back(
673 new IntRangePolicyHandler(key::kScreenLockDelayBattery
,
674 prefs::kPowerBatteryScreenLockDelayMs
,
679 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
680 new IntRangePolicyHandler(key::kSAMLOfflineSigninTimeLimit
,
681 prefs::kSAMLOfflineSigninTimeLimit
,
685 handlers
->AddHandler(
686 make_scoped_ptr
<ConfigurationPolicyHandler
>(new IntRangePolicyHandler(
687 key::kLidCloseAction
,
688 prefs::kPowerLidClosedAction
,
689 chromeos::PowerPolicyController::ACTION_SUSPEND
,
690 chromeos::PowerPolicyController::ACTION_DO_NOTHING
,
692 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
693 new IntPercentageToDoublePolicyHandler(
694 key::kPresentationScreenDimDelayScale
,
695 prefs::kPowerPresentationScreenDimDelayFactor
,
699 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
700 new IntPercentageToDoublePolicyHandler(
701 key::kUserActivityScreenDimDelayScale
,
702 prefs::kPowerUserActivityScreenDimDelayFactor
,
706 handlers
->AddHandler(
707 make_scoped_ptr
<ConfigurationPolicyHandler
>(new IntRangePolicyHandler(
708 key::kUptimeLimit
, prefs::kUptimeLimit
, 3600, INT_MAX
, true)));
709 handlers
->AddHandler(
710 make_scoped_ptr
<ConfigurationPolicyHandler
>(new IntRangePolicyHandler(
711 key::kDeviceLoginScreenDefaultScreenMagnifierType
,
716 // TODO(binjin): Remove LegacyPoliciesDeprecatingPolicyHandler for these two
717 // policies once deprecation of legacy power management policies is done.
718 // http://crbug.com/346229
719 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
720 new LegacyPoliciesDeprecatingPolicyHandler(
721 power_management_idle_legacy_policies
.Pass(),
722 make_scoped_ptr
<SchemaValidatingPolicyHandler
>(
723 new PowerManagementIdleSettingsPolicyHandler(chrome_schema
)))));
724 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
725 new LegacyPoliciesDeprecatingPolicyHandler(
726 screen_lock_legacy_policies
.Pass(),
727 make_scoped_ptr
<SchemaValidatingPolicyHandler
>(
728 new ScreenLockDelayPolicyHandler(chrome_schema
)))));
729 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
730 new ExternalDataPolicyHandler(key::kUserAvatarImage
)));
731 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
732 new ExternalDataPolicyHandler(key::kWallpaperImage
)));
733 #endif // defined(OS_CHROMEOS)
735 #if defined(OS_ANDROID) || defined(OS_IOS)
736 handlers
->AddHandler(make_scoped_ptr
<ConfigurationPolicyHandler
>(
737 new ManagedBookmarksPolicyHandler()));
739 return handlers
.Pass();
742 } // namespace policy