blob: 2e52bd49e4ab84e705f85e728c3f481e612f1deb [file] [log] [blame]
[email protected]69bb9e62012-01-20 11:02:301// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]37858e52010-08-26 00:22:025#include "chrome/browser/prefs/browser_prefs.h"
initial.commit09911bf2008-07-26 23:55:296
[email protected]1a47d7e2010-10-15 00:37:247#include "chrome/browser/about_flags.h"
[email protected]551c0ff2010-01-11 18:49:408#include "chrome/browser/autofill/autofill_manager.h"
[email protected]a07676b22011-06-17 16:36:539#include "chrome/browser/background/background_mode_manager.h"
[email protected]c58c5ea2011-07-13 21:43:1610#include "chrome/browser/bookmarks/bookmark_model.h"
[email protected]44b2c8852009-03-18 00:57:4911#include "chrome/browser/bookmarks/bookmark_utils.h"
[email protected]c5cf01032009-02-16 07:00:3712#include "chrome/browser/browser_shutdown.h"
[email protected]9d01a6a2010-11-30 12:03:3313#include "chrome/browser/content_settings/host_content_settings_map.h"
[email protected]a6d36cc2011-02-23 00:39:4814#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
[email protected]dce502762011-07-20 08:53:4915#include "chrome/browser/debugger/devtools_window.h"
[email protected]e5dc4222010-08-30 22:16:3216#include "chrome/browser/download/download_prefs.h"
[email protected]18cc5a52011-04-15 16:03:3817#include "chrome/browser/extensions/apps_promo.h"
[email protected]25ae0152011-11-18 14:40:0218#include "chrome/browser/extensions/component_loader.h"
[email protected]fee8f0222010-03-17 01:13:3719#include "chrome/browser/extensions/extension_prefs.h"
[email protected]8f9d4eb2011-02-05 01:39:1020#include "chrome/browser/extensions/extension_web_ui.h"
[email protected]ed2b1002011-05-25 14:12:1021#include "chrome/browser/external_protocol/external_protocol_handler.h"
[email protected]4e48d772010-02-18 12:11:1422#include "chrome/browser/geolocation/geolocation_prefs.h"
[email protected]f7578f52010-08-30 22:22:4923#include "chrome/browser/google/google_url_tracker.h"
[email protected]480760a2011-01-18 16:14:4824#include "chrome/browser/instant/instant_controller.h"
[email protected]8f0bbd62012-02-22 03:37:1825#include "chrome/browser/intents/web_intents_util.h"
[email protected]5e9d1f72011-01-19 14:15:2326#include "chrome/browser/intranet_redirect_detector.h"
[email protected]679082052010-07-21 21:30:1327#include "chrome/browser/metrics/metrics_log.h"
[email protected]0b88fdb2009-02-13 18:07:4428#include "chrome/browser/metrics/metrics_service.h"
[email protected]db96a882011-10-09 02:01:5429#include "chrome/browser/net/http_server_properties_manager.h"
[email protected]5e9d1f72011-01-19 14:15:2330#include "chrome/browser/net/net_pref_observer.h"
[email protected]67372ecf2011-09-10 01:30:4631#include "chrome/browser/net/predictor.h"
[email protected]ffa3e4862011-07-23 04:47:3032#include "chrome/browser/net/ssl_config_service_manager.h"
[email protected]480760a2011-01-18 16:14:4833#include "chrome/browser/notifications/desktop_notification_service.h"
[email protected]5e9d1f72011-01-19 14:15:2334#include "chrome/browser/notifications/notification_ui_manager.h"
[email protected]4d677202009-07-19 07:37:1235#include "chrome/browser/page_info_model.h"
[email protected]93ee5f82009-02-16 06:32:4536#include "chrome/browser/password_manager/password_manager.h"
[email protected]9eee50d52011-04-14 09:07:4837#include "chrome/browser/policy/cloud_policy_subsystem.h"
[email protected]6a5f77c32011-09-04 19:19:5938#include "chrome/browser/policy/url_blacklist_manager.h"
[email protected]4e94ab32011-08-05 05:28:2739#include "chrome/browser/prefs/incognito_mode_prefs.h"
[email protected]37858e52010-08-26 00:22:0240#include "chrome/browser/prefs/session_startup_pref.h"
[email protected]f16b9662011-04-27 10:06:0741#include "chrome/browser/printing/print_job_manager.h"
[email protected]1bfc3d42011-11-30 07:21:5142#include "chrome/browser/profiles/gaia_info_update_service.h"
[email protected]8ecad5e2010-12-02 21:18:3343#include "chrome/browser/profiles/profile_impl.h"
[email protected]dee810e2011-06-27 19:43:3944#include "chrome/browser/profiles/profile_info_cache.h"
[email protected]29d70252011-04-28 02:16:5845#include "chrome/browser/profiles/profile_manager.h"
[email protected]2c434b32009-03-19 06:27:4746#include "chrome/browser/renderer_host/web_cache_manager.h"
[email protected]559ce85492009-03-17 17:31:1147#include "chrome/browser/safe_browsing/safe_browsing_service.h"
[email protected]f63ae312009-02-04 17:58:4648#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
[email protected]37858e52010-08-26 00:22:0249#include "chrome/browser/tabs/pinned_tab_codec.h"
[email protected]a5d1e1e2010-09-23 19:34:1250#include "chrome/browser/task_manager/task_manager.h"
[email protected]f078169292010-04-07 23:31:5851#include "chrome/browser/translate/translate_prefs.h"
[email protected]51d83bdf2011-12-09 16:09:2952#include "chrome/browser/ui/alternate_error_tab_observer.h"
[email protected]440348f2010-11-16 00:30:1953#include "chrome/browser/ui/browser.h"
[email protected]0cba2962011-12-15 10:45:3254#include "chrome/browser/ui/browser_init.h"
[email protected]9ce7cb42011-12-07 18:53:0755#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
[email protected]62f77772011-02-23 19:45:4256#include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
[email protected]265a1492011-02-27 05:58:0757#include "chrome/browser/ui/webui/flags_ui.h"
[email protected]27e96a972011-10-20 20:06:5558#include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
[email protected]7c5c6f3a2011-04-28 19:56:4959#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
[email protected]7741f592011-09-23 09:56:2960#include "chrome/browser/ui/webui/options/extension_settings_handler.h"
[email protected]265a1492011-02-27 05:58:0761#include "chrome/browser/ui/webui/plugins_ui.h"
[email protected]130879e2011-12-15 08:10:5762#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
[email protected]8fcec3c72010-06-03 00:17:2263#include "chrome/browser/upgrade_detector.h"
[email protected]18cc5a52011-04-15 16:03:3864#include "chrome/browser/web_resource/promo_resource_service.h"
[email protected]f87919d72011-02-02 18:46:1665#include "chrome/common/pref_names.h"
[email protected]f3b1a082011-11-18 00:34:3066#include "content/public/browser/render_process_host.h"
[email protected]a814d8632009-01-31 20:18:5267
[email protected]d3766932011-08-04 22:18:2368#if defined(OS_MACOSX)
[email protected]b6366ffa2012-02-29 17:12:2669#include "chrome/browser/ui/cocoa/confirm_quit.h"
[email protected]d3766932011-08-04 22:18:2370#include "chrome/browser/ui/cocoa/presentation_mode_prefs.h"
71#endif
72
[email protected]0ef42ff92009-07-06 20:17:3573#if defined(TOOLKIT_VIEWS) // TODO(port): whittle this down as we port
[email protected]9e790bd2011-01-10 23:48:5474#include "chrome/browser/ui/views/browser_actions_container.h"
75#include "chrome/browser/ui/views/frame/browser_view.h"
[email protected]0ef42ff92009-07-06 20:17:3576#endif
77
[email protected]fc7611b32009-07-31 21:52:4478#if defined(TOOLKIT_GTK)
[email protected]93270d002011-01-19 22:32:5979#include "chrome/browser/ui/gtk/browser_window_gtk.h"
[email protected]fc7611b32009-07-31 21:52:4480#endif
81
[email protected]9acc48602009-11-30 21:18:5182#if defined(OS_CHROMEOS)
[email protected]d333dfc2012-02-04 16:53:4883#include "chrome/browser/chromeos/audio/audio_handler.h"
[email protected]9ef86832011-04-28 06:54:3384#include "chrome/browser/chromeos/customization_document.h"
[email protected]233bb3ec2011-12-02 16:15:4985#include "chrome/browser/chromeos/login/signed_settings_cache.h"
[email protected]8f0d8ecd12010-04-20 11:51:3086#include "chrome/browser/chromeos/login/user_manager.h"
[email protected]21f90b82010-06-30 12:01:0787#include "chrome/browser/chromeos/login/wizard_controller.h"
[email protected]9acc48602009-11-30 21:18:5188#include "chrome/browser/chromeos/preferences.h"
[email protected]6f96cbcb2011-11-04 02:26:0789#include "chrome/browser/chromeos/proxy_config_service_impl.h"
[email protected]f3964ad2011-01-25 05:06:3590#include "chrome/browser/chromeos/status/input_method_menu.h"
[email protected]9271c5f2011-05-24 09:52:1291#include "chrome/browser/chromeos/status/network_menu_button.h"
[email protected]bd62b4e2012-01-29 01:41:5092#include "chrome/browser/policy/auto_enrollment_client.h"
[email protected]1c61b1f2011-12-13 12:33:5793#include "chrome/browser/policy/device_status_collector.h"
[email protected]86c6b9e32011-10-25 17:09:1094#else
95#include "chrome/browser/extensions/default_apps.h"
[email protected]9acc48602009-11-30 21:18:5196#endif
97
[email protected]4a56d2442012-02-22 23:10:1998#if defined(USE_AURA)
99#include "chrome/browser/ui/views/aura/launcher/chrome_launcher_delegate.h"
100#endif
101
initial.commit09911bf2008-07-26 23:55:29102namespace browser {
103
[email protected]9acc48602009-11-30 21:18:51104void RegisterLocalState(PrefService* local_state) {
initial.commit09911bf2008-07-26 23:55:29105 // Prefs in Local State
[email protected]03218cd2011-08-30 13:54:02106 local_state->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0);
[email protected]18cc5a52011-04-15 16:03:38107 AppsPromo::RegisterPrefs(local_state);
[email protected]e94980022009-02-03 01:09:53108 Browser::RegisterPrefs(local_state);
[email protected]42cbc842011-01-24 22:28:39109 FlagsUI::RegisterPrefs(local_state);
[email protected]2c434b32009-03-19 06:27:47110 WebCacheManager::RegisterPrefs(local_state);
[email protected]559ce85492009-03-17 17:31:11111 ExternalProtocolHandler::RegisterPrefs(local_state);
112 GoogleURLTracker::RegisterPrefs(local_state);
[email protected]c4ff4952010-01-08 19:12:47113 IntranetRedirectDetector::RegisterPrefs(local_state);
[email protected]c2788ecb2009-09-19 01:54:23114 KeywordEditorController::RegisterPrefs(local_state);
[email protected]0b88fdb2009-02-13 18:07:44115 MetricsLog::RegisterPrefs(local_state);
116 MetricsService::RegisterPrefs(local_state);
[email protected]27e96a972011-10-20 20:06:55117
[email protected]4b58e7d2011-07-11 10:22:56118#if defined(ENABLE_SAFE_BROWSING)
[email protected]559ce85492009-03-17 17:31:11119 SafeBrowsingService::RegisterPrefs(local_state);
[email protected]4b58e7d2011-07-11 10:22:56120#endif
[email protected]c5cf01032009-02-16 07:00:37121 browser_shutdown::RegisterPrefs(local_state);
[email protected]fee8f0222010-03-17 01:13:37122#if defined(TOOLKIT_VIEWS)
[email protected]c6e67002008-11-11 22:03:15123 BrowserView::RegisterBrowserViewPrefs(local_state);
[email protected]a5eb6fc02009-07-29 21:52:28124#endif
[email protected]8fcec3c72010-06-03 00:17:22125 UpgradeDetector::RegisterPrefs(local_state);
initial.commit09911bf2008-07-26 23:55:29126 TaskManager::RegisterPrefs(local_state);
[email protected]4e48d772010-02-18 12:11:14127 geolocation::RegisterPrefs(local_state);
[email protected]b0b2a3dd2011-01-06 00:30:05128 NotificationUIManager::RegisterPrefs(local_state);
[email protected]6f96cbcb2011-11-04 02:26:07129 PrefProxyConfigTrackerImpl::RegisterPrefs(local_state);
[email protected]ffa3e4862011-07-23 04:47:30130 SSLConfigServiceManager::RegisterPrefs(local_state);
[email protected]f31e2e52011-07-14 16:01:19131#if defined(ENABLE_CONFIGURATION_POLICY)
[email protected]9eee50d52011-04-14 09:07:48132 policy::CloudPolicySubsystem::RegisterPrefs(local_state);
[email protected]f31e2e52011-07-14 16:01:19133#endif
[email protected]dee810e2011-06-27 19:43:39134 ProfileInfoCache::RegisterPrefs(local_state);
[email protected]29d70252011-04-28 02:16:58135 ProfileManager::RegisterPrefs(local_state);
[email protected]3954f332012-02-25 02:51:54136
137#if !defined(OS_ANDROID)
138 NewTabPageHandler::RegisterPrefs(local_state);
139 printing::PrintJobManager::RegisterPrefs(local_state);
140 PromoResourceService::RegisterPrefs(local_state);
141 BackgroundModeManager::RegisterPrefs(local_state);
142#endif
143
[email protected]8f0d8ecd12010-04-20 11:51:30144#if defined(OS_CHROMEOS)
[email protected]d333dfc2012-02-04 16:53:48145 chromeos::AudioHandler::RegisterPrefs(local_state);
[email protected]8f0d8ecd12010-04-20 11:51:30146 chromeos::UserManager::RegisterPrefs(local_state);
[email protected]413a5312011-05-27 15:14:11147 chromeos::WizardController::RegisterPrefs(local_state);
[email protected]f3964ad2011-01-25 05:06:35148 chromeos::InputMethodMenu::RegisterPrefs(local_state);
[email protected]9ef86832011-04-28 06:54:33149 chromeos::ServicesCustomizationDocument::RegisterPrefs(local_state);
[email protected]233bb3ec2011-12-02 16:15:49150 chromeos::signed_settings_cache::RegisterPrefs(local_state);
[email protected]9271c5f2011-05-24 09:52:12151 chromeos::NetworkMenuButton::RegisterPrefs(local_state);
[email protected]6f96cbcb2011-11-04 02:26:07152 chromeos::ProxyConfigServiceImpl::RegisterPrefs(local_state);
[email protected]bd62b4e2012-01-29 01:41:50153 policy::AutoEnrollmentClient::RegisterPrefs(local_state);
[email protected]1c61b1f2011-12-13 12:33:57154 policy::DeviceStatusCollector::RegisterPrefs(local_state);
[email protected]8f0d8ecd12010-04-20 11:51:30155#endif
[email protected]b6366ffa2012-02-29 17:12:26156
157#if defined(OS_MACOSX)
158 confirm_quit::RegisterLocalState(local_state);
159#endif
[email protected]9acc48602009-11-30 21:18:51160}
initial.commit09911bf2008-07-26 23:55:29161
[email protected]9acc48602009-11-30 21:18:51162void RegisterUserPrefs(PrefService* user_prefs) {
initial.commit09911bf2008-07-26 23:55:29163 // User prefs
[email protected]18cc5a52011-04-15 16:03:38164 AppsPromo::RegisterUserPrefs(user_prefs);
[email protected]c4a9e932011-03-05 04:05:55165 AutofillManager::RegisterUserPrefs(user_prefs);
[email protected]a814d8632009-01-31 20:18:52166 SessionStartupPref::RegisterUserPrefs(user_prefs);
[email protected]c58c5ea2011-07-13 21:43:16167 BookmarkModel::RegisterUserPrefs(user_prefs);
[email protected]e94980022009-02-03 01:09:53168 Browser::RegisterUserPrefs(user_prefs);
[email protected]0cba2962011-12-15 10:45:32169 BrowserInit::RegisterUserPrefs(user_prefs);
[email protected]93ee5f82009-02-16 06:32:45170 PasswordManager::RegisterUserPrefs(user_prefs);
[email protected]67372ecf2011-09-10 01:30:46171 chrome_browser_net::Predictor::RegisterUserPrefs(user_prefs);
[email protected]e5dc4222010-08-30 22:16:32172 DownloadPrefs::RegisterUserPrefs(user_prefs);
[email protected]44b2c8852009-03-18 00:57:49173 bookmark_utils::RegisterUserPrefs(user_prefs);
[email protected]51d83bdf2011-12-09 16:09:29174 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs);
[email protected]9ce7cb42011-12-07 18:53:07175 PrefsTabHelper::RegisterUserPrefs(user_prefs);
[email protected]f63ae312009-02-04 17:58:46176 TemplateURLPrepopulateData::RegisterUserPrefs(user_prefs);
[email protected]8f9d4eb2011-02-05 01:39:10177 ExtensionWebUI::RegisterUserPrefs(user_prefs);
[email protected]7741f592011-09-23 09:56:29178 ExtensionSettingsHandler::RegisterUserPrefs(user_prefs);
[email protected]4e94ab32011-08-05 05:28:27179 IncognitoModePrefs::RegisterUserPrefs(user_prefs);
[email protected]34cdd0552009-04-13 19:00:29180 NewTabUI::RegisterUserPrefs(user_prefs);
[email protected]e19cf1e2010-10-01 12:31:34181 ProfileImpl::RegisterUserPrefs(user_prefs);
[email protected]e284e6d82010-01-29 19:49:45182 HostContentSettingsMap::RegisterUserPrefs(user_prefs);
[email protected]dce502762011-07-20 08:53:49183 DevToolsWindow::RegisterUserPrefs(user_prefs);
[email protected]911f8152010-03-18 16:46:40184 PinnedTabCodec::RegisterUserPrefs(user_prefs);
[email protected]fee8f0222010-03-17 01:13:37185 ExtensionPrefs::RegisterUserPrefs(user_prefs);
[email protected]f078169292010-04-07 23:31:58186 TranslatePrefs::RegisterUserPrefs(user_prefs);
[email protected]6f96cbcb2011-11-04 02:26:07187 PrefProxyConfigTrackerImpl::RegisterPrefs(user_prefs);
[email protected]fee8f0222010-03-17 01:13:37188#if defined(TOOLKIT_VIEWS)
[email protected]bd5a00a72010-01-22 22:00:09189 BrowserActionsContainer::RegisterUserPrefs(user_prefs);
[email protected]fee8f0222010-03-17 01:13:37190#elif defined(TOOLKIT_GTK)
[email protected]fc7611b32009-07-31 21:52:44191 BrowserWindowGtk::RegisterUserPrefs(user_prefs);
192#endif
[email protected]9acc48602009-11-30 21:18:51193#if defined(OS_CHROMEOS)
194 chromeos::Preferences::RegisterUserPrefs(user_prefs);
[email protected]6f96cbcb2011-11-04 02:26:07195 chromeos::ProxyConfigServiceImpl::RegisterPrefs(user_prefs);
[email protected]9acc48602009-11-30 21:18:51196#endif
[email protected]018cbb22010-10-11 22:32:09197 InstantController::RegisterUserPrefs(user_prefs);
[email protected]93bd86a2010-10-16 21:30:53198 NetPrefObserver::RegisterPrefs(user_prefs);
[email protected]a6d36cc2011-02-23 00:39:48199 ProtocolHandlerRegistry::RegisterPrefs(user_prefs);
[email protected]d3766932011-08-04 22:18:23200#if defined(OS_MACOSX)
201 PresentationModePrefs::RegisterUserPrefs(user_prefs);
[email protected]b6366ffa2012-02-29 17:12:26202 confirm_quit::RegisterObsoleteUserPrefs(user_prefs);
[email protected]d3766932011-08-04 22:18:23203#endif
[email protected]6a5f77c32011-09-04 19:19:59204#if defined(ENABLE_CONFIGURATION_POLICY)
205 policy::URLBlacklistManager::RegisterPrefs(user_prefs);
206#endif
[email protected]b3bc58392011-10-11 09:17:26207 SyncPromoUI::RegisterUserPrefs(user_prefs);
[email protected]1bfc3d42011-11-30 07:21:51208 GAIAInfoUpdateService::RegisterUserPrefs(user_prefs);
[email protected]db96a882011-10-09 02:01:54209 chrome_browser_net::HttpServerPropertiesManager::RegisterPrefs(user_prefs);
[email protected]3954f332012-02-25 02:51:54210#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
[email protected]86c6b9e32011-10-25 17:09:10211 default_apps::RegisterUserPrefs(user_prefs);
212#endif
[email protected]25ae0152011-11-18 14:40:02213 extensions::ComponentLoader::RegisterUserPrefs(user_prefs);
[email protected]8f0bbd62012-02-22 03:37:18214 web_intents::RegisterUserPrefs(user_prefs);
[email protected]4a56d2442012-02-22 23:10:19215#if defined(USE_AURA)
216 ChromeLauncherDelegate::RegisterUserPrefs(user_prefs);
217#endif
[email protected]3954f332012-02-25 02:51:54218#if !defined(OS_ANDROID)
219 PluginsUI::RegisterUserPrefs(user_prefs);
220 PromoResourceService::RegisterUserPrefs(user_prefs);
221#endif
initial.commit09911bf2008-07-26 23:55:29222}
license.botbf09a502008-08-24 00:55:55223
[email protected]f87919d72011-02-02 18:46:16224void MigrateBrowserPrefs(PrefService* user_prefs, PrefService* local_state) {
225 // Copy pref values which have been migrated to user_prefs from local_state,
226 // or remove them from local_state outright, if copying is not required.
227 int current_version =
228 local_state->GetInteger(prefs::kMultipleProfilePrefMigration);
229
230 if ((current_version & WINDOWS_PREFS) == 0) {
231 // Migrate the devtools split location preference.
232 local_state->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1);
[email protected]f87919d72011-02-02 18:46:16233 if (local_state->HasPrefPath(prefs::kDevToolsSplitLocation)) {
234 user_prefs->SetInteger(prefs::kDevToolsSplitLocation,
235 local_state->GetInteger(prefs::kDevToolsSplitLocation));
236 }
237 local_state->ClearPref(prefs::kDevToolsSplitLocation);
238
239 // Migrate the browser window placement preference.
240 local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
[email protected]f87919d72011-02-02 18:46:16241 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) {
[email protected]8874e02172011-03-11 19:44:08242 const PrefService::Preference* pref =
243 local_state->FindPreference(prefs::kBrowserWindowPlacement);
244 DCHECK(pref);
245 user_prefs->Set(prefs::kBrowserWindowPlacement, *(pref->GetValue()));
[email protected]f87919d72011-02-02 18:46:16246 }
247 local_state->ClearPref(prefs::kBrowserWindowPlacement);
248
249 local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
250 current_version | WINDOWS_PREFS);
251 }
252}
253
[email protected]919d77f02009-01-06 19:48:35254} // namespace browser