| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prefs/browser_prefs.h" | 5 #include "chrome/browser/prefs/browser_prefs.h" |
| 6 | 6 |
| 7 #include "chrome/browser/about_flags.h" | 7 #include "chrome/browser/about_flags.h" |
| 8 #include "chrome/browser/accessibility/invert_bubble_prefs.h" | 8 #include "chrome/browser/accessibility/invert_bubble_prefs.h" |
| 9 #include "chrome/browser/autofill/autofill_manager.h" | 9 #include "chrome/browser/autofill/autofill_manager.h" |
| 10 #include "chrome/browser/background/background_mode_manager.h" | 10 #include "chrome/browser/background/background_mode_manager.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_prompt_prefs.h" | 11 #include "chrome/browser/bookmarks/bookmark_prompt_prefs.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 13 #include "chrome/browser/browser_process_impl.h" |
| 13 #include "chrome/browser/browser_shutdown.h" | 14 #include "chrome/browser/browser_shutdown.h" |
| 14 #include "chrome/browser/chrome_content_browser_client.h" | 15 #include "chrome/browser/chrome_content_browser_client.h" |
| 15 #include "chrome/browser/content_settings/host_content_settings_map.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 16 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 17 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 17 #include "chrome/browser/devtools/devtools_window.h" | 18 #include "chrome/browser/devtools/devtools_window.h" |
| 18 #include "chrome/browser/download/download_prefs.h" | 19 #include "chrome/browser/download/download_prefs.h" |
| 19 #include "chrome/browser/extensions/api/commands/command_service.h" | 20 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 20 #include "chrome/browser/extensions/api/tabs/tabs.h" | 21 #include "chrome/browser/extensions/api/tabs/tabs.h" |
| 21 #include "chrome/browser/extensions/component_loader.h" | 22 #include "chrome/browser/extensions/component_loader.h" |
| 22 #include "chrome/browser/extensions/extension_prefs.h" | 23 #include "chrome/browser/extensions/extension_prefs.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 #include "chrome/browser/net/net_pref_observer.h" | 39 #include "chrome/browser/net/net_pref_observer.h" |
| 39 #include "chrome/browser/net/predictor.h" | 40 #include "chrome/browser/net/predictor.h" |
| 40 #include "chrome/browser/net/ssl_config_service_manager.h" | 41 #include "chrome/browser/net/ssl_config_service_manager.h" |
| 41 #include "chrome/browser/notifications/desktop_notification_service.h" | 42 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 42 #include "chrome/browser/notifications/notification_prefs_manager.h" | 43 #include "chrome/browser/notifications/notification_prefs_manager.h" |
| 43 #include "chrome/browser/page_info_model.h" | 44 #include "chrome/browser/page_info_model.h" |
| 44 #include "chrome/browser/password_manager/password_manager.h" | 45 #include "chrome/browser/password_manager/password_manager.h" |
| 45 #include "chrome/browser/pepper_flash_settings_manager.h" | 46 #include "chrome/browser/pepper_flash_settings_manager.h" |
| 46 #include "chrome/browser/plugins/plugin_finder.h" | 47 #include "chrome/browser/plugins/plugin_finder.h" |
| 47 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 48 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 49 #include "chrome/browser/prefs/pref_registrar_simple.h" |
| 48 #include "chrome/browser/prefs/pref_service.h" | 50 #include "chrome/browser/prefs/pref_service.h" |
| 49 #include "chrome/browser/prefs/session_startup_pref.h" | 51 #include "chrome/browser/prefs/session_startup_pref.h" |
| 50 #include "chrome/browser/profiles/chrome_version_service.h" | 52 #include "chrome/browser/profiles/chrome_version_service.h" |
| 51 #include "chrome/browser/profiles/gaia_info_update_service.h" | 53 #include "chrome/browser/profiles/gaia_info_update_service.h" |
| 52 #include "chrome/browser/profiles/profile_impl.h" | 54 #include "chrome/browser/profiles/profile_impl.h" |
| 53 #include "chrome/browser/profiles/profile_info_cache.h" | 55 #include "chrome/browser/profiles/profile_info_cache.h" |
| 54 #include "chrome/browser/profiles/profile_manager.h" | 56 #include "chrome/browser/profiles/profile_manager.h" |
| 55 #include "chrome/browser/renderer_host/web_cache_manager.h" | 57 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 56 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 58 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 57 #include "chrome/browser/signin/signin_manager_factory.h" | 59 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 NO_PREFS = 0, | 139 NO_PREFS = 0, |
| 138 DNS_PREFS = 1 << 0, | 140 DNS_PREFS = 1 << 0, |
| 139 WINDOWS_PREFS = 1 << 1, | 141 WINDOWS_PREFS = 1 << 1, |
| 140 GOOGLE_URL_TRACKER_PREFS = 1 << 2, | 142 GOOGLE_URL_TRACKER_PREFS = 1 << 2, |
| 141 }; | 143 }; |
| 142 | 144 |
| 143 } // namespace | 145 } // namespace |
| 144 | 146 |
| 145 namespace chrome { | 147 namespace chrome { |
| 146 | 148 |
| 147 void RegisterLocalState(PrefServiceSimple* local_state) { | 149 void RegisterLocalState(PrefService* local_state) { |
| 150 PrefRegistrarSimple registrar(local_state); |
| 151 |
| 148 // Prefs in Local State. | 152 // Prefs in Local State. |
| 149 local_state->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); | 153 registrar.RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); |
| 150 | 154 |
| 151 // Please keep this list alphabetized. | 155 // Please keep this list alphabetized. |
| 152 browser_shutdown::RegisterPrefs(local_state); | 156 BrowserProcessImpl::RegisterPrefs(®istrar); |
| 153 chrome::RegisterScreenshotPrefs(local_state); | 157 browser_shutdown::RegisterPrefs(®istrar); |
| 154 ExternalProtocolHandler::RegisterPrefs(local_state); | 158 chrome::RegisterScreenshotPrefs(®istrar); |
| 155 geolocation::RegisterPrefs(local_state); | 159 ExternalProtocolHandler::RegisterPrefs(®istrar); |
| 156 IntranetRedirectDetector::RegisterPrefs(local_state); | 160 geolocation::RegisterPrefs(®istrar); |
| 157 KeywordEditorController::RegisterPrefs(local_state); | 161 IntranetRedirectDetector::RegisterPrefs(®istrar); |
| 158 MetricsLog::RegisterPrefs(local_state); | 162 KeywordEditorController::RegisterPrefs(®istrar); |
| 159 MetricsService::RegisterPrefs(local_state); | 163 MetricsLog::RegisterPrefs(®istrar); |
| 160 PluginFinder::RegisterPrefs(local_state); | 164 MetricsService::RegisterPrefs(®istrar); |
| 161 PrefProxyConfigTrackerImpl::RegisterPrefs(local_state); | 165 PluginFinder::RegisterPrefs(®istrar); |
| 162 ProfileInfoCache::RegisterPrefs(local_state); | 166 PrefProxyConfigTrackerImpl::RegisterPrefs(®istrar); |
| 163 ProfileManager::RegisterPrefs(local_state); | 167 ProfileInfoCache::RegisterPrefs(®istrar); |
| 164 PromoResourceService::RegisterPrefs(local_state); | 168 ProfileManager::RegisterPrefs(®istrar); |
| 165 SigninManagerFactory::RegisterPrefs(local_state); | 169 PromoResourceService::RegisterPrefs(local_state, ®istrar); |
| 166 SSLConfigServiceManager::RegisterPrefs(local_state); | 170 SigninManagerFactory::RegisterPrefs(®istrar); |
| 167 WebCacheManager::RegisterPrefs(local_state); | 171 SSLConfigServiceManager::RegisterPrefs(®istrar); |
| 172 WebCacheManager::RegisterPrefs(®istrar); |
| 168 | 173 |
| 169 #if defined(ENABLE_PLUGIN_INSTALLATION) | 174 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 170 PluginsResourceService::RegisterPrefs(local_state); | 175 PluginsResourceService::RegisterPrefs(®istrar); |
| 171 #endif | 176 #endif |
| 172 | 177 |
| 173 #if defined(ENABLE_CONFIGURATION_POLICY) | 178 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 174 policy::CloudPolicySubsystem::RegisterPrefs(local_state); | 179 policy::CloudPolicySubsystem::RegisterPrefs(®istrar); |
| 175 policy::PolicyStatisticsCollector::RegisterPrefs(local_state); | 180 policy::PolicyStatisticsCollector::RegisterPrefs(®istrar); |
| 176 #endif | 181 #endif |
| 177 | 182 |
| 178 #if defined(ENABLE_NOTIFICATIONS) | 183 #if defined(ENABLE_NOTIFICATIONS) |
| 179 NotificationPrefsManager::RegisterPrefs(local_state); | 184 NotificationPrefsManager::RegisterPrefs(®istrar); |
| 180 #endif | 185 #endif |
| 181 | 186 |
| 182 #if defined(ENABLE_TASK_MANAGER) | 187 #if defined(ENABLE_TASK_MANAGER) |
| 183 TaskManager::RegisterPrefs(local_state); | 188 TaskManager::RegisterPrefs(®istrar); |
| 184 #endif // defined(ENABLE_TASK_MANAGER) | 189 #endif // defined(ENABLE_TASK_MANAGER) |
| 185 | 190 |
| 186 #if defined(TOOLKIT_VIEWS) | 191 #if defined(TOOLKIT_VIEWS) |
| 187 RegisterBrowserViewPrefs(local_state); | 192 RegisterBrowserViewPrefs(®istrar); |
| 188 RegisterTabStripLayoutTypePrefs(local_state); | 193 RegisterTabStripLayoutTypePrefs(®istrar); |
| 189 #endif | 194 #endif |
| 190 | 195 |
| 191 #if !defined(OS_ANDROID) | 196 #if !defined(OS_ANDROID) |
| 192 BackgroundModeManager::RegisterPrefs(local_state); | 197 BackgroundModeManager::RegisterPrefs(®istrar); |
| 193 chrome_variations::VariationsService::RegisterPrefs(local_state); | 198 chrome_variations::VariationsService::RegisterPrefs(®istrar); |
| 194 RegisterBrowserPrefs(local_state); | 199 RegisterBrowserPrefs(®istrar); |
| 195 FlagsUI::RegisterPrefs(local_state); | 200 FlagsUI::RegisterPrefs(®istrar); |
| 196 ManagedMode::RegisterPrefs(local_state); | 201 ManagedMode::RegisterPrefs(®istrar); |
| 197 UpgradeDetector::RegisterPrefs(local_state); | 202 UpgradeDetector::RegisterPrefs(®istrar); |
| 198 #endif | 203 #endif |
| 199 | 204 |
| 200 #if defined(OS_CHROMEOS) | 205 #if defined(OS_CHROMEOS) |
| 201 chromeos::AudioHandler::RegisterPrefs(local_state); | 206 chromeos::AudioHandler::RegisterPrefs(®istrar); |
| 202 chromeos::DataPromoNotification::RegisterPrefs(local_state); | 207 chromeos::DataPromoNotification::RegisterPrefs(®istrar); |
| 203 chromeos::device_settings_cache::RegisterPrefs(local_state); | 208 chromeos::device_settings_cache::RegisterPrefs(®istrar); |
| 204 chromeos::language_prefs::RegisterPrefs(local_state); | 209 chromeos::language_prefs::RegisterPrefs(®istrar); |
| 205 chromeos::ProxyConfigServiceImpl::RegisterPrefs(local_state); | 210 chromeos::ProxyConfigServiceImpl::RegisterPrefs(®istrar); |
| 206 chromeos::RegisterDisplayLocalStatePrefs(local_state); | 211 chromeos::RegisterDisplayLocalStatePrefs(®istrar); |
| 207 chromeos::ServicesCustomizationDocument::RegisterPrefs(local_state); | 212 chromeos::ServicesCustomizationDocument::RegisterPrefs(®istrar); |
| 208 chromeos::UserImageManager::RegisterPrefs(local_state); | 213 chromeos::UserImageManager::RegisterPrefs(®istrar); |
| 209 chromeos::UserManager::RegisterPrefs(local_state); | 214 chromeos::UserManager::RegisterPrefs(®istrar); |
| 210 chromeos::WallpaperManager::RegisterPrefs(local_state); | 215 chromeos::WallpaperManager::RegisterPrefs(®istrar); |
| 211 chromeos::WizardController::RegisterPrefs(local_state); | 216 chromeos::WizardController::RegisterPrefs(®istrar); |
| 212 policy::AutoEnrollmentClient::RegisterPrefs(local_state); | 217 policy::AutoEnrollmentClient::RegisterPrefs(®istrar); |
| 213 policy::DeviceStatusCollector::RegisterPrefs(local_state); | 218 policy::DeviceStatusCollector::RegisterPrefs(®istrar); |
| 214 #endif | 219 #endif |
| 215 | 220 |
| 216 #if defined(OS_MACOSX) | 221 #if defined(OS_MACOSX) |
| 217 confirm_quit::RegisterLocalState(local_state); | 222 confirm_quit::RegisterLocalState(®istrar); |
| 218 #endif | 223 #endif |
| 219 } | 224 } |
| 220 | 225 |
| 221 void RegisterUserPrefs(PrefServiceSyncable* user_prefs) { | 226 void RegisterUserPrefs(PrefServiceSyncable* user_prefs) { |
| 222 // User prefs. Please keep this list alphabetized. | 227 // User prefs. Please keep this list alphabetized. |
| 223 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs); | 228 AlternateErrorPageTabObserver::RegisterUserPrefs(user_prefs); |
| 224 AutofillManager::RegisterUserPrefs(user_prefs); | 229 AutofillManager::RegisterUserPrefs(user_prefs); |
| 225 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs); | 230 BookmarkPromptPrefs::RegisterUserPrefs(user_prefs); |
| 226 bookmark_utils::RegisterUserPrefs(user_prefs); | 231 bookmark_utils::RegisterUserPrefs(user_prefs); |
| 227 BrowserInstantController::RegisterUserPrefs(user_prefs); | 232 BrowserInstantController::RegisterUserPrefs(user_prefs); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 void MigrateUserPrefs(Profile* profile) { | 314 void MigrateUserPrefs(Profile* profile) { |
| 310 // Cleanup old prefs. | 315 // Cleanup old prefs. |
| 311 static const char kBackupPref[] = "backup"; | 316 static const char kBackupPref[] = "backup"; |
| 312 PrefServiceSyncable* prefs = profile->GetPrefs(); | 317 PrefServiceSyncable* prefs = profile->GetPrefs(); |
| 313 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), | 318 prefs->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), |
| 314 PrefServiceSyncable::UNSYNCABLE_PREF); | 319 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 315 prefs->ClearPref(kBackupPref); | 320 prefs->ClearPref(kBackupPref); |
| 316 prefs->UnregisterPreference(kBackupPref); | 321 prefs->UnregisterPreference(kBackupPref); |
| 317 } | 322 } |
| 318 | 323 |
| 319 void MigrateBrowserPrefs(Profile* profile, PrefServiceSimple* local_state) { | 324 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) { |
| 320 // Copy pref values which have been migrated to user_prefs from local_state, | 325 // Copy pref values which have been migrated to user_prefs from local_state, |
| 321 // or remove them from local_state outright, if copying is not required. | 326 // or remove them from local_state outright, if copying is not required. |
| 322 int current_version = | 327 int current_version = |
| 323 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); | 328 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); |
| 329 PrefRegistrarSimple registrar(local_state); |
| 324 | 330 |
| 325 if (!(current_version & DNS_PREFS)) { | 331 if (!(current_version & DNS_PREFS)) { |
| 326 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList); | 332 registrar.RegisterListPref(prefs::kDnsStartupPrefetchList); |
| 327 local_state->ClearPref(prefs::kDnsStartupPrefetchList); | 333 local_state->ClearPref(prefs::kDnsStartupPrefetchList); |
| 328 | 334 |
| 329 local_state->RegisterListPref(prefs::kDnsHostReferralList); | 335 registrar.RegisterListPref(prefs::kDnsHostReferralList); |
| 330 local_state->ClearPref(prefs::kDnsHostReferralList); | 336 local_state->ClearPref(prefs::kDnsHostReferralList); |
| 331 | 337 |
| 332 current_version |= DNS_PREFS; | 338 current_version |= DNS_PREFS; |
| 333 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 339 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
| 334 current_version); | 340 current_version); |
| 335 } | 341 } |
| 336 | 342 |
| 337 PrefServiceSyncable* user_prefs = profile->GetPrefs(); | 343 PrefServiceSyncable* user_prefs = profile->GetPrefs(); |
| 338 if (!(current_version & WINDOWS_PREFS)) { | 344 if (!(current_version & WINDOWS_PREFS)) { |
| 339 local_state->RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); | 345 registrar.RegisterIntegerPref(prefs::kDevToolsHSplitLocation, -1); |
| 340 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { | 346 if (local_state->HasPrefPath(prefs::kDevToolsHSplitLocation)) { |
| 341 user_prefs->SetInteger( | 347 user_prefs->SetInteger( |
| 342 prefs::kDevToolsHSplitLocation, | 348 prefs::kDevToolsHSplitLocation, |
| 343 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); | 349 local_state->GetInteger(prefs::kDevToolsHSplitLocation)); |
| 344 } | 350 } |
| 345 local_state->ClearPref(prefs::kDevToolsHSplitLocation); | 351 local_state->ClearPref(prefs::kDevToolsHSplitLocation); |
| 346 | 352 |
| 347 local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | 353 registrar.RegisterDictionaryPref(prefs::kBrowserWindowPlacement); |
| 348 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { | 354 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { |
| 349 const PrefService::Preference* pref = | 355 const PrefService::Preference* pref = |
| 350 local_state->FindPreference(prefs::kBrowserWindowPlacement); | 356 local_state->FindPreference(prefs::kBrowserWindowPlacement); |
| 351 DCHECK(pref); | 357 DCHECK(pref); |
| 352 user_prefs->Set(prefs::kBrowserWindowPlacement, | 358 user_prefs->Set(prefs::kBrowserWindowPlacement, |
| 353 *(pref->GetValue())); | 359 *(pref->GetValue())); |
| 354 } | 360 } |
| 355 local_state->ClearPref(prefs::kBrowserWindowPlacement); | 361 local_state->ClearPref(prefs::kBrowserWindowPlacement); |
| 356 | 362 |
| 357 current_version |= WINDOWS_PREFS; | 363 current_version |= WINDOWS_PREFS; |
| 358 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 364 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
| 359 current_version); | 365 current_version); |
| 360 } | 366 } |
| 361 | 367 |
| 362 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { | 368 if (!(current_version & GOOGLE_URL_TRACKER_PREFS)) { |
| 363 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); | 369 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnProfile(profile); |
| 364 local_state->RegisterStringPref(prefs::kLastKnownGoogleURL, | 370 registrar.RegisterStringPref(prefs::kLastKnownGoogleURL, |
| 365 GoogleURLTracker::kDefaultGoogleHomepage); | 371 GoogleURLTracker::kDefaultGoogleHomepage); |
| 366 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { | 372 if (local_state->HasPrefPath(prefs::kLastKnownGoogleURL)) { |
| 367 user_prefs->SetString(prefs::kLastKnownGoogleURL, | 373 user_prefs->SetString(prefs::kLastKnownGoogleURL, |
| 368 local_state->GetString(prefs::kLastKnownGoogleURL)); | 374 local_state->GetString(prefs::kLastKnownGoogleURL)); |
| 369 } | 375 } |
| 370 local_state->ClearPref(prefs::kLastKnownGoogleURL); | 376 local_state->ClearPref(prefs::kLastKnownGoogleURL); |
| 371 | 377 |
| 372 local_state->RegisterStringPref(prefs::kLastPromptedGoogleURL, | 378 registrar.RegisterStringPref(prefs::kLastPromptedGoogleURL, |
| 373 std::string()); | 379 std::string()); |
| 374 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { | 380 if (local_state->HasPrefPath(prefs::kLastPromptedGoogleURL)) { |
| 375 user_prefs->SetString( | 381 user_prefs->SetString( |
| 376 prefs::kLastPromptedGoogleURL, | 382 prefs::kLastPromptedGoogleURL, |
| 377 local_state->GetString(prefs::kLastPromptedGoogleURL)); | 383 local_state->GetString(prefs::kLastPromptedGoogleURL)); |
| 378 } | 384 } |
| 379 local_state->ClearPref(prefs::kLastPromptedGoogleURL); | 385 local_state->ClearPref(prefs::kLastPromptedGoogleURL); |
| 380 | 386 |
| 381 current_version |= GOOGLE_URL_TRACKER_PREFS; | 387 current_version |= GOOGLE_URL_TRACKER_PREFS; |
| 382 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 388 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
| 383 current_version); | 389 current_version); |
| 384 } | 390 } |
| 385 } | 391 } |
| 386 | 392 |
| 387 } // namespace chrome | 393 } // namespace chrome |
| OLD | NEW |