Revert of Merge apps/pref* to extensions/browser/pref* (patchset #1 of https://codere...
[chromium-blink-merge.git] / chrome / browser / prefs / browser_prefs.cc
blob44ff8a8423e123811857325efa7d944325040642
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 <string>
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/external_protocol/external_protocol_handler.h"
27 #include "chrome/browser/first_run/first_run.h"
28 #include "chrome/browser/geolocation/geolocation_prefs.h"
29 #include "chrome/browser/google/google_url_tracker_factory.h"
30 #include "chrome/browser/gpu/gl_string_manager.h"
31 #include "chrome/browser/gpu/gpu_mode_manager.h"
32 #include "chrome/browser/intranet_redirect_detector.h"
33 #include "chrome/browser/io_thread.h"
34 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
35 #include "chrome/browser/media/media_device_id_salt.h"
36 #include "chrome/browser/media/media_stream_devices_controller.h"
37 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
38 #include "chrome/browser/metrics/variations/variations_service.h"
39 #include "chrome/browser/net/http_server_properties_manager_factory.h"
40 #include "chrome/browser/net/net_pref_observer.h"
41 #include "chrome/browser/net/prediction_options.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/services/gcm/gcm_profile_service.h"
63 #include "chrome/browser/signin/signin_manager_factory.h"
64 #include "chrome/browser/signin/signin_promo.h"
65 #include "chrome/browser/task_manager/task_manager.h"
66 #include "chrome/browser/ui/app_list/app_list_service.h"
67 #include "chrome/browser/ui/browser_ui_prefs.h"
68 #include "chrome/browser/ui/navigation_correction_tab_observer.h"
69 #include "chrome/browser/ui/network_profile_bubble.h"
70 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
71 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
72 #include "chrome/browser/ui/startup/autolaunch_prompt.h"
73 #include "chrome/browser/ui/startup/default_browser_prompt.h"
74 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
75 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
76 #include "chrome/browser/ui/webui/flags_ui.h"
77 #include "chrome/browser/ui/webui/instant_ui.h"
78 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
79 #include "chrome/browser/ui/webui/plugins_ui.h"
80 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
81 #include "chrome/browser/upgrade_detector.h"
82 #include "chrome/browser/web_resource/promo_resource_service.h"
83 #include "chrome/common/pref_names.h"
84 #include "components/autofill/core/browser/autofill_manager.h"
85 #include "components/bookmarks/browser/bookmark_utils.h"
86 #include "components/dom_distiller/core/distilled_page_prefs.h"
87 #include "components/google/core/browser/google_pref_names.h"
88 #include "components/google/core/browser/google_url_tracker.h"
89 #include "components/network_time/network_time_tracker.h"
90 #include "components/password_manager/core/browser/password_manager.h"
91 #include "components/pref_registry/pref_registry_syncable.h"
92 #include "components/rappor/rappor_service.h"
93 #include "components/search_engines/template_url_prepopulate_data.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 "net/http/http_server_properties_manager.h"
99 #if defined(ENABLE_AUTOFILL_DIALOG)
100 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
101 #endif
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
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/extension_web_ui.h"
115 #include "chrome/browser/extensions/launch_util.h"
116 #include "chrome/browser/signin/easy_unlock_service.h"
117 #include "extensions/browser/extension_prefs.h"
118 #endif
120 #if defined(ENABLE_MANAGED_USERS)
121 #include "chrome/browser/supervised_user/supervised_user_service.h"
122 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service.h"
123 #include "chrome/browser/supervised_user/supervised_user_sync_service.h"
124 #endif
126 #if defined(ENABLE_SERVICE_DISCOVERY)
127 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui.h"
128 #endif
130 #if defined(ENABLE_PLUGIN_INSTALLATION)
131 #include "chrome/browser/plugins/plugins_resource_service.h"
132 #endif
134 #if defined(OS_ANDROID)
135 #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h"
136 #include "chrome/browser/android/new_tab_page_prefs.h"
137 #else
138 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
139 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
140 #endif
142 #if defined(OS_CHROMEOS)
143 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
144 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
145 #include "chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h"
146 #include "chrome/browser/chromeos/customization_document.h"
147 #include "chrome/browser/chromeos/display/display_preferences.h"
148 #include "chrome/browser/chromeos/extensions/echo_private_api.h"
149 #include "chrome/browser/chromeos/file_system_provider/service.h"
150 #include "chrome/browser/chromeos/first_run/first_run.h"
151 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h"
152 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h"
153 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
154 #include "chrome/browser/chromeos/login/startup_utils.h"
155 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h"
156 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h"
157 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h"
158 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
159 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
160 #include "chrome/browser/chromeos/net/proxy_config_handler.h"
161 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
162 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
163 #include "chrome/browser/chromeos/policy/consumer_management_service.h"
164 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
165 #include "chrome/browser/chromeos/policy/device_status_collector.h"
166 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
167 #include "chrome/browser/chromeos/power/power_prefs.h"
168 #include "chrome/browser/chromeos/preferences.h"
169 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
170 #include "chrome/browser/chromeos/settings/device_settings_cache.h"
171 #include "chrome/browser/chromeos/status/data_promo_notification.h"
172 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
173 #include "chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h"
174 #include "chrome/browser/extensions/extension_assets_manager_chromeos.h"
175 #include "chrome/browser/metrics/chromeos_metrics_provider.h"
176 #include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h"
177 #include "chrome/browser/ui/webui/chromeos/login/demo_mode_detector.h"
178 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
179 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h"
180 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
181 #include "components/invalidation/invalidator_storage.h"
182 #else
183 #include "chrome/browser/extensions/default_apps.h"
184 #endif
186 #if defined(OS_MACOSX)
187 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h"
188 #include "chrome/browser/ui/cocoa/confirm_quit.h"
189 #endif
191 #if defined(OS_WIN)
192 #include "chrome/browser/apps/app_launch_for_metro_restart_win.h"
193 #include "chrome/browser/component_updater/sw_reporter_installer_win.h"
194 #endif
196 #if defined(TOOLKIT_VIEWS)
197 #include "chrome/browser/ui/browser_view_prefs.h"
198 #endif
200 #if defined(USE_ASH)
201 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
202 #endif
204 namespace {
206 enum MigratedPreferences {
207 NO_PREFS = 0,
208 DNS_PREFS = 1 << 0,
209 WINDOWS_PREFS = 1 << 1,
210 GOOGLE_URL_TRACKER_PREFS = 1 << 2,
213 // A previous feature (see
214 // chrome/browser/protector/protected_prefs_watcher.cc in source
215 // control history) used this string as a prefix for various prefs it
216 // registered. We keep it here for now to clear out those old prefs in
217 // MigrateUserPrefs.
218 const char kBackupPref[] = "backup";
220 #if !defined(OS_ANDROID)
221 // The sync promo error message preference has been removed; this pref will
222 // be cleared from user data.
223 const char kSyncPromoErrorMessage[] = "sync_promo.error_message";
225 // The AutomaticProfileResetter service, which has since been unimplemented,
226 // used this preference to save that the profile reset prompt had already been
227 // shown. We keep the name here for now so that we can clear out legacy values.
228 // TODO(engedy): Remove this and usages in M42 or later. See crbug.com/398813.
229 const char kProfileResetPromptMemento[] = "profile.reset_prompt_memento";
230 #endif
232 } // namespace
234 namespace chrome {
236 void RegisterLocalState(PrefRegistrySimple* registry) {
237 // Prefs in Local State.
238 registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0);
240 // Please keep this list alphabetized.
241 AppListService::RegisterPrefs(registry);
242 browser_shutdown::RegisterPrefs(registry);
243 BrowserProcessImpl::RegisterPrefs(registry);
244 ChromeMetricsServiceClient::RegisterPrefs(registry);
245 chrome_prefs::RegisterPrefs(registry);
246 chrome_variations::VariationsService::RegisterPrefs(registry);
247 component_updater::RegisterPrefsForRecoveryComponent(registry);
248 ExternalProtocolHandler::RegisterPrefs(registry);
249 FlagsUI::RegisterPrefs(registry);
250 geolocation::RegisterPrefs(registry);
251 GLStringManager::RegisterPrefs(registry);
252 GpuModeManager::RegisterPrefs(registry);
253 IntranetRedirectDetector::RegisterPrefs(registry);
254 IOThread::RegisterPrefs(registry);
255 KeywordEditorController::RegisterPrefs(registry);
256 network_time::NetworkTimeTracker::RegisterPrefs(registry);
257 PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
258 ProfileInfoCache::RegisterPrefs(registry);
259 profiles::RegisterPrefs(registry);
260 PromoResourceService::RegisterPrefs(registry);
261 rappor::RapporService::RegisterPrefs(registry);
262 RegisterScreenshotPrefs(registry);
263 SigninManagerFactory::RegisterPrefs(registry);
264 SSLConfigServiceManager::RegisterPrefs(registry);
265 UpgradeDetector::RegisterPrefs(registry);
266 WebCacheManager::RegisterPrefs(registry);
268 #if defined(ENABLE_AUTOFILL_DIALOG)
269 autofill::AutofillDialogController::RegisterPrefs(registry);
270 #endif
272 #if defined(ENABLE_CONFIGURATION_POLICY)
273 policy::BrowserPolicyConnector::RegisterPrefs(registry);
274 policy::PolicyStatisticsCollector::RegisterPrefs(registry);
275 #endif
277 #if defined(ENABLE_NOTIFICATIONS) && !defined(OS_ANDROID)
278 // Android does not use the message center for notifications.
279 MessageCenterNotificationManager::RegisterPrefs(registry);
280 #endif
282 #if defined(ENABLE_PLUGINS)
283 PluginFinder::RegisterPrefs(registry);
284 #endif
286 #if defined(ENABLE_PLUGIN_INSTALLATION)
287 PluginsResourceService::RegisterPrefs(registry);
288 #endif
290 #if defined(ENABLE_TASK_MANAGER)
291 TaskManager::RegisterPrefs(registry);
292 #endif // defined(ENABLE_TASK_MANAGER)
294 #if !defined(OS_ANDROID)
295 BackgroundModeManager::RegisterPrefs(registry);
296 RegisterBrowserPrefs(registry);
297 #if !defined(OS_CHROMEOS)
298 RegisterDefaultBrowserPromptPrefs(registry);
299 #endif // !defined(OS_CHROMEOS)
300 #endif // !defined(OS_ANDROID)
302 #if defined(OS_CHROMEOS)
303 ChromeOSMetricsProvider::RegisterPrefs(registry);
304 chromeos::AudioDevicesPrefHandlerImpl::RegisterPrefs(registry);
305 chromeos::ChargerReplacementHandler::RegisterPrefs(registry);
306 chromeos::ChromeUserManagerImpl::RegisterPrefs(registry);
307 chromeos::DataPromoNotification::RegisterPrefs(registry);
308 chromeos::DeviceOAuth2TokenService::RegisterPrefs(registry);
309 chromeos::device_settings_cache::RegisterPrefs(registry);
310 chromeos::default_pinned_apps_field_trial::RegisterPrefs(registry);
311 chromeos::language_prefs::RegisterPrefs(registry);
312 chromeos::KioskAppManager::RegisterPrefs(registry);
313 chromeos::MultiProfileUserController::RegisterPrefs(registry);
314 chromeos::HIDDetectionScreenHandler::RegisterPrefs(registry);
315 chromeos::DemoModeDetector::RegisterPrefs(registry);
316 chromeos::Preferences::RegisterPrefs(registry);
317 chromeos::proxy_config::RegisterPrefs(registry);
318 chromeos::RegisterDisplayLocalStatePrefs(registry);
319 chromeos::ResetScreenHandler::RegisterPrefs(registry);
320 chromeos::ServicesCustomizationDocument::RegisterPrefs(registry);
321 chromeos::SigninScreenHandler::RegisterPrefs(registry);
322 chromeos::StartupUtils::RegisterPrefs(registry);
323 chromeos::system::AutomaticRebootManager::RegisterPrefs(registry);
324 chromeos::UserImageManager::RegisterPrefs(registry);
325 chromeos::UserSessionManager::RegisterPrefs(registry);
326 chromeos::WallpaperManager::RegisterPrefs(registry);
327 chromeos::echo_offer::RegisterPrefs(registry);
328 extensions::ExtensionAssetsManagerChromeOS::RegisterPrefs(registry);
329 invalidation::InvalidatorStorage::RegisterPrefs(registry);
330 policy::AutoEnrollmentClient::RegisterPrefs(registry);
331 policy::BrowserPolicyConnectorChromeOS::RegisterPrefs(registry);
332 policy::ConsumerManagementService::RegisterPrefs(registry);
333 policy::DeviceCloudPolicyManagerChromeOS::RegisterPrefs(registry);
334 policy::DeviceStatusCollector::RegisterPrefs(registry);
335 policy::PolicyCertServiceFactory::RegisterPrefs(registry);
336 #endif
338 #if defined(OS_MACOSX)
339 confirm_quit::RegisterLocalState(registry);
340 QuitWithAppsController::RegisterPrefs(registry);
341 #endif
343 #if defined(OS_WIN)
344 app_metro_launch::RegisterPrefs(registry);
345 component_updater::RegisterPrefsForSwReporter(registry);
346 password_manager::PasswordManager::RegisterLocalPrefs(registry);
347 #endif
349 #if defined(TOOLKIT_VIEWS)
350 RegisterBrowserViewLocalPrefs(registry);
351 #endif
353 // Preferences registered only for migration (clearing or moving to a new key)
354 // go here.
355 #if !defined(OS_ANDROID)
356 registry->RegisterDictionaryPref(kProfileResetPromptMemento);
357 #endif // !defined(OS_ANDROID)
360 // Register prefs applicable to all profiles.
361 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
362 TRACE_EVENT0("browser", "chrome::RegisterUserPrefs");
363 // User prefs. Please keep this list alphabetized.
364 autofill::AutofillManager::RegisterProfilePrefs(registry);
365 bookmarks::RegisterProfilePrefs(registry);
366 sync_driver::SyncPrefs::RegisterProfilePrefs(registry);
367 ChromeContentBrowserClient::RegisterProfilePrefs(registry);
368 ChromeVersionService::RegisterProfilePrefs(registry);
369 chrome_browser_net::HttpServerPropertiesManagerFactory::RegisterProfilePrefs(
370 registry);
371 chrome_browser_net::Predictor::RegisterProfilePrefs(registry);
372 chrome_browser_net::RegisterPredictionOptionsProfilePrefs(registry);
373 chrome_prefs::RegisterProfilePrefs(registry);
374 dom_distiller::DistilledPagePrefs::RegisterProfilePrefs(registry);
375 DownloadPrefs::RegisterProfilePrefs(registry);
376 gcm::GCMProfileService::RegisterProfilePrefs(registry);
377 HostContentSettingsMap::RegisterProfilePrefs(registry);
378 IncognitoModePrefs::RegisterProfilePrefs(registry);
379 InstantUI::RegisterProfilePrefs(registry);
380 NavigationCorrectionTabObserver::RegisterProfilePrefs(registry);
381 MediaCaptureDevicesDispatcher::RegisterProfilePrefs(registry);
382 MediaDeviceIDSalt::RegisterProfilePrefs(registry);
383 MediaStreamDevicesController::RegisterProfilePrefs(registry);
384 NetPrefObserver::RegisterProfilePrefs(registry);
385 password_manager::PasswordManager::RegisterProfilePrefs(registry);
386 PrefProxyConfigTrackerImpl::RegisterProfilePrefs(registry);
387 PrefsTabHelper::RegisterProfilePrefs(registry);
388 Profile::RegisterProfilePrefs(registry);
389 ProfileImpl::RegisterProfilePrefs(registry);
390 PromoResourceService::RegisterProfilePrefs(registry);
391 ProtocolHandlerRegistry::RegisterProfilePrefs(registry);
392 RegisterBrowserUserPrefs(registry);
393 SessionStartupPref::RegisterProfilePrefs(registry);
394 TemplateURLPrepopulateData::RegisterProfilePrefs(registry);
395 translate::TranslatePrefs::RegisterProfilePrefs(registry);
396 ZeroSuggestProvider::RegisterProfilePrefs(registry);
398 #if defined(ENABLE_AUTOFILL_DIALOG)
399 autofill::AutofillDialogController::RegisterProfilePrefs(registry);
400 #endif
402 #if defined(ENABLE_CONFIGURATION_POLICY)
403 policy::URLBlacklistManager::RegisterProfilePrefs(registry);
404 #endif
406 #if defined(ENABLE_EXTENSIONS)
407 apps::RegisterProfilePrefs(registry);
408 EasyUnlockService::RegisterProfilePrefs(registry);
409 extensions::ActivityLog::RegisterProfilePrefs(registry);
410 extensions::launch_util::RegisterProfilePrefs(registry);
411 ExtensionWebUI::RegisterProfilePrefs(registry);
412 extensions::ExtensionPrefs::RegisterProfilePrefs(registry);
413 #endif
415 #if defined(ENABLE_FULL_PRINTING)
416 print_dialog_cloud::RegisterProfilePrefs(registry);
417 printing::StickySettings::RegisterProfilePrefs(registry);
418 #endif
420 #if defined(ENABLE_MANAGED_USERS)
421 SupervisedUserService::RegisterProfilePrefs(registry);
422 SupervisedUserSharedSettingsService::RegisterProfilePrefs(registry);
423 SupervisedUserSyncService::RegisterProfilePrefs(registry);
424 #endif
426 #if defined(ENABLE_NOTIFICATIONS)
427 DesktopNotificationService::RegisterProfilePrefs(registry);
428 #endif
430 #if defined(ENABLE_SERVICE_DISCOVERY)
431 LocalDiscoveryUI::RegisterProfilePrefs(registry);
432 #endif
434 #if defined(OS_ANDROID)
435 chrome_variations::VariationsService::RegisterProfilePrefs(registry);
436 NewTabPagePrefs::RegisterProfilePrefs(registry);
437 PartnerBookmarksShim::RegisterProfilePrefs(registry);
438 #else
439 AppShortcutManager::RegisterProfilePrefs(registry);
440 autofill::GeneratedCreditCardBubbleController::RegisterUserPrefs(registry);
441 DeviceIDFetcher::RegisterProfilePrefs(registry);
442 DevToolsWindow::RegisterProfilePrefs(registry);
443 DriveAppMapping::RegisterProfilePrefs(registry);
444 extensions::CommandService::RegisterProfilePrefs(registry);
445 extensions::ExtensionSettingsHandler::RegisterProfilePrefs(registry);
446 extensions::TabsCaptureVisibleTabFunction::RegisterProfilePrefs(registry);
447 first_run::RegisterProfilePrefs(registry);
448 NewTabUI::RegisterProfilePrefs(registry);
449 PepperFlashSettingsManager::RegisterProfilePrefs(registry);
450 PinnedTabCodec::RegisterProfilePrefs(registry);
451 PluginsUI::RegisterProfilePrefs(registry);
452 RegisterAutolaunchUserPrefs(registry);
453 signin::RegisterProfilePrefs(registry);
454 #endif
456 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
457 default_apps::RegisterProfilePrefs(registry);
458 #endif
460 #if defined(OS_CHROMEOS)
461 chromeos::attestation::PlatformVerificationFlow::RegisterProfilePrefs(
462 registry);
463 chromeos::first_run::RegisterProfilePrefs(registry);
464 chromeos::file_system_provider::RegisterProfilePrefs(registry);
465 chromeos::MultiProfileUserController::RegisterProfilePrefs(registry);
466 chromeos::Preferences::RegisterProfilePrefs(registry);
467 chromeos::proxy_config::RegisterProfilePrefs(registry);
468 chromeos::SAMLOfflineSigninLimiter::RegisterProfilePrefs(registry);
469 chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry);
470 chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry);
471 extensions::EnterprisePlatformKeysPrivateChallengeUserKeyFunction::
472 RegisterProfilePrefs(registry);
473 FlagsUI::RegisterProfilePrefs(registry);
474 #endif
476 #if defined(OS_WIN)
477 NetworkProfileBubble::RegisterProfilePrefs(registry);
478 #endif
480 #if defined(TOOLKIT_VIEWS)
481 RegisterBrowserViewProfilePrefs(registry);
482 RegisterInvertBubbleUserPrefs(registry);
483 #endif
485 #if defined(USE_ASH)
486 ash::RegisterChromeLauncherUserPrefs(registry);
487 #endif
489 // Preferences registered only for migration (clearing or moving to a new key)
490 // go here.
491 registry->RegisterDictionaryPref(
492 kBackupPref,
493 new base::DictionaryValue(),
494 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
495 #if !defined(OS_ANDROID)
496 registry->RegisterStringPref(
497 kSyncPromoErrorMessage,
498 std::string(),
499 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
500 #endif
503 void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
504 RegisterProfilePrefs(registry);
506 #if defined(OS_CHROMEOS)
507 chromeos::PowerPrefs::RegisterUserProfilePrefs(registry);
508 #endif
511 void RegisterScreenshotPrefs(PrefRegistrySimple* registry) {
512 registry->RegisterBooleanPref(prefs::kDisableScreenshots, false);
515 #if defined(OS_CHROMEOS)
516 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
517 RegisterProfilePrefs(registry);
519 chromeos::PowerPrefs::RegisterLoginProfilePrefs(registry);
521 #endif
523 void MigrateUserPrefs(Profile* profile) {
524 PrefService* prefs = profile->GetPrefs();
526 // Cleanup prefs from now-removed protector feature.
527 prefs->ClearPref(kBackupPref);
529 #if !defined(OS_ANDROID)
530 // Cleanup now-removed sync promo error message preference.
531 // TODO(fdoray): Remove this when it's safe to do so (crbug.com/268442).
532 prefs->ClearPref(kSyncPromoErrorMessage);
533 // Migrate kNetworkPredictionEnabled to kNetworkPredictionOptions when not on
534 // Android. On Android, platform-specific code performs preference migration.
535 // TODO(bnc): https://crbug.com/401970 Remove migration code one year after
536 // M38.
537 chrome_browser_net::MigrateNetworkPredictionUserPrefs(prefs);
538 #endif
540 PromoResourceService::MigrateUserPrefs(prefs);
541 translate::TranslatePrefs::MigrateUserPrefs(prefs, prefs::kAcceptLanguages);
543 #if defined(OS_MACOSX) && !defined(OS_IOS)
544 autofill::AutofillManager::MigrateUserPrefs(prefs);
545 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
548 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) {
549 // Copy pref values which have been migrated to user_prefs from local_state,
550 // or remove them from local_state outright, if copying is not required.
551 int current_version =
552 local_state->GetInteger(prefs::kMultipleProfilePrefMigration);
553 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>(
554 local_state->DeprecatedGetPrefRegistry());
556 if (!(current_version & DNS_PREFS)) {
557 registry->RegisterListPref(prefs::kDnsStartupPrefetchList);
558 local_state->ClearPref(prefs::kDnsStartupPrefetchList);
560 registry->RegisterListPref(prefs::kDnsHostReferralList);
561 local_state->ClearPref(prefs::kDnsHostReferralList);
563 current_version |= DNS_PREFS;
564 local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
565 current_version);
568 PrefService* user_prefs = profile->GetPrefs();
569 if (!(current_version & WINDOWS_PREFS)) {
570 registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
571 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) {
572 const PrefService::Preference* pref =
573 local_state->FindPreference(prefs::kBrowserWindowPlacement);
574 DCHECK(pref);
575 user_prefs->Set(prefs::kBrowserWindowPlacement,
576 *(pref->GetValue()));
578 local_state->ClearPref(prefs::kBrowserWindowPlacement);
580 current_version |= WINDOWS_PREFS;
581 local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
582 current_version);
585 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) {
586 registry->RegisterStringPref(prefs::kLastKnownGoogleURL,
587 GoogleURLTracker::kDefaultGoogleHomepage);
588 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) {
589 user_prefs->SetString(prefs::kLastKnownGoogleURL,
590 local_state->GetString(prefs::kLastKnownGoogleURL));
592 local_state->ClearPref(prefs::kLastKnownGoogleURL);
594 registry->RegisterStringPref(prefs::kLastPromptedGoogleURL,
595 std::string());
596 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) {
597 user_prefs->SetString(
598 prefs::kLastPromptedGoogleURL,
599 local_state->GetString(prefs::kLastPromptedGoogleURL));
601 local_state->ClearPref(prefs::kLastPromptedGoogleURL);
603 current_version |= GOOGLE_URL_TRACKER_PREFS;
604 local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
605 current_version);
608 #if !defined(OS_ANDROID)
609 local_state->ClearPref(kProfileResetPromptMemento);
610 #endif
612 #if defined(OS_CHROMEOS)
613 chromeos::default_pinned_apps_field_trial::MigratePrefs(local_state);
614 #endif
616 #if defined(TOOLKIT_VIEWS)
617 MigrateBrowserTabStripPrefs(local_state);
618 #endif
621 } // namespace chrome