Home | History | Annotate | Download | only in policy
      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.
      4 
      5 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h"
      6 
      7 #include "base/basictypes.h"
      8 #include "base/bind.h"
      9 #include "base/values.h"
     10 #include "chrome/browser/extensions/policy_handlers.h"
     11 #include "chrome/browser/net/disk_cache_dir_policy_handler.h"
     12 #include "chrome/browser/net/proxy_policy_handler.h"
     13 #include "chrome/browser/policy/autofill_policy_handler.h"
     14 #include "chrome/browser/policy/file_selection_dialogs_policy_handler.h"
     15 #include "chrome/browser/policy/javascript_policy_handler.h"
     16 #include "chrome/browser/policy/url_blacklist_policy_handler.h"
     17 #include "chrome/browser/profiles/incognito_mode_policy_handler.h"
     18 #include "chrome/browser/search_engines/default_search_policy_handler.h"
     19 #include "chrome/browser/sessions/restore_on_startup_policy_handler.h"
     20 #include "chrome/browser/sync/sync_policy_handler.h"
     21 #include "chrome/common/pref_names.h"
     22 #include "components/policy/core/browser/configuration_policy_handler.h"
     23 #include "components/policy/core/browser/configuration_policy_handler_list.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 "extensions/common/manifest.h"
     28 #include "grit/component_strings.h"
     29 #include "policy/policy_constants.h"
     30 
     31 #if defined(OS_CHROMEOS)
     32 #include "ash/magnifier/magnifier_constants.h"
     33 #include "chrome/browser/chromeos/policy/configuration_policy_handler_chromeos.h"
     34 #include "chromeos/dbus/power_policy_controller.h"
     35 #endif  // defined(OS_CHROMEOS)
     36 
     37 #if defined(OS_ANDROID)
     38 #include "chrome/browser/policy/configuration_policy_handler_android.h"
     39 #endif  // defined(OS_ANDROID)
     40 
     41 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
     42 #include "chrome/browser/download/download_dir_policy_handler.h"
     43 #endif
     44 
     45 #if !defined(OS_MACOSX)
     46 #include "apps/pref_names.h"
     47 #endif
     48 
     49 namespace policy {
     50 
     51 namespace {
     52 
     53 // List of policy types to preference names. This is used for simple policies
     54 // that directly map to a single preference.
     55 const PolicyToPreferenceMapEntry kSimplePolicyMap[] = {
     56   { key::kHomepageLocation,
     57     prefs::kHomePage,
     58     Value::TYPE_STRING },
     59   { key::kHomepageIsNewTabPage,
     60     prefs::kHomePageIsNewTabPage,
     61     Value::TYPE_BOOLEAN },
     62   { key::kRestoreOnStartupURLs,
     63     prefs::kURLsToRestoreOnStartup,
     64     Value::TYPE_LIST },
     65   { key::kAlternateErrorPagesEnabled,
     66     prefs::kAlternateErrorPagesEnabled,
     67     Value::TYPE_BOOLEAN },
     68   { key::kSearchSuggestEnabled,
     69     prefs::kSearchSuggestEnabled,
     70     Value::TYPE_BOOLEAN },
     71   { key::kDnsPrefetchingEnabled,
     72     prefs::kNetworkPredictionEnabled,
     73     Value::TYPE_BOOLEAN },
     74   { key::kBuiltInDnsClientEnabled,
     75     prefs::kBuiltInDnsClientEnabled,
     76     Value::TYPE_BOOLEAN },
     77   { key::kDisableSpdy,
     78     prefs::kDisableSpdy,
     79     Value::TYPE_BOOLEAN },
     80   { key::kSafeBrowsingEnabled,
     81     prefs::kSafeBrowsingEnabled,
     82     Value::TYPE_BOOLEAN },
     83   { key::kForceSafeSearch,
     84     prefs::kForceSafeSearch,
     85     Value::TYPE_BOOLEAN },
     86   { key::kPasswordManagerEnabled,
     87     prefs::kPasswordManagerEnabled,
     88     Value::TYPE_BOOLEAN },
     89   { key::kPasswordManagerAllowShowPasswords,
     90     prefs::kPasswordManagerAllowShowPasswords,
     91     Value::TYPE_BOOLEAN },
     92   { key::kPrintingEnabled,
     93     prefs::kPrintingEnabled,
     94     Value::TYPE_BOOLEAN },
     95   { key::kDisablePrintPreview,
     96     prefs::kPrintPreviewDisabled,
     97     Value::TYPE_BOOLEAN },
     98   { key::kMetricsReportingEnabled,
     99     prefs::kMetricsReportingEnabled,
    100     Value::TYPE_BOOLEAN },
    101   { key::kApplicationLocaleValue,
    102     prefs::kApplicationLocale,
    103     Value::TYPE_STRING },
    104   { key::kDisabledPlugins,
    105     prefs::kPluginsDisabledPlugins,
    106     Value::TYPE_LIST },
    107   { key::kDisabledPluginsExceptions,
    108     prefs::kPluginsDisabledPluginsExceptions,
    109     Value::TYPE_LIST },
    110   { key::kEnabledPlugins,
    111     prefs::kPluginsEnabledPlugins,
    112     Value::TYPE_LIST },
    113   { key::kShowHomeButton,
    114     prefs::kShowHomeButton,
    115     Value::TYPE_BOOLEAN },
    116   { key::kSavingBrowserHistoryDisabled,
    117     prefs::kSavingBrowserHistoryDisabled,
    118     Value::TYPE_BOOLEAN },
    119   { key::kAllowDeletingBrowserHistory,
    120     prefs::kAllowDeletingBrowserHistory,
    121     Value::TYPE_BOOLEAN },
    122   { key::kDeveloperToolsDisabled,
    123     prefs::kDevToolsDisabled,
    124     Value::TYPE_BOOLEAN },
    125   { key::kBlockThirdPartyCookies,
    126     prefs::kBlockThirdPartyCookies,
    127     Value::TYPE_BOOLEAN },
    128   { key::kDefaultCookiesSetting,
    129     prefs::kManagedDefaultCookiesSetting,
    130     Value::TYPE_INTEGER },
    131   { key::kDefaultImagesSetting,
    132     prefs::kManagedDefaultImagesSetting,
    133     Value::TYPE_INTEGER },
    134   { key::kDefaultPluginsSetting,
    135     prefs::kManagedDefaultPluginsSetting,
    136     Value::TYPE_INTEGER },
    137   { key::kDefaultPopupsSetting,
    138     prefs::kManagedDefaultPopupsSetting,
    139     Value::TYPE_INTEGER },
    140   { key::kAutoSelectCertificateForUrls,
    141     prefs::kManagedAutoSelectCertificateForUrls,
    142     Value::TYPE_LIST },
    143   { key::kCookiesAllowedForUrls,
    144     prefs::kManagedCookiesAllowedForUrls,
    145     Value::TYPE_LIST },
    146   { key::kCookiesBlockedForUrls,
    147     prefs::kManagedCookiesBlockedForUrls,
    148     Value::TYPE_LIST },
    149   { key::kCookiesSessionOnlyForUrls,
    150     prefs::kManagedCookiesSessionOnlyForUrls,
    151     Value::TYPE_LIST },
    152   { key::kImagesAllowedForUrls,
    153     prefs::kManagedImagesAllowedForUrls,
    154     Value::TYPE_LIST },
    155   { key::kImagesBlockedForUrls,
    156     prefs::kManagedImagesBlockedForUrls,
    157     Value::TYPE_LIST },
    158   { key::kJavaScriptAllowedForUrls,
    159     prefs::kManagedJavaScriptAllowedForUrls,
    160     Value::TYPE_LIST },
    161   { key::kJavaScriptBlockedForUrls,
    162     prefs::kManagedJavaScriptBlockedForUrls,
    163     Value::TYPE_LIST },
    164   { key::kPluginsAllowedForUrls,
    165     prefs::kManagedPluginsAllowedForUrls,
    166     Value::TYPE_LIST },
    167   { key::kPluginsBlockedForUrls,
    168     prefs::kManagedPluginsBlockedForUrls,
    169     Value::TYPE_LIST },
    170   { key::kPopupsAllowedForUrls,
    171     prefs::kManagedPopupsAllowedForUrls,
    172     Value::TYPE_LIST },
    173   { key::kPopupsBlockedForUrls,
    174     prefs::kManagedPopupsBlockedForUrls,
    175     Value::TYPE_LIST },
    176   { key::kNotificationsAllowedForUrls,
    177     prefs::kManagedNotificationsAllowedForUrls,
    178     Value::TYPE_LIST },
    179   { key::kNotificationsBlockedForUrls,
    180     prefs::kManagedNotificationsBlockedForUrls,
    181     Value::TYPE_LIST },
    182   { key::kDefaultNotificationsSetting,
    183     prefs::kManagedDefaultNotificationsSetting,
    184     Value::TYPE_INTEGER },
    185   { key::kDefaultGeolocationSetting,
    186     prefs::kManagedDefaultGeolocationSetting,
    187     Value::TYPE_INTEGER },
    188   { key::kSigninAllowed,
    189     prefs::kSigninAllowed,
    190     Value::TYPE_BOOLEAN },
    191   { key::kEnableOriginBoundCerts,
    192     prefs::kEnableOriginBoundCerts,
    193     Value::TYPE_BOOLEAN },
    194   { key::kDisableSSLRecordSplitting,
    195     prefs::kDisableSSLRecordSplitting,
    196     Value::TYPE_BOOLEAN },
    197   { key::kEnableOnlineRevocationChecks,
    198     prefs::kCertRevocationCheckingEnabled,
    199     Value::TYPE_BOOLEAN },
    200   { key::kRequireOnlineRevocationChecksForLocalAnchors,
    201     prefs::kCertRevocationCheckingRequiredLocalAnchors,
    202     Value::TYPE_BOOLEAN },
    203   { key::kAuthSchemes,
    204     prefs::kAuthSchemes,
    205     Value::TYPE_STRING },
    206   { key::kDisableAuthNegotiateCnameLookup,
    207     prefs::kDisableAuthNegotiateCnameLookup,
    208     Value::TYPE_BOOLEAN },
    209   { key::kEnableAuthNegotiatePort,
    210     prefs::kEnableAuthNegotiatePort,
    211     Value::TYPE_BOOLEAN },
    212   { key::kAuthServerWhitelist,
    213     prefs::kAuthServerWhitelist,
    214     Value::TYPE_STRING },
    215   { key::kAuthNegotiateDelegateWhitelist,
    216     prefs::kAuthNegotiateDelegateWhitelist,
    217     Value::TYPE_STRING },
    218   { key::kGSSAPILibraryName,
    219     prefs::kGSSAPILibraryName,
    220     Value::TYPE_STRING },
    221   { key::kAllowCrossOriginAuthPrompt,
    222     prefs::kAllowCrossOriginAuthPrompt,
    223     Value::TYPE_BOOLEAN },
    224   { key::kDisable3DAPIs,
    225     prefs::kDisable3DAPIs,
    226     Value::TYPE_BOOLEAN },
    227   { key::kDisablePluginFinder,
    228     prefs::kDisablePluginFinder,
    229     Value::TYPE_BOOLEAN },
    230   { key::kDiskCacheSize,
    231     prefs::kDiskCacheSize,
    232     Value::TYPE_INTEGER },
    233   { key::kMediaCacheSize,
    234     prefs::kMediaCacheSize,
    235     Value::TYPE_INTEGER },
    236   { key::kPolicyRefreshRate,
    237     policy_prefs::kUserPolicyRefreshRate,
    238     Value::TYPE_INTEGER },
    239   { key::kDevicePolicyRefreshRate,
    240     prefs::kDevicePolicyRefreshRate,
    241     Value::TYPE_INTEGER },
    242   { key::kDefaultBrowserSettingEnabled,
    243     prefs::kDefaultBrowserSettingEnabled,
    244     Value::TYPE_BOOLEAN },
    245   { key::kRemoteAccessHostFirewallTraversal,
    246     prefs::kRemoteAccessHostFirewallTraversal,
    247     Value::TYPE_BOOLEAN },
    248   { key::kRemoteAccessHostRequireTwoFactor,
    249     prefs::kRemoteAccessHostRequireTwoFactor,
    250     Value::TYPE_BOOLEAN },
    251   { key::kRemoteAccessHostDomain,
    252     prefs::kRemoteAccessHostDomain,
    253     Value::TYPE_STRING },
    254   { key::kRemoteAccessHostTalkGadgetPrefix,
    255     prefs::kRemoteAccessHostTalkGadgetPrefix,
    256     Value::TYPE_STRING },
    257   { key::kRemoteAccessHostRequireCurtain,
    258     prefs::kRemoteAccessHostRequireCurtain,
    259     Value::TYPE_BOOLEAN },
    260   { key::kRemoteAccessHostAllowClientPairing,
    261     prefs::kRemoteAccessHostAllowClientPairing,
    262     Value::TYPE_BOOLEAN },
    263   { key::kCloudPrintProxyEnabled,
    264     prefs::kCloudPrintProxyEnabled,
    265     Value::TYPE_BOOLEAN },
    266   { key::kCloudPrintSubmitEnabled,
    267     prefs::kCloudPrintSubmitEnabled,
    268     Value::TYPE_BOOLEAN },
    269   { key::kTranslateEnabled,
    270     prefs::kEnableTranslate,
    271     Value::TYPE_BOOLEAN },
    272   { key::kAllowOutdatedPlugins,
    273     prefs::kPluginsAllowOutdated,
    274     Value::TYPE_BOOLEAN },
    275   { key::kAlwaysAuthorizePlugins,
    276     prefs::kPluginsAlwaysAuthorize,
    277     Value::TYPE_BOOLEAN },
    278   { key::kBookmarkBarEnabled,
    279     prefs::kShowBookmarkBar,
    280     Value::TYPE_BOOLEAN },
    281   { key::kEditBookmarksEnabled,
    282     prefs::kEditBookmarksEnabled,
    283     Value::TYPE_BOOLEAN },
    284   { key::kAllowFileSelectionDialogs,
    285     prefs::kAllowFileSelectionDialogs,
    286     Value::TYPE_BOOLEAN },
    287   { key::kImportBookmarks,
    288     prefs::kImportBookmarks,
    289     Value::TYPE_BOOLEAN },
    290   { key::kImportHistory,
    291     prefs::kImportHistory,
    292     Value::TYPE_BOOLEAN },
    293   { key::kImportHomepage,
    294     prefs::kImportHomepage,
    295     Value::TYPE_BOOLEAN },
    296   { key::kImportSearchEngine,
    297     prefs::kImportSearchEngine,
    298     Value::TYPE_BOOLEAN },
    299   { key::kImportSavedPasswords,
    300     prefs::kImportSavedPasswords,
    301     Value::TYPE_BOOLEAN },
    302   { key::kMaxConnectionsPerProxy,
    303     prefs::kMaxConnectionsPerProxy,
    304     Value::TYPE_INTEGER },
    305   { key::kURLWhitelist,
    306     prefs::kUrlWhitelist,
    307     Value::TYPE_LIST },
    308   { key::kEnableMemoryInfo,
    309     prefs::kEnableMemoryInfo,
    310     Value::TYPE_BOOLEAN },
    311   { key::kRestrictSigninToPattern,
    312     prefs::kGoogleServicesUsernamePattern,
    313     Value::TYPE_STRING },
    314   { key::kDefaultMediaStreamSetting,
    315     prefs::kManagedDefaultMediaStreamSetting,
    316     Value::TYPE_INTEGER },
    317   { key::kDisableSafeBrowsingProceedAnyway,
    318     prefs::kSafeBrowsingProceedAnywayDisabled,
    319     Value::TYPE_BOOLEAN },
    320   { key::kSpellCheckServiceEnabled,
    321     prefs::kSpellCheckUseSpellingService,
    322     Value::TYPE_BOOLEAN },
    323   { key::kDisableScreenshots,
    324     prefs::kDisableScreenshots,
    325     Value::TYPE_BOOLEAN },
    326   { key::kAudioCaptureAllowed,
    327     prefs::kAudioCaptureAllowed,
    328     Value::TYPE_BOOLEAN },
    329   { key::kVideoCaptureAllowed,
    330     prefs::kVideoCaptureAllowed,
    331     Value::TYPE_BOOLEAN },
    332   { key::kAudioCaptureAllowedUrls,
    333     prefs::kAudioCaptureAllowedUrls,
    334     Value::TYPE_LIST },
    335   { key::kVideoCaptureAllowedUrls,
    336     prefs::kVideoCaptureAllowedUrls,
    337     Value::TYPE_LIST },
    338   { key::kHideWebStoreIcon,
    339     prefs::kHideWebStoreIcon,
    340     Value::TYPE_BOOLEAN },
    341   { key::kVariationsRestrictParameter,
    342     prefs::kVariationsRestrictParameter,
    343     Value::TYPE_STRING },
    344   { key::kSupervisedUserCreationEnabled,
    345     prefs::kManagedUserCreationAllowed,
    346     Value::TYPE_BOOLEAN },
    347   { key::kForceEphemeralProfiles,
    348     prefs::kForceEphemeralProfiles,
    349     Value::TYPE_BOOLEAN },
    350 
    351 #if !defined(OS_MACOSX)
    352   { key::kFullscreenAllowed,
    353     prefs::kFullscreenAllowed,
    354     Value::TYPE_BOOLEAN },
    355   { key::kFullscreenAllowed,
    356     apps::prefs::kAppFullscreenAllowed,
    357     Value::TYPE_BOOLEAN },
    358 #endif  // !defined(OS_MACOSX)
    359 
    360 #if defined(OS_CHROMEOS)
    361   { key::kChromeOsLockOnIdleSuspend,
    362     prefs::kEnableScreenLock,
    363     Value::TYPE_BOOLEAN },
    364   { key::kChromeOsReleaseChannel,
    365     prefs::kChromeOsReleaseChannel,
    366     Value::TYPE_STRING },
    367   { key::kDriveDisabled,
    368     prefs::kDisableDrive,
    369     Value::TYPE_BOOLEAN },
    370   { key::kDriveDisabledOverCellular,
    371     prefs::kDisableDriveOverCellular,
    372     Value::TYPE_BOOLEAN },
    373   { key::kExternalStorageDisabled,
    374     prefs::kExternalStorageDisabled,
    375     Value::TYPE_BOOLEAN },
    376   { key::kAudioOutputAllowed,
    377     prefs::kAudioOutputAllowed,
    378     Value::TYPE_BOOLEAN },
    379   { key::kShowLogoutButtonInTray,
    380     prefs::kShowLogoutButtonInTray,
    381     Value::TYPE_BOOLEAN },
    382   { key::kShelfAutoHideBehavior,
    383     prefs::kShelfAutoHideBehaviorLocal,
    384     Value::TYPE_STRING },
    385   { key::kSessionLengthLimit,
    386     prefs::kSessionLengthLimit,
    387     Value::TYPE_INTEGER },
    388   { key::kWaitForInitialUserActivity,
    389     prefs::kSessionWaitForInitialUserActivity,
    390     Value::TYPE_BOOLEAN },
    391   { key::kPowerManagementUsesAudioActivity,
    392     prefs::kPowerUseAudioActivity,
    393     Value::TYPE_BOOLEAN },
    394   { key::kPowerManagementUsesVideoActivity,
    395     prefs::kPowerUseVideoActivity,
    396     Value::TYPE_BOOLEAN },
    397   { key::kAllowScreenWakeLocks,
    398     prefs::kPowerAllowScreenWakeLocks,
    399     Value::TYPE_BOOLEAN },
    400   { key::kWaitForInitialUserActivity,
    401     prefs::kPowerWaitForInitialUserActivity,
    402     Value::TYPE_BOOLEAN },
    403   { key::kTermsOfServiceURL,
    404     prefs::kTermsOfServiceURL,
    405     Value::TYPE_STRING },
    406   { key::kShowAccessibilityOptionsInSystemTrayMenu,
    407     prefs::kShouldAlwaysShowAccessibilityMenu,
    408     Value::TYPE_BOOLEAN },
    409   { key::kLargeCursorEnabled,
    410     prefs::kLargeCursorEnabled,
    411     Value::TYPE_BOOLEAN },
    412   { key::kSpokenFeedbackEnabled,
    413     prefs::kSpokenFeedbackEnabled,
    414     Value::TYPE_BOOLEAN },
    415   { key::kHighContrastEnabled,
    416     prefs::kHighContrastEnabled,
    417     Value::TYPE_BOOLEAN },
    418   { key::kDeviceLoginScreenDefaultLargeCursorEnabled,
    419     NULL,
    420     Value::TYPE_BOOLEAN },
    421   { key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled,
    422     NULL,
    423     Value::TYPE_BOOLEAN },
    424   { key::kDeviceLoginScreenDefaultHighContrastEnabled,
    425     NULL,
    426     Value::TYPE_BOOLEAN },
    427   { key::kRebootAfterUpdate,
    428     prefs::kRebootAfterUpdate,
    429     Value::TYPE_BOOLEAN },
    430   { key::kAttestationEnabledForUser,
    431     prefs::kAttestationEnabled,
    432     Value::TYPE_BOOLEAN },
    433   { key::kChromeOsMultiProfileUserBehavior,
    434     prefs::kMultiProfileUserBehavior,
    435     Value::TYPE_STRING },
    436 #endif  // defined(OS_CHROMEOS)
    437 
    438 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
    439   { key::kBackgroundModeEnabled,
    440     prefs::kBackgroundModeEnabled,
    441     Value::TYPE_BOOLEAN },
    442 #endif  // !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
    443 
    444 #if defined(OS_ANDROID)
    445   { key::kDataCompressionProxyEnabled,
    446     prefs::kSpdyProxyAuthEnabled,
    447     Value::TYPE_BOOLEAN },
    448 #endif  // defined(OS_ANDROID)
    449 };
    450 
    451 // Mapping from extension type names to Manifest::Type.
    452 StringToIntEnumListPolicyHandler::MappingEntry kExtensionAllowedTypesMap[] = {
    453   { "extension", extensions::Manifest::TYPE_EXTENSION },
    454   { "theme", extensions::Manifest::TYPE_THEME },
    455   { "user_script", extensions::Manifest::TYPE_USER_SCRIPT },
    456   { "hosted_app", extensions::Manifest::TYPE_HOSTED_APP },
    457   { "legacy_packaged_app", extensions::Manifest::TYPE_LEGACY_PACKAGED_APP },
    458   { "platform_app", extensions::Manifest::TYPE_PLATFORM_APP },
    459 };
    460 
    461 }  // namespace
    462 
    463 #if !defined(OS_IOS)
    464 scoped_ptr<ConfigurationPolicyHandlerList> BuildHandlerList() {
    465   scoped_ptr<ConfigurationPolicyHandlerList> handlers(
    466       new ConfigurationPolicyHandlerList(base::Bind(&GetChromePolicyDetails)));
    467   for (size_t i = 0; i < arraysize(kSimplePolicyMap); ++i) {
    468     handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    469         new SimplePolicyHandler(kSimplePolicyMap[i].policy_name,
    470                                 kSimplePolicyMap[i].preference_path,
    471                                 kSimplePolicyMap[i].value_type)));
    472   }
    473 
    474   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    475       new AutofillPolicyHandler()));
    476   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    477       new DefaultSearchPolicyHandler()));
    478   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    479       new FileSelectionDialogsPolicyHandler()));
    480   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    481       new IncognitoModePolicyHandler()));
    482   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    483       new JavascriptPolicyHandler()));
    484   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    485       new ProxyPolicyHandler()));
    486   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    487       new RestoreOnStartupPolicyHandler()));
    488   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    489       new browser_sync::SyncPolicyHandler()));
    490   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    491       new URLBlacklistPolicyHandler()));
    492 
    493   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    494       new extensions::ExtensionListPolicyHandler(
    495           key::kExtensionInstallWhitelist,
    496           prefs::kExtensionInstallAllowList,
    497           false)));
    498   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    499       new extensions::ExtensionListPolicyHandler(
    500           key::kExtensionInstallBlacklist,
    501           prefs::kExtensionInstallDenyList,
    502           true)));
    503   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    504       new extensions::ExtensionInstallForcelistPolicyHandler()));
    505   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    506       new extensions::ExtensionURLPatternListPolicyHandler(
    507           key::kExtensionInstallSources,
    508           prefs::kExtensionAllowedInstallSites)));
    509   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    510       new StringToIntEnumListPolicyHandler(
    511           key::kExtensionAllowedTypes,
    512           prefs::kExtensionAllowedTypes,
    513           kExtensionAllowedTypesMap,
    514           kExtensionAllowedTypesMap + arraysize(kExtensionAllowedTypesMap))));
    515 #if defined(OS_CHROMEOS)
    516   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    517       new extensions::ExtensionListPolicyHandler(
    518           key::kAttestationExtensionWhitelist,
    519           prefs::kAttestationExtensionWhitelist,
    520           false)));
    521 #endif  // defined(OS_CHROMEOS)
    522 
    523 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
    524   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    525       new DiskCacheDirPolicyHandler()));
    526   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    527       new DownloadDirPolicyHandler));
    528 #endif  // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
    529 
    530 #if defined(OS_CHROMEOS)
    531   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    532       NetworkConfigurationPolicyHandler::CreateForDevicePolicy()));
    533   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    534       NetworkConfigurationPolicyHandler::CreateForUserPolicy()));
    535   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    536       new PinnedLauncherAppsPolicyHandler()));
    537   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    538       new ScreenMagnifierPolicyHandler()));
    539   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    540       new LoginScreenPowerManagementPolicyHandler));
    541 
    542   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    543       new IntRangePolicyHandler(key::kScreenDimDelayAC,
    544                                 prefs::kPowerAcScreenDimDelayMs,
    545                                 0,
    546                                 INT_MAX,
    547                                 true)));
    548   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    549       new IntRangePolicyHandler(key::kScreenOffDelayAC,
    550                                 prefs::kPowerAcScreenOffDelayMs,
    551                                 0,
    552                                 INT_MAX,
    553                                 true)));
    554   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    555       new IntRangePolicyHandler(key::kScreenLockDelayAC,
    556                                 prefs::kPowerAcScreenLockDelayMs,
    557                                 0,
    558                                 INT_MAX,
    559                                 true)));
    560   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    561       new IntRangePolicyHandler(key::kIdleWarningDelayAC,
    562                                 prefs::kPowerAcIdleWarningDelayMs,
    563                                 0,
    564                                 INT_MAX,
    565                                 true)));
    566   handlers->AddHandler(
    567       make_scoped_ptr<ConfigurationPolicyHandler>(new IntRangePolicyHandler(
    568           key::kIdleDelayAC, prefs::kPowerAcIdleDelayMs, 0, INT_MAX, true)));
    569   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    570       new IntRangePolicyHandler(key::kScreenDimDelayBattery,
    571                                 prefs::kPowerBatteryScreenDimDelayMs,
    572                                 0,
    573                                 INT_MAX,
    574                                 true)));
    575   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    576       new IntRangePolicyHandler(key::kScreenOffDelayBattery,
    577                                 prefs::kPowerBatteryScreenOffDelayMs,
    578                                 0,
    579                                 INT_MAX,
    580                                 true)));
    581   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    582       new IntRangePolicyHandler(key::kScreenLockDelayBattery,
    583                                 prefs::kPowerBatteryScreenLockDelayMs,
    584                                 0,
    585                                 INT_MAX,
    586                                 true)));
    587   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    588       new IntRangePolicyHandler(key::kIdleWarningDelayBattery,
    589                                 prefs::kPowerBatteryIdleWarningDelayMs,
    590                                 0,
    591                                 INT_MAX,
    592                                 true)));
    593   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    594       new IntRangePolicyHandler(key::kIdleDelayBattery,
    595                                 prefs::kPowerBatteryIdleDelayMs,
    596                                 0,
    597                                 INT_MAX,
    598                                 true)));
    599   handlers->AddHandler(
    600       make_scoped_ptr<ConfigurationPolicyHandler>(new IntRangePolicyHandler(
    601           key::kIdleActionAC,
    602           prefs::kPowerAcIdleAction,
    603           chromeos::PowerPolicyController::ACTION_SUSPEND,
    604           chromeos::PowerPolicyController::ACTION_DO_NOTHING,
    605           false)));
    606   handlers->AddHandler(
    607       make_scoped_ptr<ConfigurationPolicyHandler>(new IntRangePolicyHandler(
    608           key::kIdleActionBattery,
    609           prefs::kPowerBatteryIdleAction,
    610           chromeos::PowerPolicyController::ACTION_SUSPEND,
    611           chromeos::PowerPolicyController::ACTION_DO_NOTHING,
    612           false)));
    613   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    614       new DeprecatedIdleActionHandler()));
    615   handlers->AddHandler(
    616       make_scoped_ptr<ConfigurationPolicyHandler>(new IntRangePolicyHandler(
    617           key::kLidCloseAction,
    618           prefs::kPowerLidClosedAction,
    619           chromeos::PowerPolicyController::ACTION_SUSPEND,
    620           chromeos::PowerPolicyController::ACTION_DO_NOTHING,
    621           false)));
    622   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    623       new IntPercentageToDoublePolicyHandler(
    624           key::kPresentationScreenDimDelayScale,
    625           prefs::kPowerPresentationScreenDimDelayFactor,
    626           100,
    627           INT_MAX,
    628           true)));
    629   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    630       new IntPercentageToDoublePolicyHandler(
    631           key::kUserActivityScreenDimDelayScale,
    632           prefs::kPowerUserActivityScreenDimDelayFactor,
    633           100,
    634           INT_MAX,
    635           true)));
    636   handlers->AddHandler(
    637       make_scoped_ptr<ConfigurationPolicyHandler>(new IntRangePolicyHandler(
    638           key::kUptimeLimit, prefs::kUptimeLimit, 3600, INT_MAX, true)));
    639   handlers->AddHandler(
    640       make_scoped_ptr<ConfigurationPolicyHandler>(new IntRangePolicyHandler(
    641           key::kDeviceLoginScreenDefaultScreenMagnifierType,
    642           NULL,
    643           0,
    644           ash::MAGNIFIER_FULL,
    645           false)));
    646   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    647       new ExternalDataPolicyHandler(key::kUserAvatarImage)));
    648 #endif  // defined(OS_CHROMEOS)
    649 
    650 #if defined(OS_ANDROID)
    651   handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
    652       new ManagedBookmarksPolicyHandler()));
    653 #endif
    654   return handlers.Pass();
    655 }
    656 #endif  // !defined(OS_IOS)
    657 
    658 }  // namespace policy
    659