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.
5 #include "chrome/browser/prefs/browser_prefs.h"
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/apps/shortcut_manager.h"
14 #include "chrome/browser/background/background_mode_manager.h"
15 #include "chrome/browser/bookmarks/bookmark_prompt_prefs.h"
16 #include "chrome/browser/bookmarks/bookmark_utils.h"
17 #include "chrome/browser/browser_process_impl.h"
18 #include "chrome/browser/browser_shutdown.h"
19 #include "chrome/browser/chrome_content_browser_client.h"
20 #include "chrome/browser/component_updater/recovery_component_installer.h"
21 #include "chrome/browser/content_settings/host_content_settings_map.h"
22 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
23 #include "chrome/browser/devtools/devtools_window.h"
24 #include "chrome/browser/download/download_prefs.h"
25 #include "chrome/browser/extensions/activity_log/activity_log.h"
26 #include "chrome/browser/extensions/api/commands/command_service.h"
27 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
28 #include "chrome/browser/extensions/extension_prefs.h"
29 #include "chrome/browser/extensions/extension_web_ui.h"
30 #include "chrome/browser/extensions/external_component_loader.h"
31 #include "chrome/browser/external_protocol/external_protocol_handler.h"
32 #include "chrome/browser/first_run/first_run.h"
33 #include "chrome/browser/geolocation/geolocation_prefs.h"
34 #include "chrome/browser/google/google_url_tracker.h"
35 #include "chrome/browser/google/google_url_tracker_factory.h"
36 #include "chrome/browser/gpu/gl_string_manager.h"
37 #include "chrome/browser/gpu/gpu_mode_manager.h"
38 #include "chrome/browser/intranet_redirect_detector.h"
39 #include "chrome/browser/io_thread.h"
40 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
41 #include "chrome/browser/media/media_device_id_salt.h"
42 #include "chrome/browser/media/media_stream_devices_controller.h"
43 #include "chrome/browser/metrics/metrics_log.h"
44 #include "chrome/browser/metrics/metrics_service.h"
45 #include "chrome/browser/metrics/variations/variations_service.h"
46 #include "chrome/browser/net/http_server_properties_manager.h"
47 #include "chrome/browser/net/net_pref_observer.h"
48 #include "chrome/browser/net/predictor.h"
49 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
50 #include "chrome/browser/net/ssl_config_service_manager.h"
51 #include "chrome/browser/network_time/network_time_service.h"
52 #include "chrome/browser/notifications/desktop_notification_service.h"
53 #include "chrome/browser/notifications/notification_prefs_manager.h"
54 #include "chrome/browser/password_manager/password_generation_manager.h"
55 #include "chrome/browser/password_manager/password_manager.h"
56 #include "chrome/browser/pepper_flash_settings_manager.h"
57 #include "chrome/browser/plugins/plugin_finder.h"
58 #include "chrome/browser/prefs/incognito_mode_prefs.h"
59 #include "chrome/browser/prefs/pref_hash_store_impl.h"
60 #include "chrome/browser/prefs/pref_service_syncable.h"
61 #include "chrome/browser/prefs/session_startup_pref.h"
62 #include "chrome/browser/printing/cloud_print/cloud_print_url.h"
63 #include "chrome/browser/printing/print_dialog_cloud.h"
64 #include "chrome/browser/profiles/chrome_version_service.h"
65 #include "chrome/browser/profiles/profile.h"
66 #include "chrome/browser/profiles/profile_impl.h"
67 #include "chrome/browser/profiles/profile_info_cache.h"
68 #include "chrome/browser/profiles/profiles_state.h"
69 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h"
70 #include "chrome/browser/renderer_host/web_cache_manager.h"
71 #include "chrome/browser/search/search.h"
72 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
73 #include "chrome/browser/services/gcm/gcm_profile_service.h"
74 #include "chrome/browser/signin/signin_manager_factory.h"
75 #include "chrome/browser/signin/signin_promo.h"
76 #include "chrome/browser/sync/sync_prefs.h"
77 #include "chrome/browser/task_manager/task_manager.h"
78 #include "chrome/browser/translate/translate_prefs.h"
79 #include "chrome/browser/ui/alternate_error_tab_observer.h"
80 #include "chrome/browser/ui/app_list/app_list_service.h"
81 #include "chrome/browser/ui/browser_ui_prefs.h"
82 #include "chrome/browser/ui/network_profile_bubble.h"
83 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
84 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
85 #include "chrome/browser/ui/startup/autolaunch_prompt.h"
86 #include "chrome/browser/ui/startup/default_browser_prompt.h"
87 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
88 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
89 #include "chrome/browser/ui/webui/flags_ui.h"
90 #include "chrome/browser/ui/webui/instant_ui.h"
91 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
92 #include "chrome/browser/ui/webui/plugins_ui.h"
93 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
94 #include "chrome/browser/upgrade_detector.h"
95 #include "chrome/browser/web_resource/promo_resource_service.h"
96 #include "chrome/common/metrics/caching_permuted_entropy_provider.h"
97 #include "chrome/common/pref_names.h"
98 #include "components/autofill/core/browser/autofill_manager.h"
99 #include "components/user_prefs/pref_registry_syncable.h"
100 #include "content/public/browser/render_process_host.h"
102 #if defined(ENABLE_AUTOFILL_DIALOG)
103 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
106 #if defined(ENABLE_CONFIGURATION_POLICY)
107 #include "chrome/browser/policy/browser_policy_connector.h"
108 #include "components/policy/core/browser/url_blacklist_manager.h"
109 #include "components/policy/core/common/policy_statistics_collector.h"
112 #if defined(ENABLE_MANAGED_USERS)
113 #include "chrome/browser/managed_mode/managed_user_service.h"
114 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
115 #include "chrome/browser/managed_mode/managed_user_sync_service.h"
118 #if defined(ENABLE_MDNS)
119 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui.h"
122 #if defined(ENABLE_PLUGIN_INSTALLATION)
123 #include "chrome/browser/plugins/plugins_resource_service.h"
126 #if defined(OS_ANDROID)
127 #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h"
128 #include "chrome/browser/android/new_tab_page_prefs.h"
129 #include "chrome/browser/ui/webui/ntp/android/promo_handler.h"
131 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
132 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
133 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
136 #if defined(OS_CHROMEOS)
137 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
138 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
139 #include "chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h"
140 #include "chrome/browser/chromeos/customization_document.h"
141 #include "chrome/browser/chromeos/display/display_preferences.h"
142 #include "chrome/browser/chromeos/extensions/echo_private_api.h"
143 #include "chrome/browser/chromeos/first_run/first_run.h"
144 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h"
145 #include "chrome/browser/chromeos/login/login_utils.h"
146 #include "chrome/browser/chromeos/login/multi_profile_first_run_notification.h"
147 #include "chrome/browser/chromeos/login/multi_profile_user_controller.h"
148 #include "chrome/browser/chromeos/login/startup_utils.h"
149 #include "chrome/browser/chromeos/login/user_image_manager.h"
150 #include "chrome/browser/chromeos/login/user_image_sync_observer.h"
151 #include "chrome/browser/chromeos/login/user_manager.h"
152 #include "chrome/browser/chromeos/login/wallpaper_manager.h"
153 #include "chrome/browser/chromeos/net/proxy_config_handler.h"
154 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
155 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
156 #include "chrome/browser/chromeos/policy/device_status_collector.h"
157 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
158 #include "chrome/browser/chromeos/power/power_prefs.h"
159 #include "chrome/browser/chromeos/preferences.h"
160 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
161 #include "chrome/browser/chromeos/settings/device_settings_cache.h"
162 #include "chrome/browser/chromeos/status/data_promo_notification.h"
163 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
164 #include "chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h"
165 #include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h"
166 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
168 #include "chrome/browser/extensions/default_apps.h"
171 #if defined(OS_MACOSX)
172 #include "chrome/browser/ui/cocoa/confirm_quit.h"
173 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller_prefs.h"
177 #include "chrome/browser/apps/app_launch_for_metro_restart_win.h"
180 #if defined(TOOLKIT_VIEWS)
181 #include "chrome/browser/ui/browser_view_prefs.h"
182 #include "chrome/browser/ui/tabs/tab_strip_layout_type_prefs.h"
185 #if defined(TOOLKIT_GTK)
186 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
190 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
195 enum MigratedPreferences
{
198 WINDOWS_PREFS
= 1 << 1,
199 GOOGLE_URL_TRACKER_PREFS
= 1 << 2,
202 // A previous feature (see
203 // chrome/browser/protector/protected_prefs_watcher.cc in source
204 // control history) used this string as a prefix for various prefs it
205 // registered. We keep it here for now to clear out those old prefs in
207 const char kBackupPref
[] = "backup";
209 #if !defined(OS_ANDROID)
210 // The sync promo error message preference has been removed; this pref will
211 // be cleared from user data.
212 const char kSyncPromoErrorMessage
[] = "sync_promo.error_message";
219 void RegisterLocalState(PrefRegistrySimple
* registry
) {
220 // Prefs in Local State.
221 registry
->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration
, 0);
223 // Please keep this list alphabetized.
224 AppListService::RegisterPrefs(registry
);
225 browser_shutdown::RegisterPrefs(registry
);
226 BrowserProcessImpl::RegisterPrefs(registry
);
227 chrome_variations::VariationsService::RegisterPrefs(registry
);
228 component_updater::RegisterPrefsForRecoveryComponent(registry
);
229 ExternalProtocolHandler::RegisterPrefs(registry
);
230 FlagsUI::RegisterPrefs(registry
);
231 geolocation::RegisterPrefs(registry
);
232 GLStringManager::RegisterPrefs(registry
);
233 GpuModeManager::RegisterPrefs(registry
);
234 IntranetRedirectDetector::RegisterPrefs(registry
);
235 IOThread::RegisterPrefs(registry
);
236 KeywordEditorController::RegisterPrefs(registry
);
237 MetricsLog::RegisterPrefs(registry
);
238 MetricsService::RegisterPrefs(registry
);
239 metrics::CachingPermutedEntropyProvider::RegisterPrefs(registry
);
240 PrefHashStoreImpl::RegisterPrefs(registry
);
241 PrefProxyConfigTrackerImpl::RegisterPrefs(registry
);
242 ProfileInfoCache::RegisterPrefs(registry
);
243 profiles::RegisterPrefs(registry
);
244 PromoResourceService::RegisterPrefs(registry
);
245 RegisterScreenshotPrefs(registry
);
246 SigninManagerFactory::RegisterPrefs(registry
);
247 SSLConfigServiceManager::RegisterPrefs(registry
);
248 UpgradeDetector::RegisterPrefs(registry
);
249 WebCacheManager::RegisterPrefs(registry
);
251 #if defined(ENABLE_AUTOFILL_DIALOG)
252 autofill::AutofillDialogController::RegisterPrefs(registry
);
255 #if defined(ENABLE_CONFIGURATION_POLICY)
256 policy::BrowserPolicyConnector::RegisterPrefs(registry
);
257 policy::PolicyStatisticsCollector::RegisterPrefs(registry
);
260 #if defined(ENABLE_NOTIFICATIONS)
261 NotificationPrefsManager::RegisterPrefs(registry
);
264 #if defined(ENABLE_PLUGINS)
265 PluginFinder::RegisterPrefs(registry
);
268 #if defined(ENABLE_PLUGIN_INSTALLATION)
269 PluginsResourceService::RegisterPrefs(registry
);
272 #if defined(ENABLE_TASK_MANAGER)
273 TaskManager::RegisterPrefs(registry
);
274 #endif // defined(ENABLE_TASK_MANAGER)
276 #if !defined(OS_ANDROID)
277 AutomaticProfileResetterFactory::RegisterPrefs(registry
);
278 BackgroundModeManager::RegisterPrefs(registry
);
279 RegisterBrowserPrefs(registry
);
280 #if !defined(OS_CHROMEOS)
281 RegisterDefaultBrowserPromptPrefs(registry
);
282 #endif // !defined(OS_CHROMEOS)
283 #endif // !defined(OS_ANDROID)
285 #if defined(OS_CHROMEOS)
286 chromeos::AudioDevicesPrefHandlerImpl::RegisterPrefs(registry
);
287 chromeos::ChargerReplacementHandler::RegisterPrefs(registry
);
288 chromeos::DataPromoNotification::RegisterPrefs(registry
);
289 chromeos::DeviceOAuth2TokenService::RegisterPrefs(registry
);
290 chromeos::device_settings_cache::RegisterPrefs(registry
);
291 chromeos::default_pinned_apps_field_trial::RegisterPrefs(registry
);
292 chromeos::language_prefs::RegisterPrefs(registry
);
293 chromeos::KioskAppManager::RegisterPrefs(registry
);
294 chromeos::LoginUtils::RegisterPrefs(registry
);
295 chromeos::MultiProfileUserController::RegisterPrefs(registry
);
296 chromeos::Preferences::RegisterPrefs(registry
);
297 chromeos::proxy_config::RegisterPrefs(registry
);
298 chromeos::RegisterDisplayLocalStatePrefs(registry
);
299 chromeos::ServicesCustomizationDocument::RegisterPrefs(registry
);
300 chromeos::SigninScreenHandler::RegisterPrefs(registry
);
301 chromeos::system::AutomaticRebootManager::RegisterPrefs(registry
);
302 chromeos::UserImageManager::RegisterPrefs(registry
);
303 chromeos::UserManager::RegisterPrefs(registry
);
304 chromeos::WallpaperManager::RegisterPrefs(registry
);
305 chromeos::StartupUtils::RegisterPrefs(registry
);
306 chromeos::echo_offer::RegisterPrefs(registry
);
307 policy::AutoEnrollmentClient::RegisterPrefs(registry
);
308 policy::DeviceCloudPolicyManagerChromeOS::RegisterPrefs(registry
);
309 policy::DeviceStatusCollector::RegisterPrefs(registry
);
310 policy::PolicyCertServiceFactory::RegisterPrefs(registry
);
313 #if defined(OS_MACOSX)
314 confirm_quit::RegisterLocalState(registry
);
318 app_metro_launch::RegisterPrefs(registry
);
319 PasswordManager::RegisterLocalPrefs(registry
);
322 #if defined(TOOLKIT_VIEWS)
323 RegisterBrowserViewPrefs(registry
);
324 RegisterTabStripLayoutTypePrefs(registry
);
328 // Register prefs applicable to all profiles.
329 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
) {
330 TRACE_EVENT0("browser", "chrome::RegisterUserPrefs");
331 // User prefs. Please keep this list alphabetized.
332 AlternateErrorPageTabObserver::RegisterProfilePrefs(registry
);
333 apps::RegisterProfilePrefs(registry
);
334 autofill::AutofillManager::RegisterProfilePrefs(registry
);
335 BookmarkPromptPrefs::RegisterProfilePrefs(registry
);
336 bookmark_utils::RegisterProfilePrefs(registry
);
337 browser_sync::SyncPrefs::RegisterProfilePrefs(registry
);
338 ChromeContentBrowserClient::RegisterProfilePrefs(registry
);
339 ChromeVersionService::RegisterProfilePrefs(registry
);
340 chrome_browser_net::HttpServerPropertiesManager::RegisterProfilePrefs(
342 chrome_browser_net::Predictor::RegisterProfilePrefs(registry
);
343 DownloadPrefs::RegisterProfilePrefs(registry
);
344 extensions::ExtensionPrefs::RegisterProfilePrefs(registry
);
345 extensions::ExternalComponentLoader::RegisterProfilePrefs(registry
);
346 ExtensionWebUI::RegisterProfilePrefs(registry
);
347 HostContentSettingsMap::RegisterProfilePrefs(registry
);
348 IncognitoModePrefs::RegisterProfilePrefs(registry
);
349 InstantUI::RegisterProfilePrefs(registry
);
350 MediaCaptureDevicesDispatcher::RegisterProfilePrefs(registry
);
351 MediaDeviceIDSalt::RegisterProfilePrefs(registry
);
352 MediaStreamDevicesController::RegisterProfilePrefs(registry
);
353 NetPrefObserver::RegisterProfilePrefs(registry
);
354 NetworkTimeService::RegisterProfilePrefs(registry
);
355 NewTabUI::RegisterProfilePrefs(registry
);
356 PasswordGenerationManager::RegisterProfilePrefs(registry
);
357 PasswordManager::RegisterProfilePrefs(registry
);
358 PrefProxyConfigTrackerImpl::RegisterProfilePrefs(registry
);
359 PrefsTabHelper::RegisterProfilePrefs(registry
);
360 Profile::RegisterProfilePrefs(registry
);
361 ProfileImpl::RegisterProfilePrefs(registry
);
362 PromoResourceService::RegisterProfilePrefs(registry
);
363 ProtocolHandlerRegistry::RegisterProfilePrefs(registry
);
364 RegisterBrowserUserPrefs(registry
);
365 SessionStartupPref::RegisterProfilePrefs(registry
);
366 TemplateURLPrepopulateData::RegisterProfilePrefs(registry
);
367 TranslatePrefs::RegisterProfilePrefs(registry
);
368 gcm::GCMProfileService::RegisterProfilePrefs(registry
);
370 #if defined(ENABLE_AUTOFILL_DIALOG)
371 autofill::AutofillDialogController::RegisterProfilePrefs(registry
);
374 #if defined(ENABLE_CONFIGURATION_POLICY)
375 policy::URLBlacklistManager::RegisterProfilePrefs(registry
);
378 #if defined(ENABLE_EXTENSIONS)
379 extensions::ActivityLog::RegisterProfilePrefs(registry
);
382 #if defined(ENABLE_FULL_PRINTING)
383 print_dialog_cloud::RegisterProfilePrefs(registry
);
384 printing::StickySettings::RegisterProfilePrefs(registry
);
385 CloudPrintURL::RegisterProfilePrefs(registry
);
388 #if defined(ENABLE_MANAGED_USERS)
389 ManagedUserService::RegisterProfilePrefs(registry
);
390 ManagedUserSharedSettingsService::RegisterProfilePrefs(registry
);
391 ManagedUserSyncService::RegisterProfilePrefs(registry
);
394 #if defined(ENABLE_MDNS)
395 LocalDiscoveryUI::RegisterProfilePrefs(registry
);
398 #if defined(ENABLE_NOTIFICATIONS)
399 DesktopNotificationService::RegisterProfilePrefs(registry
);
402 #if defined(OS_ANDROID)
403 NewTabPagePrefs::RegisterProfilePrefs(registry
);
404 PartnerBookmarksShim::RegisterProfilePrefs(registry
);
405 PromoHandler::RegisterProfilePrefs(registry
);
407 AppShortcutManager::RegisterProfilePrefs(registry
);
408 autofill::GeneratedCreditCardBubbleController::RegisterUserPrefs(registry
);
409 DeviceIDFetcher::RegisterProfilePrefs(registry
);
410 DevToolsWindow::RegisterProfilePrefs(registry
);
411 extensions::CommandService::RegisterProfilePrefs(registry
);
412 extensions::ExtensionSettingsHandler::RegisterProfilePrefs(registry
);
413 extensions::TabsCaptureVisibleTabFunction::RegisterProfilePrefs(registry
);
414 first_run::RegisterProfilePrefs(registry
);
415 notifier::ChromeNotifierService::RegisterProfilePrefs(registry
);
416 PepperFlashSettingsManager::RegisterProfilePrefs(registry
);
417 PinnedTabCodec::RegisterProfilePrefs(registry
);
418 PluginsUI::RegisterProfilePrefs(registry
);
419 RegisterAutolaunchUserPrefs(registry
);
420 signin::RegisterProfilePrefs(registry
);
423 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
424 default_apps::RegisterProfilePrefs(registry
);
427 #if defined(OS_CHROMEOS)
428 chromeos::attestation::PlatformVerificationFlow::RegisterProfilePrefs(
430 chromeos::first_run::RegisterProfilePrefs(registry
);
431 chromeos::MultiProfileFirstRunNotification::RegisterProfilePrefs(registry
);
432 chromeos::MultiProfileUserController::RegisterProfilePrefs(registry
);
433 chromeos::Preferences::RegisterProfilePrefs(registry
);
434 chromeos::proxy_config::RegisterProfilePrefs(registry
);
435 chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry
);
436 extensions::EnterprisePlatformKeysPrivateChallengeUserKeyFunction::
437 RegisterProfilePrefs(registry
);
438 FlagsUI::RegisterProfilePrefs(registry
);
441 #if defined(OS_MACOSX)
442 RegisterBrowserActionsControllerProfilePrefs(registry
);
446 NetworkProfileBubble::RegisterProfilePrefs(registry
);
449 #if defined(TOOLKIT_VIEWS)
450 RegisterInvertBubbleUserPrefs(registry
);
451 #elif defined(TOOLKIT_GTK)
452 BrowserWindowGtk::RegisterProfilePrefs(registry
);
456 ash::RegisterChromeLauncherUserPrefs(registry
);
459 // Prefs registered only for migration (clearing or moving to a new
461 registry
->RegisterDictionaryPref(
463 new base::DictionaryValue(),
464 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
465 #if !defined(OS_ANDROID)
466 registry
->RegisterStringPref(
467 kSyncPromoErrorMessage
,
469 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
473 void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
) {
474 RegisterProfilePrefs(registry
);
476 #if defined(OS_CHROMEOS)
477 chromeos::PowerPrefs::RegisterUserProfilePrefs(registry
);
481 void RegisterScreenshotPrefs(PrefRegistrySimple
* registry
) {
482 registry
->RegisterBooleanPref(prefs::kDisableScreenshots
, false);
485 #if defined(OS_CHROMEOS)
486 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
) {
487 RegisterProfilePrefs(registry
);
489 chromeos::PowerPrefs::RegisterLoginProfilePrefs(registry
);
493 void MigrateUserPrefs(Profile
* profile
) {
494 PrefService
* prefs
= profile
->GetPrefs();
496 // Cleanup prefs from now-removed protector feature.
497 prefs
->ClearPref(kBackupPref
);
499 #if !defined(OS_ANDROID)
500 // Cleanup now-removed sync promo error message preference.
501 // TODO(fdoray): Remove this when it's safe to do so (crbug.com/268442).
502 prefs
->ClearPref(kSyncPromoErrorMessage
);
505 PromoResourceService::MigrateUserPrefs(prefs
);
506 TranslatePrefs::MigrateUserPrefs(prefs
);
508 #if defined(ENABLE_MANAGED_USERS)
509 ManagedUserService::MigrateUserPrefs(prefs
);
513 void MigrateBrowserPrefs(Profile
* profile
, PrefService
* local_state
) {
514 // Copy pref values which have been migrated to user_prefs from local_state,
515 // or remove them from local_state outright, if copying is not required.
516 int current_version
=
517 local_state
->GetInteger(prefs::kMultipleProfilePrefMigration
);
518 PrefRegistrySimple
* registry
= static_cast<PrefRegistrySimple
*>(
519 local_state
->DeprecatedGetPrefRegistry());
521 if (!(current_version
& DNS_PREFS
)) {
522 registry
->RegisterListPref(prefs::kDnsStartupPrefetchList
);
523 local_state
->ClearPref(prefs::kDnsStartupPrefetchList
);
525 registry
->RegisterListPref(prefs::kDnsHostReferralList
);
526 local_state
->ClearPref(prefs::kDnsHostReferralList
);
528 current_version
|= DNS_PREFS
;
529 local_state
->SetInteger(prefs::kMultipleProfilePrefMigration
,
533 PrefService
* user_prefs
= profile
->GetPrefs();
534 if (!(current_version
& WINDOWS_PREFS
)) {
535 registry
->RegisterDictionaryPref(prefs::kBrowserWindowPlacement
);
536 if (local_state
->HasPrefPath(prefs::kBrowserWindowPlacement
)) {
537 const PrefService::Preference
* pref
=
538 local_state
->FindPreference(prefs::kBrowserWindowPlacement
);
540 user_prefs
->Set(prefs::kBrowserWindowPlacement
,
541 *(pref
->GetValue()));
543 local_state
->ClearPref(prefs::kBrowserWindowPlacement
);
545 current_version
|= WINDOWS_PREFS
;
546 local_state
->SetInteger(prefs::kMultipleProfilePrefMigration
,
550 if (!(current_version
& GOOGLE_URL_TRACKER_PREFS
)) {
551 registry
->RegisterStringPref(prefs::kLastKnownGoogleURL
,
552 GoogleURLTracker::kDefaultGoogleHomepage
);
553 if (local_state
->HasPrefPath(prefs::kLastKnownGoogleURL
)) {
554 user_prefs
->SetString(prefs::kLastKnownGoogleURL
,
555 local_state
->GetString(prefs::kLastKnownGoogleURL
));
557 local_state
->ClearPref(prefs::kLastKnownGoogleURL
);
559 registry
->RegisterStringPref(prefs::kLastPromptedGoogleURL
,
561 if (local_state
->HasPrefPath(prefs::kLastPromptedGoogleURL
)) {
562 user_prefs
->SetString(
563 prefs::kLastPromptedGoogleURL
,
564 local_state
->GetString(prefs::kLastPromptedGoogleURL
));
566 local_state
->ClearPref(prefs::kLastPromptedGoogleURL
);
568 current_version
|= GOOGLE_URL_TRACKER_PREFS
;
569 local_state
->SetInteger(prefs::kMultipleProfilePrefMigration
,
573 #if defined(OS_CHROMEOS)
574 chromeos::default_pinned_apps_field_trial::MigratePrefs(local_state
);
578 } // namespace chrome