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 "apps/prefs.h"
      8 #include "base/debug/trace_event.h"
      9 #include "base/prefs/pref_registry_simple.h"
     10 #include "base/prefs/pref_service.h"
     11 #include "chrome/browser/about_flags.h"
     12 #include "chrome/browser/accessibility/invert_bubble_prefs.h"
     13 #include "chrome/browser/background/background_mode_manager.h"
     14 #include "chrome/browser/bookmarks/bookmark_prompt_prefs.h"
     15 #include "chrome/browser/bookmarks/bookmark_utils.h"
     16 #include "chrome/browser/browser_process_impl.h"
     17 #include "chrome/browser/browser_shutdown.h"
     18 #include "chrome/browser/chrome_content_browser_client.h"
     19 #include "chrome/browser/component_updater/recovery_component_installer.h"
     20 #include "chrome/browser/content_settings/host_content_settings_map.h"
     21 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
     22 #include "chrome/browser/devtools/devtools_window.h"
     23 #include "chrome/browser/download/download_prefs.h"
     24 #include "chrome/browser/extensions/api/commands/command_service.h"
     25 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
     26 #include "chrome/browser/extensions/extension_prefs.h"
     27 #include "chrome/browser/extensions/extension_web_ui.h"
     28 #include "chrome/browser/external_protocol/external_protocol_handler.h"
     29 #include "chrome/browser/first_run/first_run.h"
     30 #include "chrome/browser/geolocation/geolocation_prefs.h"
     31 #include "chrome/browser/google/google_url_tracker.h"
     32 #include "chrome/browser/google/google_url_tracker_factory.h"
     33 #include "chrome/browser/gpu/gl_string_manager.h"
     34 #include "chrome/browser/gpu/gpu_mode_manager.h"
     35 #include "chrome/browser/intranet_redirect_detector.h"
     36 #include "chrome/browser/io_thread.h"
     37 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
     38 #include "chrome/browser/media/media_stream_devices_controller.h"
     39 #include "chrome/browser/metrics/metrics_log.h"
     40 #include "chrome/browser/metrics/metrics_service.h"
     41 #include "chrome/browser/metrics/variations/variations_service.h"
     42 #include "chrome/browser/net/http_server_properties_manager.h"
     43 #include "chrome/browser/net/net_pref_observer.h"
     44 #include "chrome/browser/net/predictor.h"
     45 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
     46 #include "chrome/browser/net/ssl_config_service_manager.h"
     47 #include "chrome/browser/notifications/desktop_notification_service.h"
     48 #include "chrome/browser/notifications/notification_prefs_manager.h"
     49 #include "chrome/browser/password_manager/password_generation_manager.h"
     50 #include "chrome/browser/password_manager/password_manager.h"
     51 #include "chrome/browser/pepper_flash_settings_manager.h"
     52 #include "chrome/browser/plugins/plugin_finder.h"
     53 #include "chrome/browser/prefs/incognito_mode_prefs.h"
     54 #include "chrome/browser/prefs/pref_metrics_service.h"
     55 #include "chrome/browser/prefs/pref_service_syncable.h"
     56 #include "chrome/browser/prefs/session_startup_pref.h"
     57 #include "chrome/browser/printing/cloud_print/cloud_print_url.h"
     58 #include "chrome/browser/printing/print_dialog_cloud.h"
     59 #include "chrome/browser/profiles/chrome_version_service.h"
     60 #include "chrome/browser/profiles/profile.h"
     61 #include "chrome/browser/profiles/profile_impl.h"
     62 #include "chrome/browser/profiles/profile_info_cache.h"
     63 #include "chrome/browser/profiles/profiles_state.h"
     64 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h"
     65 #include "chrome/browser/renderer_host/web_cache_manager.h"
     66 #include "chrome/browser/search/search.h"
     67 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
     68 #include "chrome/browser/signin/signin_manager_factory.h"
     69 #include "chrome/browser/signin/signin_promo.h"
     70 #include "chrome/browser/sync/sync_prefs.h"
     71 #include "chrome/browser/task_manager/task_manager.h"
     72 #include "chrome/browser/translate/translate_prefs.h"
     73 #include "chrome/browser/ui/alternate_error_tab_observer.h"
     74 #include "chrome/browser/ui/app_list/app_list_service.h"
     75 #include "chrome/browser/ui/browser_ui_prefs.h"
     76 #include "chrome/browser/ui/network_profile_bubble.h"
     77 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
     78 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
     79 #include "chrome/browser/ui/startup/autolaunch_prompt.h"
     80 #include "chrome/browser/ui/startup/default_browser_prompt.h"
     81 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
     82 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
     83 #include "chrome/browser/ui/webui/flags_ui.h"
     84 #include "chrome/browser/ui/webui/instant_ui.h"
     85 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
     86 #include "chrome/browser/ui/webui/plugins_ui.h"
     87 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
     88 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
     89 #include "chrome/browser/upgrade_detector.h"
     90 #include "chrome/browser/web_resource/promo_resource_service.h"
     91 #include "chrome/common/metrics/caching_permuted_entropy_provider.h"
     92 #include "chrome/common/pref_names.h"
     93 #include "components/autofill/core/browser/autofill_manager.h"
     94 #include "components/user_prefs/pref_registry_syncable.h"
     95 #include "content/public/browser/render_process_host.h"
     96 
     97 #if defined(ENABLE_AUTOFILL_DIALOG)
     98 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
     99 #endif
    100 
    101 #if defined(ENABLE_CONFIGURATION_POLICY)
    102 #include "chrome/browser/policy/browser_policy_connector.h"
    103 #include "chrome/browser/policy/policy_statistics_collector.h"
    104 #include "chrome/browser/policy/url_blacklist_manager.h"
    105 #endif
    106 
    107 #if defined(ENABLE_MANAGED_USERS)
    108 #include "chrome/browser/managed_mode/managed_user_service.h"
    109 #include "chrome/browser/managed_mode/managed_user_sync_service.h"
    110 #endif
    111 
    112 #if defined(OS_MACOSX)
    113 #include "chrome/browser/ui/cocoa/confirm_quit.h"
    114 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller_prefs.h"
    115 #endif
    116 
    117 #if defined(TOOLKIT_VIEWS)
    118 #include "chrome/browser/ui/browser_view_prefs.h"
    119 #include "chrome/browser/ui/tabs/tab_strip_layout_type_prefs.h"
    120 #endif
    121 
    122 #if defined(TOOLKIT_GTK)
    123 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
    124 #endif
    125 
    126 #if defined(OS_CHROMEOS)
    127 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
    128 #include "chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h"
    129 #include "chrome/browser/chromeos/customization_document.h"
    130 #include "chrome/browser/chromeos/display/display_preferences.h"
    131 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h"
    132 #include "chrome/browser/chromeos/login/login_utils.h"
    133 #include "chrome/browser/chromeos/login/startup_utils.h"
    134 #include "chrome/browser/chromeos/login/user_image_manager.h"
    135 #include "chrome/browser/chromeos/login/user_manager.h"
    136 #include "chrome/browser/chromeos/login/wallpaper_manager.h"
    137 #include "chrome/browser/chromeos/net/proxy_config_handler.h"
    138 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
    139 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
    140 #include "chrome/browser/chromeos/policy/device_status_collector.h"
    141 #include "chrome/browser/chromeos/power/power_prefs.h"
    142 #include "chrome/browser/chromeos/preferences.h"
    143 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
    144 #include "chrome/browser/chromeos/settings/device_settings_cache.h"
    145 #include "chrome/browser/chromeos/status/data_promo_notification.h"
    146 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
    147 #include "chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h"
    148 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
    149 #else
    150 #include "chrome/browser/extensions/default_apps.h"
    151 #endif
    152 
    153 #if defined(USE_ASH)
    154 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
    155 #endif
    156 
    157 #if defined(OS_ANDROID)
    158 #include "chrome/browser/ui/webui/ntp/android/promo_handler.h"
    159 #else
    160 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
    161 #endif
    162 
    163 #if defined(ENABLE_PLUGIN_INSTALLATION)
    164 #include "chrome/browser/plugins/plugins_resource_service.h"
    165 #endif
    166 
    167 namespace {
    168 
    169 enum MigratedPreferences {
    170   NO_PREFS = 0,
    171   DNS_PREFS = 1 << 0,
    172   WINDOWS_PREFS = 1 << 1,
    173   GOOGLE_URL_TRACKER_PREFS = 1 << 2,
    174 };
    175 
    176 // A previous feature (see
    177 // chrome/browser/protector/protected_prefs_watcher.cc in source
    178 // control history) used this string as a prefix for various prefs it
    179 // registered. We keep it here for now to clear out those old prefs in
    180 // MigrateUserPrefs.
    181 const char kBackupPref[] = "backup";
    182 
    183 // Chrome To Mobile has been removed; this pref will be cleared from user data.
    184 const char kChromeToMobilePref[] = "chrome_to_mobile.device_list";
    185 
    186 #if !defined(OS_ANDROID)
    187 // The sync promo error message preference has been removed; this pref will
    188 // be cleared from user data.
    189 const char kSyncPromoErrorMessage[] = "sync_promo.error_message";
    190 #endif
    191 
    192 }  // namespace
    193 
    194 namespace chrome {
    195 
    196 void RegisterLocalState(PrefRegistrySimple* registry) {
    197   // Prefs in Local State.
    198   registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0);
    199 
    200   // Please keep this list alphabetized.
    201   AppListService::RegisterPrefs(registry);
    202   apps::RegisterPrefs(registry);
    203   browser_shutdown::RegisterPrefs(registry);
    204   BrowserProcessImpl::RegisterPrefs(registry);
    205   RegisterScreenshotPrefs(registry);
    206   ExternalProtocolHandler::RegisterPrefs(registry);
    207   FlagsUI::RegisterPrefs(registry);
    208   geolocation::RegisterPrefs(registry);
    209   GLStringManager::RegisterPrefs(registry);
    210   GpuModeManager::RegisterPrefs(registry);
    211   IntranetRedirectDetector::RegisterPrefs(registry);
    212   IOThread::RegisterPrefs(registry);
    213   KeywordEditorController::RegisterPrefs(registry);
    214   MetricsLog::RegisterPrefs(registry);
    215   MetricsService::RegisterPrefs(registry);
    216   metrics::CachingPermutedEntropyProvider::RegisterPrefs(registry);
    217   PrefMetricsService::RegisterPrefs(registry);
    218   PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
    219   ProfileInfoCache::RegisterPrefs(registry);
    220   profiles::RegisterPrefs(registry);
    221   PromoResourceService::RegisterPrefs(registry);
    222   RegisterPrefsForRecoveryComponent(registry);
    223   SigninManagerFactory::RegisterPrefs(registry);
    224   SSLConfigServiceManager::RegisterPrefs(registry);
    225   UpgradeDetector::RegisterPrefs(registry);
    226   WebCacheManager::RegisterPrefs(registry);
    227   chrome_variations::VariationsService::RegisterPrefs(registry);
    228 
    229 #if defined(ENABLE_PLUGINS)
    230   PluginFinder::RegisterPrefs(registry);
    231 #endif
    232 
    233 #if defined(ENABLE_PLUGIN_INSTALLATION)
    234   PluginsResourceService::RegisterPrefs(registry);
    235 #endif
    236 
    237 #if defined(ENABLE_CONFIGURATION_POLICY)
    238   policy::BrowserPolicyConnector::RegisterPrefs(registry);
    239   policy::PolicyStatisticsCollector::RegisterPrefs(registry);
    240 #endif
    241 
    242 #if defined(ENABLE_NOTIFICATIONS)
    243   NotificationPrefsManager::RegisterPrefs(registry);
    244 #endif
    245 
    246 #if defined(ENABLE_TASK_MANAGER)
    247   TaskManager::RegisterPrefs(registry);
    248 #endif  // defined(ENABLE_TASK_MANAGER)
    249 
    250 #if defined(TOOLKIT_VIEWS)
    251   RegisterBrowserViewPrefs(registry);
    252   RegisterTabStripLayoutTypePrefs(registry);
    253 #endif
    254 
    255 #if !defined(OS_ANDROID)
    256   BackgroundModeManager::RegisterPrefs(registry);
    257   RegisterBrowserPrefs(registry);
    258   RegisterDefaultBrowserPromptPrefs(registry);
    259 #endif
    260 
    261 #if defined(OS_CHROMEOS)
    262   chromeos::AudioDevicesPrefHandlerImpl::RegisterPrefs(registry);
    263   chromeos::DataPromoNotification::RegisterPrefs(registry);
    264   chromeos::DeviceOAuth2TokenService::RegisterPrefs(registry);
    265   chromeos::device_settings_cache::RegisterPrefs(registry);
    266   chromeos::default_pinned_apps_field_trial::RegisterPrefs(registry);
    267   chromeos::language_prefs::RegisterPrefs(registry);
    268   chromeos::KioskAppManager::RegisterPrefs(registry);
    269   chromeos::LoginUtils::RegisterPrefs(registry);
    270   chromeos::Preferences::RegisterPrefs(registry);
    271   chromeos::proxy_config::RegisterPrefs(registry);
    272   chromeos::RegisterDisplayLocalStatePrefs(registry);
    273   chromeos::ServicesCustomizationDocument::RegisterPrefs(registry);
    274   chromeos::SigninScreenHandler::RegisterPrefs(registry);
    275   chromeos::system::AutomaticRebootManager::RegisterPrefs(registry);
    276   chromeos::UserImageManager::RegisterPrefs(registry);
    277   chromeos::UserManager::RegisterPrefs(registry);
    278   chromeos::WallpaperManager::RegisterPrefs(registry);
    279   chromeos::StartupUtils::RegisterPrefs(registry);
    280   policy::AutoEnrollmentClient::RegisterPrefs(registry);
    281   policy::DeviceCloudPolicyManagerChromeOS::RegisterPrefs(registry);
    282   policy::DeviceStatusCollector::RegisterPrefs(registry);
    283 #endif
    284 
    285 #if defined(OS_MACOSX)
    286   confirm_quit::RegisterLocalState(registry);
    287 #endif
    288 }
    289 
    290 // Register prefs applicable to all profiles.
    291 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
    292   TRACE_EVENT0("browser", "chrome::RegisterUserPrefs");
    293   // User prefs. Please keep this list alphabetized.
    294   AlternateErrorPageTabObserver::RegisterProfilePrefs(registry);
    295   apps::RegisterProfilePrefs(registry);
    296   autofill::AutofillManager::RegisterProfilePrefs(registry);
    297 #if !defined(OS_ANDROID)
    298   autofill::GeneratedCreditCardBubbleController::RegisterUserPrefs(registry);
    299 #endif
    300   BookmarkPromptPrefs::RegisterProfilePrefs(registry);
    301   bookmark_utils::RegisterProfilePrefs(registry);
    302   browser_sync::SyncPrefs::RegisterProfilePrefs(registry);
    303   ChromeContentBrowserClient::RegisterProfilePrefs(registry);
    304   ChromeVersionService::RegisterProfilePrefs(registry);
    305   chrome_browser_net::HttpServerPropertiesManager::RegisterProfilePrefs(
    306       registry);
    307   chrome_browser_net::Predictor::RegisterProfilePrefs(registry);
    308   DownloadPrefs::RegisterProfilePrefs(registry);
    309   extensions::ExtensionPrefs::RegisterProfilePrefs(registry);
    310   ExtensionWebUI::RegisterProfilePrefs(registry);
    311   HostContentSettingsMap::RegisterProfilePrefs(registry);
    312   IncognitoModePrefs::RegisterProfilePrefs(registry);
    313   InstantUI::RegisterProfilePrefs(registry);
    314   MediaCaptureDevicesDispatcher::RegisterProfilePrefs(registry);
    315   MediaStreamDevicesController::RegisterProfilePrefs(registry);
    316   NetPrefObserver::RegisterProfilePrefs(registry);
    317   NewTabUI::RegisterProfilePrefs(registry);
    318   PasswordGenerationManager::RegisterProfilePrefs(registry);
    319   PasswordManager::RegisterProfilePrefs(registry);
    320   PrefProxyConfigTrackerImpl::RegisterProfilePrefs(registry);
    321   PrefsTabHelper::RegisterProfilePrefs(registry);
    322   Profile::RegisterProfilePrefs(registry);
    323   ProfileImpl::RegisterProfilePrefs(registry);
    324   PromoResourceService::RegisterProfilePrefs(registry);
    325   ProtocolHandlerRegistry::RegisterProfilePrefs(registry);
    326   RegisterBrowserUserPrefs(registry);
    327   SessionStartupPref::RegisterProfilePrefs(registry);
    328   TemplateURLPrepopulateData::RegisterProfilePrefs(registry);
    329   TranslatePrefs::RegisterProfilePrefs(registry);
    330 
    331 #if defined(ENABLE_AUTOFILL_DIALOG)
    332   autofill::AutofillDialogController::RegisterProfilePrefs(registry);
    333 #endif
    334 
    335 #if defined(ENABLE_CONFIGURATION_POLICY)
    336   policy::URLBlacklistManager::RegisterProfilePrefs(registry);
    337 #endif
    338 
    339 #if defined(ENABLE_MANAGED_USERS)
    340   ManagedUserService::RegisterProfilePrefs(registry);
    341   ManagedUserSyncService::RegisterProfilePrefs(registry);
    342 #endif
    343 
    344 #if defined(ENABLE_NOTIFICATIONS)
    345   DesktopNotificationService::RegisterProfilePrefs(registry);
    346 #endif
    347 
    348 #if defined(TOOLKIT_VIEWS)
    349   RegisterInvertBubbleUserPrefs(registry);
    350 #elif defined(TOOLKIT_GTK)
    351   BrowserWindowGtk::RegisterProfilePrefs(registry);
    352 #endif
    353 
    354 #if defined(ENABLE_FULL_PRINTING)
    355   print_dialog_cloud::RegisterProfilePrefs(registry);
    356   printing::StickySettings::RegisterProfilePrefs(registry);
    357   CloudPrintURL::RegisterProfilePrefs(registry);
    358 #endif
    359 
    360 #if defined(OS_ANDROID)
    361   PromoHandler::RegisterProfilePrefs(registry);
    362 #endif
    363 
    364 #if defined(USE_ASH)
    365   ash::RegisterChromeLauncherUserPrefs(registry);
    366 #endif
    367 
    368 #if !defined(OS_ANDROID)
    369   DeviceIDFetcher::RegisterProfilePrefs(registry);
    370   DevToolsWindow::RegisterProfilePrefs(registry);
    371   extensions::CommandService::RegisterProfilePrefs(registry);
    372   extensions::ExtensionSettingsHandler::RegisterProfilePrefs(registry);
    373   extensions::TabsCaptureVisibleTabFunction::RegisterProfilePrefs(registry);
    374   first_run::RegisterProfilePrefs(registry);
    375   PepperFlashSettingsManager::RegisterProfilePrefs(registry);
    376   PinnedTabCodec::RegisterProfilePrefs(registry);
    377   PluginsUI::RegisterProfilePrefs(registry);
    378   RegisterAutolaunchUserPrefs(registry);
    379   signin::RegisterProfilePrefs(registry);
    380 #endif
    381 
    382 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
    383   default_apps::RegisterProfilePrefs(registry);
    384 #endif
    385 
    386 #if defined(OS_CHROMEOS)
    387   chromeos::Preferences::RegisterProfilePrefs(registry);
    388   chromeos::proxy_config::RegisterProfilePrefs(registry);
    389   extensions::EnterprisePlatformKeysPrivateChallengeUserKeyFunction::
    390       RegisterProfilePrefs(registry);
    391   FlagsUI::RegisterProfilePrefs(registry);
    392 #endif
    393 
    394 #if defined(OS_WIN)
    395   NetworkProfileBubble::RegisterProfilePrefs(registry);
    396 #endif
    397 
    398 #if defined(OS_MACOSX)
    399   RegisterBrowserActionsControllerProfilePrefs(registry);
    400 #endif
    401 
    402   // Prefs registered only for migration (clearing or moving to a new
    403   // key) go here.
    404   registry->RegisterDictionaryPref(
    405       kBackupPref,
    406       new DictionaryValue(),
    407       user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
    408   registry->RegisterListPref(
    409       kChromeToMobilePref,
    410       user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
    411 #if !defined(OS_ANDROID)
    412   registry->RegisterStringPref(
    413       kSyncPromoErrorMessage,
    414       std::string(),
    415       user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
    416 #endif
    417 }
    418 
    419 void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
    420   RegisterProfilePrefs(registry);
    421 
    422 #if defined(OS_CHROMEOS)
    423   chromeos::PowerPrefs::RegisterUserProfilePrefs(registry);
    424 #endif
    425 }
    426 
    427 #if defined(OS_CHROMEOS)
    428 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
    429   RegisterProfilePrefs(registry);
    430 
    431   chromeos::PowerPrefs::RegisterLoginProfilePrefs(registry);
    432 }
    433 #endif
    434 
    435 void MigrateUserPrefs(Profile* profile) {
    436   PrefService* prefs = profile->GetPrefs();
    437 
    438   // Cleanup prefs from now-removed protector feature.
    439   prefs->ClearPref(kBackupPref);
    440 
    441   // Cleanup prefs from now-removed Chrome To Mobile feature.
    442   prefs->ClearPref(kChromeToMobilePref);
    443 
    444 #if !defined(OS_ANDROID)
    445   // Cleanup now-removed sync promo error message preference.
    446   // TODO(fdoray): Remove this when it's safe to do so (crbug.com/268442).
    447   prefs->ClearPref(kSyncPromoErrorMessage);
    448 #endif
    449 
    450   PrefsTabHelper::MigrateUserPrefs(prefs);
    451   PromoResourceService::MigrateUserPrefs(prefs);
    452   TranslatePrefs::MigrateUserPrefs(prefs);
    453 }
    454 
    455 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) {
    456   // Copy pref values which have been migrated to user_prefs from local_state,
    457   // or remove them from local_state outright, if copying is not required.
    458   int current_version =
    459       local_state->GetInteger(prefs::kMultipleProfilePrefMigration);
    460   PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>(
    461       local_state->DeprecatedGetPrefRegistry());
    462 
    463   if (!(current_version & DNS_PREFS)) {
    464     registry->RegisterListPref(prefs::kDnsStartupPrefetchList);
    465     local_state->ClearPref(prefs::kDnsStartupPrefetchList);
    466 
    467     registry->RegisterListPref(prefs::kDnsHostReferralList);
    468     local_state->ClearPref(prefs::kDnsHostReferralList);
    469 
    470     current_version |= DNS_PREFS;
    471     local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
    472                             current_version);
    473   }
    474 
    475   PrefService* user_prefs = profile->GetPrefs();
    476   if (!(current_version & WINDOWS_PREFS)) {
    477     registry->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1);
    478     if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) {
    479       user_prefs->SetInteger(
    480           prefs::kDevToolsHSplitLocation,
    481           local_state->GetInteger(prefs::kDevToolsHSplitLocation));
    482     }
    483     local_state->ClearPref(prefs::kDevToolsHSplitLocation);
    484 
    485     registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
    486     if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) {
    487       const PrefService::Preference* pref =
    488           local_state->FindPreference(prefs::kBrowserWindowPlacement);
    489       DCHECK(pref);
    490       user_prefs->Set(prefs::kBrowserWindowPlacement,
    491                       *(pref->GetValue()));
    492     }
    493     local_state->ClearPref(prefs::kBrowserWindowPlacement);
    494 
    495     current_version |= WINDOWS_PREFS;
    496     local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
    497                             current_version);
    498   }
    499 
    500   if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) {
    501     GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnBrowserContext(
    502         profile);
    503     registry->RegisterStringPref(prefs::kLastKnownGoogleURL,
    504                                  GoogleURLTracker::kDefaultGoogleHomepage);
    505     if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) {
    506       user_prefs->SetString(prefs::kLastKnownGoogleURL,
    507                             local_state->GetString(prefs::kLastKnownGoogleURL));
    508     }
    509     local_state->ClearPref(prefs::kLastKnownGoogleURL);
    510 
    511     registry->RegisterStringPref(prefs::kLastPromptedGoogleURL,
    512                                  std::string());
    513     if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) {
    514       user_prefs->SetString(
    515           prefs::kLastPromptedGoogleURL,
    516           local_state->GetString(prefs::kLastPromptedGoogleURL));
    517     }
    518     local_state->ClearPref(prefs::kLastPromptedGoogleURL);
    519 
    520     current_version |= GOOGLE_URL_TRACKER_PREFS;
    521     local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
    522                             current_version);
    523   }
    524 }
    525 
    526 }  // namespace chrome
    527