Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / prefs / browser_prefs.cc
blobd0ccbef96a04b382a47223cb8032ee9d1a8edc2e
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/metrics/histogram_macros.h"
10 #include "base/prefs/pref_registry_simple.h"
11 #include "base/prefs/pref_service.h"
12 #include "base/prefs/scoped_user_pref_update.h"
13 #include "base/trace_event/trace_event.h"
14 #include "chrome/browser/about_flags.h"
15 #include "chrome/browser/accessibility/invert_bubble_prefs.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/component_updater/supervised_user_whitelist_installer.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/external_protocol/external_protocol_handler.h"
25 #include "chrome/browser/first_run/first_run.h"
26 #include "chrome/browser/geolocation/geolocation_prefs.h"
27 #include "chrome/browser/gpu/gl_string_manager.h"
28 #include "chrome/browser/gpu/gpu_mode_manager.h"
29 #include "chrome/browser/intranet_redirect_detector.h"
30 #include "chrome/browser/io_thread.h"
31 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
32 #include "chrome/browser/media/media_device_id_salt.h"
33 #include "chrome/browser/media/media_stream_devices_controller.h"
34 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
35 #include "chrome/browser/metrics/variations/variations_service.h"
36 #include "chrome/browser/net/http_server_properties_manager_factory.h"
37 #include "chrome/browser/net/net_pref_observer.h"
38 #include "chrome/browser/net/prediction_options.h"
39 #include "chrome/browser/net/predictor.h"
40 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
41 #include "chrome/browser/net/ssl_config_service_manager.h"
42 #include "chrome/browser/notifications/desktop_notification_service.h"
43 #include "chrome/browser/notifications/extension_welcome_notification.h"
44 #include "chrome/browser/notifications/message_center_notification_manager.h"
45 #include "chrome/browser/pepper_flash_settings_manager.h"
46 #include "chrome/browser/plugins/plugin_finder.h"
47 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
48 #include "chrome/browser/prefs/incognito_mode_prefs.h"
49 #include "chrome/browser/prefs/pref_service_syncable.h"
50 #include "chrome/browser/prefs/session_startup_pref.h"
51 #include "chrome/browser/profiles/chrome_version_service.h"
52 #include "chrome/browser/profiles/profile.h"
53 #include "chrome/browser/profiles/profile_impl.h"
54 #include "chrome/browser/profiles/profile_info_cache.h"
55 #include "chrome/browser/profiles/profiles_state.h"
56 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
57 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h"
58 #include "chrome/browser/search/search.h"
59 #include "chrome/browser/signin/signin_manager_factory.h"
60 #include "chrome/browser/task_manager/task_manager.h"
61 #include "chrome/browser/tracing/chrome_tracing_delegate.h"
62 #include "chrome/browser/ui/app_list/app_list_prefs.h"
63 #include "chrome/browser/ui/app_list/app_list_service.h"
64 #include "chrome/browser/ui/browser_ui_prefs.h"
65 #include "chrome/browser/ui/navigation_correction_tab_observer.h"
66 #include "chrome/browser/ui/network_profile_bubble.h"
67 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
68 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
69 #include "chrome/browser/ui/startup/autolaunch_prompt.h"
70 #include "chrome/browser/ui/startup/default_browser_prompt.h"
71 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
72 #include "chrome/browser/ui/webui/flags_ui.h"
73 #include "chrome/browser/ui/webui/instant_ui.h"
74 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
75 #include "chrome/browser/ui/webui/plugins_ui.h"
76 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
77 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
78 #include "chrome/browser/upgrade_detector.h"
79 #include "chrome/browser/web_resource/promo_resource_service.h"
80 #include "chrome/common/pref_names.h"
81 #include "components/autofill/core/browser/autofill_manager.h"
82 #include "components/content_settings/core/browser/host_content_settings_map.h"
83 #include "components/dom_distiller/core/distilled_page_prefs.h"
84 #include "components/enhanced_bookmarks/bookmark_server_cluster_service.h"
85 #include "components/gcm_driver/gcm_channel_status_syncer.h"
86 #include "components/network_time/network_time_tracker.h"
87 #include "components/omnibox/browser/zero_suggest_provider.h"
88 #include "components/password_manager/core/browser/password_manager.h"
89 #include "components/pref_registry/pref_registry_syncable.h"
90 #include "components/rappor/rappor_service.h"
91 #include "components/search_engines/template_url_prepopulate_data.h"
92 #include "components/sync_driver/sync_prefs.h"
93 #include "components/translate/core/browser/translate_prefs.h"
94 #include "content/public/browser/render_process_host.h"
95 #include "net/http/http_server_properties_manager.h"
97 #if defined(ENABLE_AUTOFILL_DIALOG)
98 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
99 #endif
101 #if defined(ENABLE_BACKGROUND)
102 #include "chrome/browser/background/background_mode_manager.h"
103 #endif
105 #if defined(ENABLE_CONFIGURATION_POLICY)
106 #include "components/policy/core/browser/browser_policy_connector.h"
107 #include "components/policy/core/browser/url_blacklist_manager.h"
108 #include "components/policy/core/common/policy_statistics_collector.h"
109 #endif
111 #if defined(ENABLE_EXTENSIONS)
112 #include "chrome/browser/accessibility/animation_policy_prefs.h"
113 #include "chrome/browser/apps/drive/drive_app_mapping.h"
114 #include "chrome/browser/apps/shortcut_manager.h"
115 #include "chrome/browser/extensions/activity_log/activity_log.h"
116 #include "chrome/browser/extensions/api/commands/command_service.h"
117 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
118 #include "chrome/browser/extensions/extension_web_ui.h"
119 #include "chrome/browser/extensions/launch_util.h"
120 #include "chrome/browser/signin/easy_unlock_service.h"
121 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
122 #include "extensions/browser/extension_prefs.h"
123 #if !defined(OS_ANDROID) && !defined(OS_IOS)
124 #include "chrome/browser/extensions/api/copresence/copresence_api.h"
125 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
126 #endif
127 #endif // defined(ENABLE_EXTENSIONS)
129 #if defined(ENABLE_PLUGIN_INSTALLATION)
130 #include "chrome/browser/plugins/plugins_resource_service.h"
131 #endif
133 #if defined(ENABLE_SUPERVISED_USERS)
134 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h"
135 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.h"
136 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
137 #include "chrome/browser/supervised_user/supervised_user_service.h"
138 #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h"
139 #endif
141 #if defined(ENABLE_SERVICE_DISCOVERY)
142 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui.h"
143 #endif
145 #if defined(OS_ANDROID)
146 #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h"
147 #include "chrome/browser/android/new_tab_page_prefs.h"
148 #else
149 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
150 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
151 #include "chrome/browser/ui/startup/startup_browser_creator.h"
152 #endif
154 #if !defined(OS_ANDROID) && !defined(OS_IOS)
155 #include "chrome/browser/signin/signin_promo.h"
156 #include "chrome/browser/ui/webui/foreign_session_handler.h"
157 #endif
159 #if defined(OS_CHROMEOS)
160 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
161 #include "chrome/browser/chromeos/customization/customization_document.h"
162 #include "chrome/browser/chromeos/display/display_preferences.h"
163 #include "chrome/browser/chromeos/extensions/echo_private_api.h"
164 #include "chrome/browser/chromeos/file_system_provider/registry.h"
165 #include "chrome/browser/chromeos/first_run/first_run.h"
166 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h"
167 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
168 #include "chrome/browser/chromeos/login/startup_utils.h"
169 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h"
170 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h"
171 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h"
172 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
173 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
174 #include "chrome/browser/chromeos/net/proxy_config_handler.h"
175 #include "chrome/browser/chromeos/platform_keys/key_permissions.h"
176 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
177 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
178 #include "chrome/browser/chromeos/policy/consumer_management_service.h"
179 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
180 #include "chrome/browser/chromeos/policy/device_status_collector.h"
181 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
182 #include "chrome/browser/chromeos/power/power_prefs.h"
183 #include "chrome/browser/chromeos/preferences.h"
184 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
185 #include "chrome/browser/chromeos/settings/device_settings_cache.h"
186 #include "chrome/browser/chromeos/status/data_promo_notification.h"
187 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
188 #include "chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h"
189 #include "chrome/browser/extensions/extension_assets_manager_chromeos.h"
190 #include "chrome/browser/media/protected_media_identifier_permission_context.h"
191 #include "chrome/browser/metrics/chromeos_metrics_provider.h"
192 #include "chrome/browser/ui/webui/chromeos/login/demo_mode_detector.h"
193 #include "chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h"
194 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
195 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h"
196 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
197 #include "chromeos/audio/audio_devices_pref_handler_impl.h"
198 #include "chromeos/timezone/timezone_resolver.h"
199 #include "components/invalidation/impl/invalidator_storage.h"
200 #else
201 #include "chrome/browser/extensions/default_apps.h"
202 #endif
204 #if defined(OS_CHROMEOS) && defined(ENABLE_APP_LIST)
205 #include "chrome/browser/ui/app_list/google_now_extension.h"
206 #endif
208 #if defined(OS_MACOSX)
209 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h"
210 #include "chrome/browser/ui/cocoa/confirm_quit.h"
211 #endif
213 #if defined(OS_WIN)
214 #include "chrome/browser/apps/app_launch_for_metro_restart_win.h"
215 #include "chrome/browser/component_updater/sw_reporter_installer_win.h"
216 #endif
218 #if defined(TOOLKIT_VIEWS)
219 #include "chrome/browser/ui/browser_view_prefs.h"
220 #endif
222 #if defined(USE_ASH)
223 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
224 #endif
226 namespace {
228 #if !defined(OS_ANDROID)
229 // The AutomaticProfileResetter service used this preference to save that the
230 // profile reset prompt had already been shown, however, the preference has been
231 // renamed in Local State. We keep the name here for now so that we can clear
232 // out legacy values.
233 // TODO(engedy): Remove this and usages in M42 or later. See crbug.com/398813.
234 const char kLegacyProfileResetPromptMemento[] = "profile.reset_prompt_memento";
235 #endif
237 } // namespace
239 namespace chrome {
241 void RegisterLocalState(PrefRegistrySimple* registry) {
243 // Please keep this list alphabetized.
244 AppListService::RegisterPrefs(registry);
245 browser_shutdown::RegisterPrefs(registry);
246 BrowserProcessImpl::RegisterPrefs(registry);
247 ChromeMetricsServiceClient::RegisterPrefs(registry);
248 ChromeTracingDelegate::RegisterPrefs(registry);
249 chrome_prefs::RegisterPrefs(registry);
250 chrome_variations::VariationsService::RegisterPrefs(registry);
251 component_updater::RegisterPrefsForRecoveryComponent(registry);
252 component_updater::SupervisedUserWhitelistInstaller::RegisterPrefs(registry);
253 ExternalProtocolHandler::RegisterPrefs(registry);
254 FlagsUI::RegisterPrefs(registry);
255 geolocation::RegisterPrefs(registry);
256 GLStringManager::RegisterPrefs(registry);
257 GpuModeManager::RegisterPrefs(registry);
258 IntranetRedirectDetector::RegisterPrefs(registry);
259 IOThread::RegisterPrefs(registry);
260 network_time::NetworkTimeTracker::RegisterPrefs(registry);
261 PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
262 ProfileInfoCache::RegisterPrefs(registry);
263 profiles::RegisterPrefs(registry);
264 PromoResourceService::RegisterPrefs(registry);
265 rappor::RapporService::RegisterPrefs(registry);
266 RegisterScreenshotPrefs(registry);
267 SigninManagerFactory::RegisterPrefs(registry);
268 SSLConfigServiceManager::RegisterPrefs(registry);
269 UpgradeDetector::RegisterPrefs(registry);
271 #if defined(ENABLE_AUTOFILL_DIALOG)
272 autofill::AutofillDialogController::RegisterPrefs(registry);
273 #endif
275 #if defined(ENABLE_CONFIGURATION_POLICY)
276 policy::BrowserPolicyConnector::RegisterPrefs(registry);
277 policy::PolicyStatisticsCollector::RegisterPrefs(registry);
278 #endif
280 #if defined(ENABLE_EXTENSIONS)
281 EasyUnlockService::RegisterPrefs(registry);
282 #endif
284 #if defined(ENABLE_NOTIFICATIONS) && !defined(OS_ANDROID)
285 // Android does not use the message center for notifications.
286 MessageCenterNotificationManager::RegisterPrefs(registry);
287 #endif
289 #if defined(ENABLE_PLUGINS)
290 PluginFinder::RegisterPrefs(registry);
291 #endif
293 #if defined(ENABLE_PLUGIN_INSTALLATION)
294 PluginsResourceService::RegisterPrefs(registry);
295 #endif
297 #if defined(ENABLE_TASK_MANAGER)
298 TaskManager::RegisterPrefs(registry);
299 #endif // defined(ENABLE_TASK_MANAGER)
301 #if !defined(OS_ANDROID)
302 AutomaticProfileResetterFactory::RegisterPrefs(registry);
303 BackgroundModeManager::RegisterPrefs(registry);
304 RegisterBrowserPrefs(registry);
305 StartupBrowserCreator::RegisterLocalStatePrefs(registry);
306 // The native GCM is used on Android instead.
307 gcm::GCMChannelStatusSyncer::RegisterPrefs(registry);
308 #if !defined(OS_CHROMEOS)
309 RegisterDefaultBrowserPromptPrefs(registry);
310 #endif // !defined(OS_CHROMEOS)
311 #endif // !defined(OS_ANDROID)
313 #if defined(OS_CHROMEOS)
314 ChromeOSMetricsProvider::RegisterPrefs(registry);
315 chromeos::AudioDevicesPrefHandlerImpl::RegisterPrefs(registry);
316 chromeos::ChromeUserManagerImpl::RegisterPrefs(registry);
317 chromeos::DataPromoNotification::RegisterPrefs(registry);
318 chromeos::DeviceOAuth2TokenService::RegisterPrefs(registry);
319 chromeos::device_settings_cache::RegisterPrefs(registry);
320 chromeos::EnableDebuggingScreenHandler::RegisterPrefs(registry);
321 chromeos::language_prefs::RegisterPrefs(registry);
322 chromeos::KioskAppManager::RegisterPrefs(registry);
323 chromeos::MultiProfileUserController::RegisterPrefs(registry);
324 chromeos::HIDDetectionScreenHandler::RegisterPrefs(registry);
325 chromeos::DemoModeDetector::RegisterPrefs(registry);
326 chromeos::Preferences::RegisterPrefs(registry);
327 chromeos::proxy_config::RegisterPrefs(registry);
328 chromeos::RegisterDisplayLocalStatePrefs(registry);
329 chromeos::ResetScreenHandler::RegisterPrefs(registry);
330 chromeos::ServicesCustomizationDocument::RegisterPrefs(registry);
331 chromeos::SigninScreenHandler::RegisterPrefs(registry);
332 chromeos::StartupUtils::RegisterPrefs(registry);
333 chromeos::system::AutomaticRebootManager::RegisterPrefs(registry);
334 chromeos::UserImageManager::RegisterPrefs(registry);
335 chromeos::UserSessionManager::RegisterPrefs(registry);
336 chromeos::WallpaperManager::RegisterPrefs(registry);
337 chromeos::echo_offer::RegisterPrefs(registry);
338 extensions::ExtensionAssetsManagerChromeOS::RegisterPrefs(registry);
339 invalidation::InvalidatorStorage::RegisterPrefs(registry);
340 policy::AutoEnrollmentClient::RegisterPrefs(registry);
341 policy::BrowserPolicyConnectorChromeOS::RegisterPrefs(registry);
342 policy::ConsumerManagementService::RegisterPrefs(registry);
343 policy::DeviceCloudPolicyManagerChromeOS::RegisterPrefs(registry);
344 policy::DeviceStatusCollector::RegisterPrefs(registry);
345 policy::PolicyCertServiceFactory::RegisterPrefs(registry);
346 chromeos::TimeZoneResolver::RegisterPrefs(registry);
347 #endif
349 #if defined(OS_MACOSX)
350 confirm_quit::RegisterLocalState(registry);
351 QuitWithAppsController::RegisterPrefs(registry);
352 #endif
354 #if defined(OS_WIN)
355 app_metro_launch::RegisterPrefs(registry);
356 component_updater::RegisterPrefsForSwReporter(registry);
357 password_manager::PasswordManager::RegisterLocalPrefs(registry);
358 #endif
360 #if defined(TOOLKIT_VIEWS)
361 RegisterBrowserViewLocalPrefs(registry);
362 #endif
364 // Preferences registered only for migration (clearing or moving to a new key)
365 // go here.
366 #if !defined(OS_ANDROID)
367 registry->RegisterDictionaryPref(kLegacyProfileResetPromptMemento);
368 #endif // !defined(OS_ANDROID)
371 // Register prefs applicable to all profiles.
372 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
373 TRACE_EVENT0("browser", "chrome::RegisterProfilePrefs");
374 SCOPED_UMA_HISTOGRAM_TIMER("Settings.RegisterProfilePrefsTime");
375 // User prefs. Please keep this list alphabetized.
376 autofill::AutofillManager::RegisterProfilePrefs(registry);
377 sync_driver::SyncPrefs::RegisterProfilePrefs(registry);
378 ChromeContentBrowserClient::RegisterProfilePrefs(registry);
379 ChromeVersionService::RegisterProfilePrefs(registry);
380 chrome_browser_net::HttpServerPropertiesManagerFactory::RegisterProfilePrefs(
381 registry);
382 chrome_browser_net::Predictor::RegisterProfilePrefs(registry);
383 chrome_browser_net::RegisterPredictionOptionsProfilePrefs(registry);
384 chrome_prefs::RegisterProfilePrefs(registry);
385 dom_distiller::DistilledPagePrefs::RegisterProfilePrefs(registry);
386 DownloadPrefs::RegisterProfilePrefs(registry);
387 enhanced_bookmarks::BookmarkServerClusterService::RegisterPrefs(registry);
388 PushMessagingServiceImpl::RegisterProfilePrefs(registry);
389 HostContentSettingsMap::RegisterProfilePrefs(registry);
390 IncognitoModePrefs::RegisterProfilePrefs(registry);
391 InstantUI::RegisterProfilePrefs(registry);
392 NavigationCorrectionTabObserver::RegisterProfilePrefs(registry);
393 MediaCaptureDevicesDispatcher::RegisterProfilePrefs(registry);
394 MediaDeviceIDSalt::RegisterProfilePrefs(registry);
395 MediaStreamDevicesController::RegisterProfilePrefs(registry);
396 NetPrefObserver::RegisterProfilePrefs(registry);
397 password_manager::PasswordManager::RegisterProfilePrefs(registry);
398 PrefProxyConfigTrackerImpl::RegisterProfilePrefs(registry);
399 PrefsTabHelper::RegisterProfilePrefs(registry);
400 Profile::RegisterProfilePrefs(registry);
401 ProfileImpl::RegisterProfilePrefs(registry);
402 PromoResourceService::RegisterProfilePrefs(registry);
403 ProtocolHandlerRegistry::RegisterProfilePrefs(registry);
404 RegisterBrowserUserPrefs(registry);
405 SessionStartupPref::RegisterProfilePrefs(registry);
406 TemplateURLPrepopulateData::RegisterProfilePrefs(registry);
407 translate::TranslatePrefs::RegisterProfilePrefs(registry);
408 ZeroSuggestProvider::RegisterProfilePrefs(registry);
410 #if defined(ENABLE_APP_LIST)
411 app_list::AppListPrefs::RegisterProfilePrefs(registry);
412 #endif
414 #if defined(ENABLE_AUTOFILL_DIALOG)
415 autofill::AutofillDialogController::RegisterProfilePrefs(registry);
416 #endif
418 #if defined(ENABLE_CONFIGURATION_POLICY)
419 policy::URLBlacklistManager::RegisterProfilePrefs(registry);
420 #endif
422 #if defined(ENABLE_EXTENSIONS)
423 EasyUnlockService::RegisterProfilePrefs(registry);
424 extensions::ActivityLog::RegisterProfilePrefs(registry);
425 extensions::launch_util::RegisterProfilePrefs(registry);
426 ExtensionWebUI::RegisterProfilePrefs(registry);
427 extensions::ExtensionPrefs::RegisterProfilePrefs(registry);
428 #if !defined(OS_ANDROID) && !defined(OS_IOS)
429 ToolbarActionsBar::RegisterProfilePrefs(registry);
430 extensions::CopresenceService::RegisterProfilePrefs(registry);
431 #endif
432 RegisterAnimationPolicyPrefs(registry);
433 #endif // defined(ENABLE_EXTENSIONS)
435 #if defined(ENABLE_NOTIFICATIONS)
436 DesktopNotificationService::RegisterProfilePrefs(registry);
437 #endif
439 #if defined(ENABLE_NOTIFICATIONS) && defined(ENABLE_EXTENSIONS) && \
440 !defined(OS_ANDROID)
441 // The extension welcome notification requires a build that enables extensions
442 // and notifications, and uses the UI message center.
443 ExtensionWelcomeNotification::RegisterProfilePrefs(registry);
444 #endif
446 #if defined(ENABLE_PRINT_PREVIEW)
447 printing::StickySettings::RegisterProfilePrefs(registry);
448 #endif
450 #if defined(ENABLE_SERVICE_DISCOVERY)
451 LocalDiscoveryUI::RegisterProfilePrefs(registry);
452 #endif
454 #if defined(ENABLE_SUPERVISED_USERS)
455 #if !defined(OS_ANDROID) && !defined(OS_IOS)
456 SupervisedUserSharedSettingsService::RegisterProfilePrefs(registry);
457 SupervisedUserSyncService::RegisterProfilePrefs(registry);
458 #endif
459 ChildAccountService::RegisterProfilePrefs(registry);
460 SupervisedUserService::RegisterProfilePrefs(registry);
461 SupervisedUserWhitelistService::RegisterProfilePrefs(registry);
462 #endif
464 #if defined(OS_ANDROID)
465 chrome_variations::VariationsService::RegisterProfilePrefs(registry);
466 NewTabPagePrefs::RegisterProfilePrefs(registry);
467 PartnerBookmarksShim::RegisterProfilePrefs(registry);
468 #else
469 AppShortcutManager::RegisterProfilePrefs(registry);
470 autofill::GeneratedCreditCardBubbleController::RegisterUserPrefs(registry);
471 DeviceIDFetcher::RegisterProfilePrefs(registry);
472 DevToolsWindow::RegisterProfilePrefs(registry);
473 DriveAppMapping::RegisterProfilePrefs(registry);
474 extensions::CommandService::RegisterProfilePrefs(registry);
475 extensions::ExtensionSettingsHandler::RegisterProfilePrefs(registry);
476 extensions::TabsCaptureVisibleTabFunction::RegisterProfilePrefs(registry);
477 first_run::RegisterProfilePrefs(registry);
478 gcm::GCMChannelStatusSyncer::RegisterProfilePrefs(registry);
479 NewTabUI::RegisterProfilePrefs(registry);
480 PepperFlashSettingsManager::RegisterProfilePrefs(registry);
481 PinnedTabCodec::RegisterProfilePrefs(registry);
482 PluginsUI::RegisterProfilePrefs(registry);
483 RegisterAutolaunchUserPrefs(registry);
484 signin::RegisterProfilePrefs(registry);
485 #endif
487 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
488 default_apps::RegisterProfilePrefs(registry);
489 #endif
491 #if defined(OS_CHROMEOS)
492 chromeos::first_run::RegisterProfilePrefs(registry);
493 chromeos::file_system_provider::RegisterProfilePrefs(registry);
494 chromeos::KeyPermissions::RegisterProfilePrefs(registry);
495 chromeos::MultiProfileUserController::RegisterProfilePrefs(registry);
496 chromeos::Preferences::RegisterProfilePrefs(registry);
497 chromeos::proxy_config::RegisterProfilePrefs(registry);
498 chromeos::SAMLOfflineSigninLimiter::RegisterProfilePrefs(registry);
499 chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry);
500 chromeos::UserImageSyncObserver::RegisterProfilePrefs(registry);
501 extensions::EnterprisePlatformKeysPrivateChallengeUserKeyFunction::
502 RegisterProfilePrefs(registry);
503 FlagsUI::RegisterProfilePrefs(registry);
504 #endif
506 #if defined(OS_WIN)
507 component_updater::RegisterProfilePrefsForSwReporter(registry);
508 NetworkProfileBubble::RegisterProfilePrefs(registry);
509 #endif
511 #if defined(TOOLKIT_VIEWS)
512 RegisterBrowserViewProfilePrefs(registry);
513 RegisterInvertBubbleUserPrefs(registry);
514 #endif
516 #if defined(USE_ASH)
517 ash::RegisterChromeLauncherUserPrefs(registry);
518 #endif
520 #if !defined(OS_ANDROID) && !defined(OS_IOS)
521 browser_sync::ForeignSessionHandler::RegisterProfilePrefs(registry);
522 #endif
525 void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
526 RegisterProfilePrefs(registry);
528 #if defined(OS_CHROMEOS)
529 chromeos::PowerPrefs::RegisterUserProfilePrefs(registry);
530 #endif
533 void RegisterScreenshotPrefs(PrefRegistrySimple* registry) {
534 registry->RegisterBooleanPref(prefs::kDisableScreenshots, false);
537 #if defined(OS_CHROMEOS)
538 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
539 RegisterProfilePrefs(registry);
541 chromeos::PowerPrefs::RegisterLoginProfilePrefs(registry);
543 #endif
545 // This method should be periodically pruned of year+ old migrations.
546 void MigrateObsoleteBrowserPrefs(Profile* profile, PrefService* local_state) {
547 #if defined(TOOLKIT_VIEWS)
548 // Added 05/2014.
549 MigrateBrowserTabStripPrefs(local_state);
550 #endif
552 #if !defined(OS_ANDROID)
553 // Added 08/2014.
554 local_state->ClearPref(kLegacyProfileResetPromptMemento);
555 #endif
558 // This method should be periodically pruned of year+ old migrations.
559 void MigrateObsoleteProfilePrefs(Profile* profile) {
560 PrefService* profile_prefs = profile->GetPrefs();
562 #if defined(OS_MACOSX) && !defined(OS_IOS)
563 // Added 06/2014.
564 autofill::AutofillManager::MigrateUserPrefs(profile_prefs);
565 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
567 // Added 07/2014.
568 translate::TranslatePrefs::MigrateUserPrefs(profile_prefs,
569 prefs::kAcceptLanguages);
571 #if !defined(OS_ANDROID)
572 // Added 08/2014.
573 // Migrate kNetworkPredictionEnabled to kNetworkPredictionOptions when not on
574 // Android. On Android, platform-specific code performs preference migration.
575 // TODO(bnc): https://crbug.com/401970 Remove migration code one year after
576 // M38.
577 chrome_browser_net::MigrateNetworkPredictionUserPrefs(profile_prefs);
578 #endif
580 #if defined(OS_CHROMEOS) && defined(ENABLE_APP_LIST)
581 // Added 02/2015.
582 MigrateGoogleNowPrefs(profile);
583 #endif
586 // As part of the migration from per-profile to per-partition HostZoomMaps,
587 // we need to detect if an existing per-profile set of preferences exist, and
588 // if so convert them to be per-partition. We migrate any per-profile zoom
589 // level prefs via zoom_level_prefs.
590 // Code that updates zoom prefs in the profile prefs store has been removed,
591 // so once we clear these values here, they should never get set again.
592 // TODO(wjmaclean): Remove this migration machinery after histograms show
593 // that an aceptable percentage of users have been migrated.
594 // crbug.com/420643
595 void MigrateProfileZoomLevelPrefs(Profile* profile) {
596 PrefService* prefs = profile->GetPrefs();
597 chrome::ChromeZoomLevelPrefs* zoom_level_prefs = profile->GetZoomLevelPrefs();
598 DCHECK(zoom_level_prefs);
600 bool migrated = false;
601 // Only migrate the default zoom level if it is not equal to the registered
602 // default for the preference.
603 const base::Value* per_profile_default_zoom_level_value =
604 prefs->GetUserPrefValue(prefs::kDefaultZoomLevelDeprecated);
605 if (per_profile_default_zoom_level_value) {
606 if (per_profile_default_zoom_level_value->GetType() ==
607 base::Value::TYPE_DOUBLE) {
608 double per_profile_default_zoom_level = 0.0;
609 bool success = per_profile_default_zoom_level_value->GetAsDouble(
610 &per_profile_default_zoom_level);
611 DCHECK(success);
612 zoom_level_prefs->SetDefaultZoomLevelPref(per_profile_default_zoom_level);
614 prefs->ClearPref(prefs::kDefaultZoomLevelDeprecated);
615 migrated = true;
618 const base::DictionaryValue* host_zoom_dictionary =
619 prefs->GetDictionary(prefs::kPerHostZoomLevelsDeprecated);
620 // Collect stats on frequency with which migrations are occuring. This measure
621 // is not perfect, since it will consider an un-migrated user with only
622 // default value as being already migrated, but it will catch all non-trivial
623 // migrations.
624 migrated |= !host_zoom_dictionary->empty();
625 UMA_HISTOGRAM_BOOLEAN("Settings.ZoomLevelPreferencesMigrated", migrated);
627 // Since |host_zoom_dictionary| is not partition-based, do not attempt to
628 // sanitize it.
629 zoom_level_prefs->ExtractPerHostZoomLevels(
630 host_zoom_dictionary, false /* sanitize_partition_host_zoom_levels */);
632 // We're done migrating the profile per-host zoom level values, so we clear
633 // them all.
634 DictionaryPrefUpdate host_zoom_dictionary_update(
635 prefs, prefs::kPerHostZoomLevelsDeprecated);
636 host_zoom_dictionary_update->Clear();
639 } // namespace chrome