Home | History | Annotate | Download | only in prefs
      1 // Copyright 2012 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/prefs/browser_prefs.h"
      6 
      7 #include <string>
      8 
      9 #include "base/debug/trace_event.h"
     10 #include "base/prefs/pref_registry_simple.h"
     11 #include "base/prefs/pref_service.h"
     12 #include "chrome/browser/about_flags.h"
     13 #include "chrome/browser/accessibility/invert_bubble_prefs.h"
     14 #include "chrome/browser/apps/drive/drive_app_mapping.h"
     15 #include "chrome/browser/apps/shortcut_manager.h"
     16 #include "chrome/browser/autocomplete/zero_suggest_provider.h"
     17 #include "chrome/browser/background/background_mode_manager.h"
     18 #include "chrome/browser/browser_process_impl.h"
     19 #include "chrome/browser/browser_shutdown.h"
     20 #include "chrome/browser/chrome_content_browser_client.h"
     21 #include "chrome/browser/component_updater/recovery_component_installer.h"
     22 #include "chrome/browser/content_settings/host_content_settings_map.h"
     23 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
     24 #include "chrome/browser/devtools/devtools_window.h"
     25 #include "chrome/browser/download/download_prefs.h"
     26 #include "chrome/browser/extensions/extension_web_ui.h"
     27 #include "chrome/browser/external_protocol/external_protocol_handler.h"
     28 #include "chrome/browser/first_run/first_run.h"
     29 #include "chrome/browser/geolocation/geolocation_prefs.h"
     30 #include "chrome/browser/google/google_url_tracker_factory.h"
     31 #include "chrome/browser/gpu/gl_string_manager.h"
     32 #include "chrome/browser/gpu/gpu_mode_manager.h"
     33 #include "chrome/browser/intranet_redirect_detector.h"
     34 #include "chrome/browser/io_thread.h"
     35 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
     36 #include "chrome/browser/media/media_device_id_salt.h"
     37 #include "chrome/browser/media/media_stream_devices_controller.h"
     38 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
     39 #include "chrome/browser/metrics/variations/variations_service.h"
     40 #include "chrome/browser/net/http_server_properties_manager.h"
     41 #include "chrome/browser/net/net_pref_observer.h"
     42 #include "chrome/browser/net/predictor.h"
     43 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
     44 #include "chrome/browser/net/ssl_config_service_manager.h"
     45 #include "chrome/browser/notifications/desktop_notification_service.h"
     46 #include "chrome/browser/notifications/message_center_notification_manager.h"
     47 #include "chrome/browser/pepper_flash_settings_manager.h"
     48 #include "chrome/browser/plugins/plugin_finder.h"
     49 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
     50 #include "chrome/browser/prefs/incognito_mode_prefs.h"
     51 #include "chrome/browser/prefs/pref_service_syncable.h"
     52 #include "chrome/browser/prefs/session_startup_pref.h"
     53 #include "chrome/browser/printing/print_dialog_cloud.h"
     54 #include "chrome/browser/profiles/chrome_version_service.h"
     55 #include "chrome/browser/profiles/profile.h"
     56 #include "chrome/browser/profiles/profile_impl.h"
     57 #include "chrome/browser/profiles/profile_info_cache.h"
     58 #include "chrome/browser/profiles/profiles_state.h"
     59 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h"
     60 #include "chrome/browser/renderer_host/web_cache_manager.h"
     61 #include "chrome/browser/search/search.h"
     62 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
     63 #include "chrome/browser/services/gcm/gcm_profile_service.h"
     64 #include "chrome/browser/signin/easy_unlock.h"
     65 #include "chrome/browser/signin/signin_manager_factory.h"
     66 #include "chrome/browser/signin/signin_promo.h"
     67 #include "chrome/browser/task_manager/task_manager.h"
     68 #include "chrome/browser/ui/app_list/app_list_service.h"
     69 #include "chrome/browser/ui/browser_ui_prefs.h"
     70 #include "chrome/browser/ui/navigation_correction_tab_observer.h"
     71 #include "chrome/browser/ui/network_profile_bubble.h"
     72 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
     73 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
     74 #include "chrome/browser/ui/startup/autolaunch_prompt.h"
     75 #include "chrome/browser/ui/startup/default_browser_prompt.h"
     76 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
     77 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
     78 #include "chrome/browser/ui/webui/flags_ui.h"
     79 #include "chrome/browser/ui/webui/instant_ui.h"
     80 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
     81 #include "chrome/browser/ui/webui/plugins_ui.h"
     82 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
     83 #include "chrome/browser/upgrade_detector.h"
     84 #include "chrome/browser/web_resource/promo_resource_service.h"
     85 #include "chrome/common/pref_names.h"
     86 #include "components/autofill/core/browser/autofill_manager.h"
     87 #include "components/bookmarks/browser/bookmark_utils.h"
     88 #include "components/google/core/browser/google_pref_names.h"
     89 #include "components/google/core/browser/google_url_tracker.h"
     90 #include "components/network_time/network_time_tracker.h"
     91 #include "components/password_manager/core/browser/password_manager.h"
     92 #include "components/pref_registry/pref_registry_syncable.h"
     93 #include "components/rappor/rappor_service.h"
     94 #include "components/sync_driver/sync_prefs.h"
     95 #include "components/translate/core/browser/translate_prefs.h"
     96 #include "content/public/browser/render_process_host.h"
     97 #include "extensions/browser/extension_prefs.h"
     98 
     99 #if defined(ENABLE_AUTOFILL_DIALOG)
    100 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
    101 #endif
    102 
    103 #if defined(ENABLE_CONFIGURATION_POLICY)
    104 #include "components/policy/core/browser/browser_policy_connector.h"
    105 #include "components/policy/core/browser/url_blacklist_manager.h"
    106 #include "components/policy/core/common/policy_statistics_collector.h"
    107 #endif
    108 
    109 #if defined(ENABLE_EXTENSIONS)
    110 #include "apps/prefs.h"
    111 #include "chrome/browser/extensions/activity_log/activity_log.h"
    112 #include "chrome/browser/extensions/api/commands/command_service.h"
    113 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
    114 #include "chrome/browser/extensions/launch_util.h"
    115 #endif
    116 
    117 #if defined(ENABLE_MANAGED_USERS)
    118 #include "chrome/browser/supervised_user/supervised_user_service.h"
    119 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
    120 #include "chrome/browser/supervised_user/supervised_user_sync_service.h"
    121 #endif
    122 
    123 #if defined(ENABLE_SERVICE_DISCOVERY)
    124 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui.h"
    125 #endif
    126 
    127 #if defined(ENABLE_PLUGIN_INSTALLATION)
    128 #include "chrome/browser/plugins/plugins_resource_service.h"
    129 #endif
    130 
    131 #if defined(OS_ANDROID)
    132 #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h"
    133 #include "chrome/browser/android/new_tab_page_prefs.h"
    134 #else
    135 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
    136 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
    137 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
    138 #endif
    139 
    140 #if defined(OS_CHROMEOS)
    141 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
    142 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
    143 #include "chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h"
    144 #include "chrome/browser/chromeos/customization_document.h"
    145 #include "chrome/browser/chromeos/display/display_preferences.h"
    146 #include "chrome/browser/chromeos/extensions/echo_private_api.h"
    147 #include "chrome/browser/chromeos/file_system_provider/service.h"
    148 #include "chrome/browser/chromeos/first_run/first_run.h"
    149 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h"
    150 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h"
    151 #include "chrome/browser/chromeos/login/session/session_manager.h"
    152 #include "chrome/browser/chromeos/login/startup_utils.h"
    153 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h"
    154 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h"
    155 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
    156 #include "chrome/browser/chromeos/login/users/user_manager.h"
    157 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
    158 #include "chrome/browser/chromeos/net/proxy_config_handler.h"
    159 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
    160 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
    161 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
    162 #include "chrome/browser/chromeos/policy/device_status_collector.h"
    163 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
    164 #include "chrome/browser/chromeos/power/power_prefs.h"
    165 #include "chrome/browser/chromeos/preferences.h"
    166 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
    167 #include "chrome/browser/chromeos/settings/device_settings_cache.h"
    168 #include "chrome/browser/chromeos/status/data_promo_notification.h"
    169 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
    170 #include "chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h"
    171 #include "chrome/browser/extensions/extension_assets_manager_chromeos.h"
    172 #include "chrome/browser/metrics/chromeos_metrics_provider.h"
    173 #include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h"
    174 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
    175 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
    176 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h"
    177 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
    178 #else
    179 #include "chrome/browser/extensions/default_apps.h"
    180 #endif
    181 
    182 #if defined(OS_MACOSX)
    183 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h"
    184 #include "chrome/browser/ui/cocoa/confirm_quit.h"
    185 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller_prefs.h"
    186 #endif
    187 
    188 #if defined(OS_WIN)
    189 #include "chrome/browser/apps/app_launch_for_metro_restart_win.h"
    190 #include "chrome/browser/component_updater/sw_reporter_installer_win.h"
    191 #endif
    192 
    193 #if defined(TOOLKIT_VIEWS)
    194 #include "chrome/browser/ui/browser_view_prefs.h"
    195 #endif
    196 
    197 #if defined(USE_ASH)
    198 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
    199 #endif
    200 
    201 namespace {
    202 
    203 enum MigratedPreferences {
    204   NO_PREFS = 0,
    205   DNS_PREFS = 1 << 0,
    206   WINDOWS_PREFS = 1 << 1,
    207   GOOGLE_URL_TRACKER_PREFS = 1 << 2,
    208 };
    209 
    210 // A previous feature (see
    211 // chrome/browser/protector/protected_prefs_watcher.cc in source
    212 // control history) used this string as a prefix for various prefs it
    213 // registered. We keep it here for now to clear out those old prefs in
    214 // MigrateUserPrefs.
    215 const char kBackupPref[] = "backup";
    216 
    217 #if !defined(OS_ANDROID)
    218 // The sync promo error message preference has been removed; this pref will
    219 // be cleared from user data.
    220 const char kSyncPromoErrorMessage[] = "sync_promo.error_message";
    221 #endif
    222 
    223 }  // namespace
    224 
    225 namespace chrome {
    226 
    227 void RegisterLocalState(PrefRegistrySimple* registry) {
    228   // Prefs in Local State.
    229   registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0);
    230 
    231   // Please keep this list alphabetized.
    232   AppListService::RegisterPrefs(registry);
    233   browser_shutdown::RegisterPrefs(registry);
    234   BrowserProcessImpl::RegisterPrefs(registry);
    235   ChromeMetricsServiceClient::RegisterPrefs(registry);
    236   chrome_prefs::RegisterPrefs(registry);
    237   chrome_variations::VariationsService::RegisterPrefs(registry);
    238   component_updater::RegisterPrefsForRecoveryComponent(registry);
    239   ExternalProtocolHandler::RegisterPrefs(registry);
    240   FlagsUI::RegisterPrefs(registry);
    241   geolocation::RegisterPrefs(registry);
    242   GLStringManager::RegisterPrefs(registry);
    243   GpuModeManager::RegisterPrefs(registry);
    244   IntranetRedirectDetector::RegisterPrefs(registry);
    245   IOThread::RegisterPrefs(registry);
    246   KeywordEditorController::RegisterPrefs(registry);
    247   network_time::NetworkTimeTracker::RegisterPrefs(registry);
    248   PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
    249   ProfileInfoCache::RegisterPrefs(registry);
    250   profiles::RegisterPrefs(registry);
    251   PromoResourceService::RegisterPrefs(registry);
    252   rappor::RapporService::RegisterPrefs(registry);
    253   RegisterScreenshotPrefs(registry);
    254   SigninManagerFactory::RegisterPrefs(registry);
    255   SSLConfigServiceManager::RegisterPrefs(registry);
    256   UpgradeDetector::RegisterPrefs(registry);
    257   WebCacheManager::RegisterPrefs(registry);
    258 
    259 #if defined(ENABLE_AUTOFILL_DIALOG)
    260   autofill::AutofillDialogController::RegisterPrefs(registry);
    261 #endif
    262 
    263 #if defined(ENABLE_CONFIGURATION_POLICY)
    264   policy::BrowserPolicyConnector::RegisterPrefs(registry);
    265   policy::PolicyStatisticsCollector::RegisterPrefs(registry);
    266 #endif
    267 
    268 #if defined(ENABLE_NOTIFICATIONS) && !defined(OS_ANDROID)
    269   // Android does not use the message center for notifications.
    270   MessageCenterNotificationManager::RegisterPrefs(registry);
    271 #endif
    272 
    273 #if defined(ENABLE_PLUGINS)
    274   PluginFinder::RegisterPrefs(registry);
    275 #endif
    276 
    277 #if defined(ENABLE_PLUGIN_INSTALLATION)
    278   PluginsResourceService::RegisterPrefs(registry);
    279 #endif
    280 
    281 #if defined(ENABLE_TASK_MANAGER)
    282   TaskManager::RegisterPrefs(registry);
    283 #endif  // defined(ENABLE_TASK_MANAGER)
    284 
    285 #if !defined(OS_ANDROID)
    286   AutomaticProfileResetterFactory::RegisterPrefs(registry);
    287   BackgroundModeManager::RegisterPrefs(registry);
    288   RegisterBrowserPrefs(registry);
    289 #if !defined(OS_CHROMEOS)
    290   RegisterDefaultBrowserPromptPrefs(registry);
    291 #endif  // !defined(OS_CHROMEOS)
    292 #endif  // !defined(OS_ANDROID)
    293 
    294 #if defined(OS_CHROMEOS)
    295   ChromeOSMetricsProvider::RegisterPrefs(registry);
    296   chromeos::AudioDevicesPrefHandlerImpl::RegisterPrefs(registry);
    297   chromeos::ChargerReplacementHandler::RegisterPrefs(registry);
    298   chromeos::DataPromoNotification::RegisterPrefs(registry);
    299   chromeos::DeviceOAuth2TokenService::RegisterPrefs(registry);
    300   chromeos::device_settings_cache::RegisterPrefs(registry);
    301   chromeos::default_pinned_apps_field_trial::RegisterPrefs(registry);
    302   chromeos::language_prefs::RegisterPrefs(registry);
    303   chromeos::KioskAppManager::RegisterPrefs(registry);
    304   chromeos::MultiProfileUserController::RegisterPrefs(registry);
    305   chromeos::HIDDetectionScreenHandler::RegisterPrefs(registry);
    306   chromeos::NetworkScreenHandler::RegisterPrefs(registry);
    307   chromeos::Preferences::RegisterPrefs(registry);
    308   chromeos::proxy_config::RegisterPrefs(registry);
    309   chromeos::RegisterDisplayLocalStatePrefs(registry);
    310   chromeos::ResetScreenHandler::RegisterPrefs(registry);
    311   chromeos::ServicesCustomizationDocument::RegisterPrefs(registry);
    312   chromeos::SessionManager::RegisterPrefs(registry);
    313   chromeos::SigninScreenHandler::RegisterPrefs(registry);
    314   chromeos::system::AutomaticRebootManager::RegisterPrefs(registry);
    315   chromeos::UserImageManager::RegisterPrefs(registry);
    316   chromeos::UserManager::RegisterPrefs(registry);
    317   chromeos::WallpaperManager::RegisterPrefs(registry);
    318   chromeos::StartupUtils::RegisterPrefs(registry);
    319   chromeos::echo_offer::RegisterPrefs(registry);
    320   extensions::ExtensionAssetsManagerChromeOS::RegisterPrefs(registry);
    321   policy::AutoEnrollmentClient::RegisterPrefs(registry);
    322   policy::BrowserPolicyConnectorChromeOS::RegisterPrefs(registry);
    323   policy::DeviceCloudPolicyManagerChromeOS::RegisterPrefs(registry);
    324   policy::DeviceStatusCollector::RegisterPrefs(registry);
    325   policy::PolicyCertServiceFactory::RegisterPrefs(registry);
    326 #endif
    327 
    328 #if defined(OS_MACOSX)
    329   confirm_quit::RegisterLocalState(registry);
    330   QuitWithAppsController::RegisterPrefs(registry);
    331 #endif
    332 
    333 #if defined(OS_WIN)
    334   app_metro_launch::RegisterPrefs(registry);
    335   component_updater::RegisterPrefsForSwReporter(registry);
    336   password_manager::PasswordManager::RegisterLocalPrefs(registry);
    337 #endif
    338 
    339 #if defined(TOOLKIT_VIEWS)
    340   RegisterBrowserViewLocalPrefs(registry);
    341 #endif
    342 }
    343 
    344 // Register prefs applicable to all profiles.
    345 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
    346   TRACE_EVENT0("browser", "chrome::RegisterUserPrefs");
    347   // User prefs. Please keep this list alphabetized.
    348   autofill::AutofillManager::RegisterProfilePrefs(registry);
    349   bookmark_utils::RegisterProfilePrefs(registry);
    350   sync_driver::SyncPrefs::RegisterProfilePrefs(registry);
    351   ChromeContentBrowserClient::RegisterProfilePrefs(registry);
    352   ChromeVersionService::RegisterProfilePrefs(registry);
    353   chrome_browser_net::HttpServerPropertiesManager::RegisterProfilePrefs(
    354       registry);
    355   chrome_browser_net::Predictor::RegisterProfilePrefs(registry);
    356   chrome_prefs::RegisterProfilePrefs(registry);
    357   DownloadPrefs::RegisterProfilePrefs(registry);
    358   easy_unlock::RegisterProfilePrefs(registry);
    359   gcm::GCMProfileService::RegisterProfilePrefs(registry);
    360   HostContentSettingsMap::RegisterProfilePrefs(registry);
    361   IncognitoModePrefs::RegisterProfilePrefs(registry);
    362   InstantUI::RegisterProfilePrefs(registry);
    363   NavigationCorrectionTabObserver::RegisterProfilePrefs(registry);
    364   MediaCaptureDevicesDispatcher::RegisterProfilePrefs(registry);
    365   MediaDeviceIDSalt::RegisterProfilePrefs(registry);
    366   MediaStreamDevicesController::RegisterProfilePrefs(registry);
    367   NetPrefObserver::RegisterProfilePrefs(registry);
    368   password_manager::PasswordManager::RegisterProfilePrefs(registry);
    369   PrefProxyConfigTrackerImpl::RegisterProfilePrefs(registry);
    370   PrefsTabHelper::RegisterProfilePrefs(registry);
    371   Profile::RegisterProfilePrefs(registry);
    372   ProfileImpl::RegisterProfilePrefs(registry);
    373   PromoResourceService::RegisterProfilePrefs(registry);
    374   ProtocolHandlerRegistry::RegisterProfilePrefs(registry);
    375   RegisterBrowserUserPrefs(registry);
    376   SessionStartupPref::RegisterProfilePrefs(registry);
    377   TemplateURLPrepopulateData::RegisterProfilePrefs(registry);
    378   TranslatePrefs::RegisterProfilePrefs(registry);
    379   ZeroSuggestProvider::RegisterProfilePrefs(registry);
    380 
    381 #if defined(ENABLE_AUTOFILL_DIALOG)
    382   autofill::AutofillDialogController::RegisterProfilePrefs(registry);
    383 #endif
    384 
    385 #if defined(ENABLE_CONFIGURATION_POLICY)
    386   policy::URLBlacklistManager::RegisterProfilePrefs(registry);
    387 #endif
    388 
    389 #if defined(ENABLE_EXTENSIONS)
    390   apps::RegisterProfilePrefs(registry);
    391   extensions::ActivityLog::RegisterProfilePrefs(registry);
    392   extensions::launch_util::RegisterProfilePrefs(registry);
    393 #endif
    394   // TODO(thestig) These should be in ifdef'd out, but too many parts of Chrome
    395   // still expects it to be registered.
    396   ExtensionWebUI::RegisterProfilePrefs(registry);
    397   extensions::ExtensionPrefs::RegisterProfilePrefs(registry);
    398 
    399 #if defined(ENABLE_FULL_PRINTING)
    400   print_dialog_cloud::RegisterProfilePrefs(registry);
    401   printing::StickySettings::RegisterProfilePrefs(registry);
    402 #endif
    403 
    404 #if defined(ENABLE_MANAGED_USERS)
    405   SupervisedUserService::RegisterProfilePrefs(registry);
    406   SupervisedUserSharedSettingsService::RegisterProfilePrefs(registry);
    407   SupervisedUserSyncService::RegisterProfilePrefs(registry);
    408 #endif
    409 
    410 #if defined(ENABLE_NOTIFICATIONS)
    411   DesktopNotificationService::RegisterProfilePrefs(registry);
    412 #endif
    413 
    414 #if defined(ENABLE_SERVICE_DISCOVERY)
    415   LocalDiscoveryUI::RegisterProfilePrefs(registry);
    416 #endif
    417 
    418 #if defined(OS_ANDROID)
    419   chrome_variations::VariationsService::RegisterProfilePrefs(registry);
    420   NewTabPagePrefs::RegisterProfilePrefs(registry);
    421   PartnerBookmarksShim::RegisterProfilePrefs(registry);
    422 #else
    423   AppShortcutManager::RegisterProfilePrefs(registry);
    424   autofill::GeneratedCreditCardBubbleController::RegisterUserPrefs(registry);
    425   DeviceIDFetcher::RegisterProfilePrefs(registry);
    426   DevToolsWindow::RegisterProfilePrefs(registry);
    427   DriveAppMapping::RegisterProfilePrefs(registry);
    428   extensions::CommandService::RegisterProfilePrefs(registry);
    429   extensions::ExtensionSettingsHandler::RegisterProfilePrefs(registry);
    430   extensions::TabsCaptureVisibleTabFunction::RegisterProfilePrefs(registry);
    431   first_run::RegisterProfilePrefs(registry);
    432   NewTabUI::RegisterProfilePrefs(registry);
    433   notifier::ChromeNotifierService::RegisterProfilePrefs(registry);
    434   PepperFlashSettingsManager::RegisterProfilePrefs(registry);
    435   PinnedTabCodec::RegisterProfilePrefs(registry);
    436   PluginsUI::RegisterProfilePrefs(registry);
    437   RegisterAutolaunchUserPrefs(registry);
    438   signin::RegisterProfilePrefs(registry);
    439 #endif
    440 
    441 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
    442   default_apps::RegisterProfilePrefs(registry);
    443 #endif
    444 
    445 #if defined(OS_CHROMEOS)
    446   chromeos::attestation::PlatformVerificationFlow::RegisterProfilePrefs(
    447       registry);
    448   chromeos::first_run::RegisterProfilePrefs(registry);
    449   chromeos::file_system_provider::RegisterProfilePrefs(registry);
    450   chromeos::MultiProfileUserController::RegisterProfilePrefs(registry);
    451   chromeos::Preferences::RegisterProfilePrefs(registry);
    452   chromeos::proxy_config::RegisterProfilePrefs(registry);
    453   chromeos::SAMLOfflineSigninLimiter::RegisterProfilePrefs(registry);
    454   chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry);
    455   chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry);
    456   extensions::EnterprisePlatformKeysPrivateChallengeUserKeyFunction::
    457       RegisterProfilePrefs(registry);
    458   FlagsUI::RegisterProfilePrefs(registry);
    459 #endif
    460 
    461 #if defined(OS_MACOSX)
    462   RegisterBrowserActionsControllerProfilePrefs(registry);
    463 #endif
    464 
    465 #if defined(OS_WIN)
    466   NetworkProfileBubble::RegisterProfilePrefs(registry);
    467 #endif
    468 
    469 #if defined(TOOLKIT_VIEWS)
    470   RegisterBrowserViewProfilePrefs(registry);
    471   RegisterInvertBubbleUserPrefs(registry);
    472 #endif
    473 
    474 #if defined(USE_ASH)
    475   ash::RegisterChromeLauncherUserPrefs(registry);
    476 #endif
    477 
    478   // Prefs registered only for migration (clearing or moving to a new
    479   // key) go here.
    480   registry->RegisterDictionaryPref(
    481       kBackupPref,
    482       new base::DictionaryValue(),
    483       user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
    484 #if !defined(OS_ANDROID)
    485   registry->RegisterStringPref(
    486       kSyncPromoErrorMessage,
    487       std::string(),
    488       user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
    489 #endif
    490 }
    491 
    492 void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
    493   RegisterProfilePrefs(registry);
    494 
    495 #if defined(OS_CHROMEOS)
    496   chromeos::PowerPrefs::RegisterUserProfilePrefs(registry);
    497 #endif
    498 }
    499 
    500 void RegisterScreenshotPrefs(PrefRegistrySimple* registry) {
    501   registry->RegisterBooleanPref(prefs::kDisableScreenshots, false);
    502 }
    503 
    504 #if defined(OS_CHROMEOS)
    505 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
    506   RegisterProfilePrefs(registry);
    507 
    508   chromeos::PowerPrefs::RegisterLoginProfilePrefs(registry);
    509 }
    510 #endif
    511 
    512 void MigrateUserPrefs(Profile* profile) {
    513   PrefService* prefs = profile->GetPrefs();
    514 
    515   // Cleanup prefs from now-removed protector feature.
    516   prefs->ClearPref(kBackupPref);
    517 
    518 #if !defined(OS_ANDROID)
    519   // Cleanup now-removed sync promo error message preference.
    520   // TODO(fdoray): Remove this when it's safe to do so (crbug.com/268442).
    521   prefs->ClearPref(kSyncPromoErrorMessage);
    522 #endif
    523 
    524   PromoResourceService::MigrateUserPrefs(prefs);
    525   TranslatePrefs::MigrateUserPrefs(prefs, prefs::kAcceptLanguages);
    526 
    527 #if defined(ENABLE_MANAGED_USERS)
    528   SupervisedUserService::MigrateUserPrefs(prefs);
    529 #endif
    530 
    531 #if defined(OS_MACOSX) && !defined(OS_IOS)
    532   autofill::AutofillManager::MigrateUserPrefs(prefs);
    533 #endif  // defined(OS_MACOSX) && !defined(OS_IOS)
    534 }
    535 
    536 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) {
    537   // Copy pref values which have been migrated to user_prefs from local_state,
    538   // or remove them from local_state outright, if copying is not required.
    539   int current_version =
    540       local_state->GetInteger(prefs::kMultipleProfilePrefMigration);
    541   PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>(
    542       local_state->DeprecatedGetPrefRegistry());
    543 
    544   if (!(current_version & DNS_PREFS)) {
    545     registry->RegisterListPref(prefs::kDnsStartupPrefetchList);
    546     local_state->ClearPref(prefs::kDnsStartupPrefetchList);
    547 
    548     registry->RegisterListPref(prefs::kDnsHostReferralList);
    549     local_state->ClearPref(prefs::kDnsHostReferralList);
    550 
    551     current_version |= DNS_PREFS;
    552     local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
    553                             current_version);
    554   }
    555 
    556   PrefService* user_prefs = profile->GetPrefs();
    557   if (!(current_version & WINDOWS_PREFS)) {
    558     registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
    559     if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) {
    560       const PrefService::Preference* pref =
    561           local_state->FindPreference(prefs::kBrowserWindowPlacement);
    562       DCHECK(pref);
    563       user_prefs->Set(prefs::kBrowserWindowPlacement,
    564                       *(pref->GetValue()));
    565     }
    566     local_state->ClearPref(prefs::kBrowserWindowPlacement);
    567 
    568     current_version |= WINDOWS_PREFS;
    569     local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
    570                             current_version);
    571   }
    572 
    573   if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) {
    574     registry->RegisterStringPref(prefs::kLastKnownGoogleURL,
    575                                  GoogleURLTracker::kDefaultGoogleHomepage);
    576     if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) {
    577       user_prefs->SetString(prefs::kLastKnownGoogleURL,
    578                             local_state->GetString(prefs::kLastKnownGoogleURL));
    579     }
    580     local_state->ClearPref(prefs::kLastKnownGoogleURL);
    581 
    582     registry->RegisterStringPref(prefs::kLastPromptedGoogleURL,
    583                                  std::string());
    584     if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) {
    585       user_prefs->SetString(
    586           prefs::kLastPromptedGoogleURL,
    587           local_state->GetString(prefs::kLastPromptedGoogleURL));
    588     }
    589     local_state->ClearPref(prefs::kLastPromptedGoogleURL);
    590 
    591     current_version |= GOOGLE_URL_TRACKER_PREFS;
    592     local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
    593                             current_version);
    594   }
    595 
    596 #if defined(OS_CHROMEOS)
    597   chromeos::default_pinned_apps_field_trial::MigratePrefs(local_state);
    598 #endif
    599 
    600 #if defined(TOOLKIT_VIEWS)
    601   MigrateBrowserTabStripPrefs(local_state);
    602 #endif
    603 }
    604 
    605 }  // namespace chrome
    606