Chromium Code Reviews| 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 "apps/prefs.h" | 7 #include "apps/prefs.h" |
| 8 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/about_flags.h" | 10 #include "chrome/browser/about_flags.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 #if defined(TOOLKIT_GTK) | 108 #if defined(TOOLKIT_GTK) |
| 109 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 109 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 110 #endif | 110 #endif |
| 111 | 111 |
| 112 #if defined(OS_CHROMEOS) | 112 #if defined(OS_CHROMEOS) |
| 113 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 113 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 114 #include "chrome/browser/chromeos/audio/audio_handler.h" | 114 #include "chrome/browser/chromeos/audio/audio_handler.h" |
| 115 #include "chrome/browser/chromeos/customization_document.h" | 115 #include "chrome/browser/chromeos/customization_document.h" |
| 116 #include "chrome/browser/chromeos/display/display_preferences.h" | 116 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 117 #include "chrome/browser/chromeos/login/login_utils.h" | 117 #include "chrome/browser/chromeos/login/login_utils.h" |
| 118 #include "chrome/browser/chromeos/login/oauth2_login_manager.h" | |
| 118 #include "chrome/browser/chromeos/login/user_image_manager.h" | 119 #include "chrome/browser/chromeos/login/user_image_manager.h" |
| 119 #include "chrome/browser/chromeos/login/user_manager.h" | 120 #include "chrome/browser/chromeos/login/user_manager.h" |
| 120 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 121 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
| 121 #include "chrome/browser/chromeos/login/wizard_controller.h" | 122 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 122 #include "chrome/browser/chromeos/preferences.h" | 123 #include "chrome/browser/chromeos/preferences.h" |
| 123 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 124 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 124 #include "chrome/browser/chromeos/settings/device_settings_cache.h" | 125 #include "chrome/browser/chromeos/settings/device_settings_cache.h" |
| 125 #include "chrome/browser/chromeos/status/data_promo_notification.h" | 126 #include "chrome/browser/chromeos/status/data_promo_notification.h" |
| 126 #include "chrome/browser/policy/auto_enrollment_client.h" | 127 #include "chrome/browser/policy/auto_enrollment_client.h" |
| 127 #include "chrome/browser/policy/device_cloud_policy_manager_chromeos.h" | 128 #include "chrome/browser/policy/device_cloud_policy_manager_chromeos.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 148 | 149 |
| 149 namespace { | 150 namespace { |
| 150 | 151 |
| 151 enum MigratedPreferences { | 152 enum MigratedPreferences { |
| 152 NO_PREFS = 0, | 153 NO_PREFS = 0, |
| 153 DNS_PREFS = 1 << 0, | 154 DNS_PREFS = 1 << 0, |
| 154 WINDOWS_PREFS = 1 << 1, | 155 WINDOWS_PREFS = 1 << 1, |
| 155 GOOGLE_URL_TRACKER_PREFS = 1 << 2, | 156 GOOGLE_URL_TRACKER_PREFS = 1 << 2, |
| 156 }; | 157 }; |
| 157 | 158 |
| 159 // Name of an old pref that is cleared in MigrateUserPrefs. | |
|
Mattias Nissler (ping if slow)
2013/02/20 17:17:27
I think it'd be nicer to actually have this in pre
Jói
2013/02/21 12:05:10
This wasn't in pref_names, it was in a .cc file th
| |
| 160 const char kBackupPref[] = "backup"; | |
| 161 | |
| 158 } // namespace | 162 } // namespace |
| 159 | 163 |
| 160 namespace chrome { | 164 namespace chrome { |
| 161 | 165 |
| 162 void RegisterLocalState(PrefRegistrySimple* registry) { | 166 void RegisterLocalState(PrefRegistrySimple* registry) { |
| 163 // Prefs in Local State. | 167 // Prefs in Local State. |
| 164 registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); | 168 registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); |
| 165 | 169 |
| 166 // Please keep this list alphabetized. | 170 // Please keep this list alphabetized. |
| 167 apps::RegisterPrefs(registry); | 171 apps::RegisterPrefs(registry); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 printing::StickySettings::RegisterUserPrefs(registry); | 334 printing::StickySettings::RegisterUserPrefs(registry); |
| 331 RegisterAutolaunchUserPrefs(registry); | 335 RegisterAutolaunchUserPrefs(registry); |
| 332 SyncPromoUI::RegisterUserPrefs(registry); | 336 SyncPromoUI::RegisterUserPrefs(registry); |
| 333 #endif | 337 #endif |
| 334 | 338 |
| 335 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 339 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 336 default_apps::RegisterUserPrefs(registry); | 340 default_apps::RegisterUserPrefs(registry); |
| 337 #endif | 341 #endif |
| 338 | 342 |
| 339 #if defined(OS_CHROMEOS) | 343 #if defined(OS_CHROMEOS) |
| 344 chromeos::OAuth2LoginManager::RegisterUserPrefs(registry); | |
| 340 chromeos::Preferences::RegisterUserPrefs(registry); | 345 chromeos::Preferences::RegisterUserPrefs(registry); |
| 341 chromeos::ProxyConfigServiceImpl::RegisterUserPrefs(registry); | 346 chromeos::ProxyConfigServiceImpl::RegisterUserPrefs(registry); |
| 342 #endif | 347 #endif |
| 343 | 348 |
| 344 #if defined(OS_WIN) | 349 #if defined(OS_WIN) |
| 345 NetworkProfileBubble::RegisterUserPrefs(registry); | 350 NetworkProfileBubble::RegisterUserPrefs(registry); |
| 346 #endif | 351 #endif |
| 352 | |
| 353 // Prefs registered only for migration (clearing or moving to a new | |
| 354 // key) go here. | |
| 355 registry->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), | |
| 356 PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 347 } | 357 } |
| 348 | 358 |
| 349 void MigrateUserPrefs(Profile* profile) { | 359 void MigrateUserPrefs(Profile* profile) { |
| 360 PrefService* prefs = profile->GetPrefs(); | |
| 361 | |
| 350 // Cleanup old prefs. | 362 // Cleanup old prefs. |
| 351 static const char kBackupPref[] = "backup"; | |
| 352 PrefService* prefs = profile->GetPrefs(); | |
| 353 // TODO(joi): Fix to not require post-construction registration? | |
| 354 scoped_refptr<PrefRegistrySyncable> registry( | |
| 355 static_cast<PrefRegistrySyncable*>(prefs->DeprecatedGetPrefRegistry())); | |
| 356 registry->RegisterDictionaryPref(kBackupPref, new DictionaryValue(), | |
| 357 PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 358 prefs->ClearPref(kBackupPref); | 363 prefs->ClearPref(kBackupPref); |
| 359 registry->DeprecatedUnregisterPreference(kBackupPref); | |
| 360 | 364 |
| 361 PrefsTabHelper::MigrateUserPrefs(prefs, registry); | 365 PrefsTabHelper::MigrateUserPrefs(prefs); |
| 362 } | 366 } |
| 363 | 367 |
| 364 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) { | 368 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) { |
| 365 // Copy pref values which have been migrated to user_prefs from local_state, | 369 // Copy pref values which have been migrated to user_prefs from local_state, |
| 366 // or remove them from local_state outright, if copying is not required. | 370 // or remove them from local_state outright, if copying is not required. |
| 367 int current_version = | 371 int current_version = |
| 368 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); | 372 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); |
| 369 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>( | 373 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>( |
| 370 local_state->DeprecatedGetPrefRegistry()); | 374 local_state->DeprecatedGetPrefRegistry()); |
| 371 | 375 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 } | 429 } |
| 426 local_state->ClearPref(prefs::kLastPromptedGoogleURL); | 430 local_state->ClearPref(prefs::kLastPromptedGoogleURL); |
| 427 | 431 |
| 428 current_version |= GOOGLE_URL_TRACKER_PREFS; | 432 current_version |= GOOGLE_URL_TRACKER_PREFS; |
| 429 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 433 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
| 430 current_version); | 434 current_version); |
| 431 } | 435 } |
| 432 } | 436 } |
| 433 | 437 |
| 434 } // namespace chrome | 438 } // namespace chrome |
| OLD | NEW |