| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 #endif | 156 #endif |
| 157 | 157 |
| 158 #if defined(OS_CHROMEOS) | 158 #if defined(OS_CHROMEOS) |
| 159 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 159 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 160 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" | 160 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" |
| 161 #include "chrome/browser/chromeos/customization/customization_document.h" | 161 #include "chrome/browser/chromeos/customization/customization_document.h" |
| 162 #include "chrome/browser/chromeos/display/display_preferences.h" | 162 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 163 #include "chrome/browser/chromeos/extensions/echo_private_api.h" | 163 #include "chrome/browser/chromeos/extensions/echo_private_api.h" |
| 164 #include "chrome/browser/chromeos/file_system_provider/registry.h" | 164 #include "chrome/browser/chromeos/file_system_provider/registry.h" |
| 165 #include "chrome/browser/chromeos/first_run/first_run.h" | 165 #include "chrome/browser/chromeos/first_run/first_run.h" |
| 166 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h" | |
| 167 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" | 166 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" |
| 168 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 167 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 169 #include "chrome/browser/chromeos/login/startup_utils.h" | 168 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 170 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" | 169 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" |
| 171 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h" | 170 #include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h" |
| 172 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" | 171 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" |
| 173 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 172 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 174 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 173 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 175 #include "chrome/browser/chromeos/net/proxy_config_handler.h" | 174 #include "chrome/browser/chromeos/net/proxy_config_handler.h" |
| 176 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h" | 175 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 #if defined(TOOLKIT_VIEWS) | 216 #if defined(TOOLKIT_VIEWS) |
| 218 #include "chrome/browser/ui/browser_view_prefs.h" | 217 #include "chrome/browser/ui/browser_view_prefs.h" |
| 219 #endif | 218 #endif |
| 220 | 219 |
| 221 #if defined(USE_ASH) | 220 #if defined(USE_ASH) |
| 222 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 221 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 223 #endif | 222 #endif |
| 224 | 223 |
| 225 namespace { | 224 namespace { |
| 226 | 225 |
| 227 enum MigratedPreferences { | |
| 228 NO_PREFS = 0, | |
| 229 DNS_PREFS = 1 << 0, | |
| 230 WINDOWS_PREFS = 1 << 1, | |
| 231 }; | |
| 232 | |
| 233 // A previous feature (see | |
| 234 // chrome/browser/protector/protected_prefs_watcher.cc in source | |
| 235 // control history) used this string as a prefix for various prefs it | |
| 236 // registered. We keep it here for now to clear out those old prefs in | |
| 237 // MigrateUserPrefs. | |
| 238 const char kBackupPref[] = "backup"; | |
| 239 | |
| 240 #if !defined(OS_ANDROID) | 226 #if !defined(OS_ANDROID) |
| 241 // The AutomaticProfileResetter service used this preference to save that the | 227 // The AutomaticProfileResetter service used this preference to save that the |
| 242 // profile reset prompt had already been shown, however, the preference has been | 228 // profile reset prompt had already been shown, however, the preference has been |
| 243 // renamed in Local State. We keep the name here for now so that we can clear | 229 // renamed in Local State. We keep the name here for now so that we can clear |
| 244 // out legacy values. | 230 // out legacy values. |
| 245 // TODO(engedy): Remove this and usages in M42 or later. See crbug.com/398813. | 231 // TODO(engedy): Remove this and usages in M42 or later. See crbug.com/398813. |
| 246 const char kLegacyProfileResetPromptMemento[] = "profile.reset_prompt_memento"; | 232 const char kLegacyProfileResetPromptMemento[] = "profile.reset_prompt_memento"; |
| 247 #endif | 233 #endif |
| 248 | 234 |
| 249 } // namespace | 235 } // namespace |
| 250 | 236 |
| 251 namespace chrome { | 237 namespace chrome { |
| 252 | 238 |
| 253 void RegisterLocalState(PrefRegistrySimple* registry) { | 239 void RegisterLocalState(PrefRegistrySimple* registry) { |
| 254 // Prefs in Local State. | |
| 255 registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); | |
| 256 | 240 |
| 257 // Please keep this list alphabetized. | 241 // Please keep this list alphabetized. |
| 258 AppListService::RegisterPrefs(registry); | 242 AppListService::RegisterPrefs(registry); |
| 259 browser_shutdown::RegisterPrefs(registry); | 243 browser_shutdown::RegisterPrefs(registry); |
| 260 BrowserProcessImpl::RegisterPrefs(registry); | 244 BrowserProcessImpl::RegisterPrefs(registry); |
| 261 ChromeMetricsServiceClient::RegisterPrefs(registry); | 245 ChromeMetricsServiceClient::RegisterPrefs(registry); |
| 262 chrome_prefs::RegisterPrefs(registry); | 246 chrome_prefs::RegisterPrefs(registry); |
| 263 chrome_variations::VariationsService::RegisterPrefs(registry); | 247 chrome_variations::VariationsService::RegisterPrefs(registry); |
| 264 component_updater::RegisterPrefsForRecoveryComponent(registry); | 248 component_updater::RegisterPrefsForRecoveryComponent(registry); |
| 265 component_updater::SupervisedUserWhitelistInstaller::RegisterPrefs(registry); | 249 component_updater::SupervisedUserWhitelistInstaller::RegisterPrefs(registry); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 #endif // !defined(OS_CHROMEOS) | 306 #endif // !defined(OS_CHROMEOS) |
| 323 #endif // !defined(OS_ANDROID) | 307 #endif // !defined(OS_ANDROID) |
| 324 | 308 |
| 325 #if defined(OS_CHROMEOS) | 309 #if defined(OS_CHROMEOS) |
| 326 ChromeOSMetricsProvider::RegisterPrefs(registry); | 310 ChromeOSMetricsProvider::RegisterPrefs(registry); |
| 327 chromeos::AudioDevicesPrefHandlerImpl::RegisterPrefs(registry); | 311 chromeos::AudioDevicesPrefHandlerImpl::RegisterPrefs(registry); |
| 328 chromeos::ChromeUserManagerImpl::RegisterPrefs(registry); | 312 chromeos::ChromeUserManagerImpl::RegisterPrefs(registry); |
| 329 chromeos::DataPromoNotification::RegisterPrefs(registry); | 313 chromeos::DataPromoNotification::RegisterPrefs(registry); |
| 330 chromeos::DeviceOAuth2TokenService::RegisterPrefs(registry); | 314 chromeos::DeviceOAuth2TokenService::RegisterPrefs(registry); |
| 331 chromeos::device_settings_cache::RegisterPrefs(registry); | 315 chromeos::device_settings_cache::RegisterPrefs(registry); |
| 332 chromeos::default_pinned_apps_field_trial::RegisterPrefs(registry); | |
| 333 chromeos::EnableDebuggingScreenHandler::RegisterPrefs(registry); | 316 chromeos::EnableDebuggingScreenHandler::RegisterPrefs(registry); |
| 334 chromeos::language_prefs::RegisterPrefs(registry); | 317 chromeos::language_prefs::RegisterPrefs(registry); |
| 335 chromeos::KioskAppManager::RegisterPrefs(registry); | 318 chromeos::KioskAppManager::RegisterPrefs(registry); |
| 336 chromeos::MultiProfileUserController::RegisterPrefs(registry); | 319 chromeos::MultiProfileUserController::RegisterPrefs(registry); |
| 337 chromeos::HIDDetectionScreenHandler::RegisterPrefs(registry); | 320 chromeos::HIDDetectionScreenHandler::RegisterPrefs(registry); |
| 338 chromeos::DemoModeDetector::RegisterPrefs(registry); | 321 chromeos::DemoModeDetector::RegisterPrefs(registry); |
| 339 chromeos::Preferences::RegisterPrefs(registry); | 322 chromeos::Preferences::RegisterPrefs(registry); |
| 340 chromeos::proxy_config::RegisterPrefs(registry); | 323 chromeos::proxy_config::RegisterPrefs(registry); |
| 341 chromeos::RegisterDisplayLocalStatePrefs(registry); | 324 chromeos::RegisterDisplayLocalStatePrefs(registry); |
| 342 chromeos::ResetScreenHandler::RegisterPrefs(registry); | 325 chromeos::ResetScreenHandler::RegisterPrefs(registry); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 #endif | 506 #endif |
| 524 | 507 |
| 525 #if defined(TOOLKIT_VIEWS) | 508 #if defined(TOOLKIT_VIEWS) |
| 526 RegisterBrowserViewProfilePrefs(registry); | 509 RegisterBrowserViewProfilePrefs(registry); |
| 527 RegisterInvertBubbleUserPrefs(registry); | 510 RegisterInvertBubbleUserPrefs(registry); |
| 528 #endif | 511 #endif |
| 529 | 512 |
| 530 #if defined(USE_ASH) | 513 #if defined(USE_ASH) |
| 531 ash::RegisterChromeLauncherUserPrefs(registry); | 514 ash::RegisterChromeLauncherUserPrefs(registry); |
| 532 #endif | 515 #endif |
| 533 | |
| 534 // Preferences registered only for migration (clearing or moving to a new key) | |
| 535 // go here. | |
| 536 registry->RegisterDictionaryPref( | |
| 537 kBackupPref, | |
| 538 new base::DictionaryValue(), | |
| 539 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 540 } | 516 } |
| 541 | 517 |
| 542 void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 518 void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
| 543 RegisterProfilePrefs(registry); | 519 RegisterProfilePrefs(registry); |
| 544 | 520 |
| 545 #if defined(OS_CHROMEOS) | 521 #if defined(OS_CHROMEOS) |
| 546 chromeos::PowerPrefs::RegisterUserProfilePrefs(registry); | 522 chromeos::PowerPrefs::RegisterUserProfilePrefs(registry); |
| 547 #endif | 523 #endif |
| 548 } | 524 } |
| 549 | 525 |
| 550 void RegisterScreenshotPrefs(PrefRegistrySimple* registry) { | 526 void RegisterScreenshotPrefs(PrefRegistrySimple* registry) { |
| 551 registry->RegisterBooleanPref(prefs::kDisableScreenshots, false); | 527 registry->RegisterBooleanPref(prefs::kDisableScreenshots, false); |
| 552 } | 528 } |
| 553 | 529 |
| 554 #if defined(OS_CHROMEOS) | 530 #if defined(OS_CHROMEOS) |
| 555 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 531 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
| 556 RegisterProfilePrefs(registry); | 532 RegisterProfilePrefs(registry); |
| 557 | 533 |
| 558 chromeos::PowerPrefs::RegisterLoginProfilePrefs(registry); | 534 chromeos::PowerPrefs::RegisterLoginProfilePrefs(registry); |
| 559 } | 535 } |
| 560 #endif | 536 #endif |
| 561 | 537 |
| 562 void MigrateUserPrefs(Profile* profile) { | 538 // This method should be periodically pruned of year+ old migrations. |
| 563 PrefService* prefs = profile->GetPrefs(); | 539 void MigrateObsoleteBrowserPrefs(Profile* profile, PrefService* local_state) { |
| 564 | 540 #if defined(TOOLKIT_VIEWS) |
| 565 // Cleanup prefs from now-removed protector feature. | 541 // Added 05/2014. |
| 566 prefs->ClearPref(kBackupPref); | 542 MigrateBrowserTabStripPrefs(local_state); |
| 543 #endif |
| 567 | 544 |
| 568 #if !defined(OS_ANDROID) | 545 #if !defined(OS_ANDROID) |
| 546 // Added 08/2014. |
| 547 local_state->ClearPref(kLegacyProfileResetPromptMemento); |
| 548 #endif |
| 549 } |
| 550 |
| 551 // This method should be periodically pruned of year+ old migrations. |
| 552 void MigrateObsoleteProfilePrefs(Profile* profile) { |
| 553 PrefService* profile_prefs = profile->GetPrefs(); |
| 554 |
| 555 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 556 // Added 06/2014. |
| 557 autofill::AutofillManager::MigrateUserPrefs(profile_prefs); |
| 558 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 559 |
| 560 // Added 07/2014. |
| 561 translate::TranslatePrefs::MigrateUserPrefs(profile_prefs, |
| 562 prefs::kAcceptLanguages); |
| 563 |
| 564 #if !defined(OS_ANDROID) |
| 565 // Added 08/2014. |
| 569 // Migrate kNetworkPredictionEnabled to kNetworkPredictionOptions when not on | 566 // Migrate kNetworkPredictionEnabled to kNetworkPredictionOptions when not on |
| 570 // Android. On Android, platform-specific code performs preference migration. | 567 // Android. On Android, platform-specific code performs preference migration. |
| 571 // TODO(bnc): https://crbug.com/401970 Remove migration code one year after | 568 // TODO(bnc): https://crbug.com/401970 Remove migration code one year after |
| 572 // M38. | 569 // M38. |
| 573 chrome_browser_net::MigrateNetworkPredictionUserPrefs(prefs); | 570 chrome_browser_net::MigrateNetworkPredictionUserPrefs(profile_prefs); |
| 574 #endif | 571 #endif |
| 575 | 572 |
| 576 PromoResourceService::MigrateUserPrefs(prefs); | |
| 577 translate::TranslatePrefs::MigrateUserPrefs(prefs, prefs::kAcceptLanguages); | |
| 578 | |
| 579 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 580 autofill::AutofillManager::MigrateUserPrefs(prefs); | |
| 581 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | |
| 582 | |
| 583 #if defined(OS_CHROMEOS) && defined(ENABLE_APP_LIST) | 573 #if defined(OS_CHROMEOS) && defined(ENABLE_APP_LIST) |
| 574 // Added 02/2015. |
| 584 MigrateGoogleNowPrefs(profile); | 575 MigrateGoogleNowPrefs(profile); |
| 585 #endif | 576 #endif |
| 586 } | 577 } |
| 587 | 578 |
| 588 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) { | |
| 589 // Copy pref values which have been migrated to user_prefs from local_state, | |
| 590 // or remove them from local_state outright, if copying is not required. | |
| 591 int current_version = | |
| 592 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); | |
| 593 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>( | |
| 594 local_state->DeprecatedGetPrefRegistry()); | |
| 595 | |
| 596 if (!(current_version & DNS_PREFS)) { | |
| 597 registry->RegisterListPref(prefs::kDnsStartupPrefetchList); | |
| 598 local_state->ClearPref(prefs::kDnsStartupPrefetchList); | |
| 599 | |
| 600 registry->RegisterListPref(prefs::kDnsHostReferralList); | |
| 601 local_state->ClearPref(prefs::kDnsHostReferralList); | |
| 602 | |
| 603 current_version |= DNS_PREFS; | |
| 604 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | |
| 605 current_version); | |
| 606 } | |
| 607 | |
| 608 PrefService* user_prefs = profile->GetPrefs(); | |
| 609 if (!(current_version & WINDOWS_PREFS)) { | |
| 610 registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | |
| 611 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { | |
| 612 const PrefService::Preference* pref = | |
| 613 local_state->FindPreference(prefs::kBrowserWindowPlacement); | |
| 614 DCHECK(pref); | |
| 615 user_prefs->Set(prefs::kBrowserWindowPlacement, | |
| 616 *(pref->GetValue())); | |
| 617 } | |
| 618 local_state->ClearPref(prefs::kBrowserWindowPlacement); | |
| 619 | |
| 620 current_version |= WINDOWS_PREFS; | |
| 621 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | |
| 622 current_version); | |
| 623 } | |
| 624 | |
| 625 #if !defined(OS_ANDROID) | |
| 626 local_state->ClearPref(kLegacyProfileResetPromptMemento); | |
| 627 #endif | |
| 628 | |
| 629 #if defined(OS_CHROMEOS) | |
| 630 chromeos::default_pinned_apps_field_trial::MigratePrefs(local_state); | |
| 631 #endif | |
| 632 | |
| 633 #if defined(TOOLKIT_VIEWS) | |
| 634 MigrateBrowserTabStripPrefs(local_state); | |
| 635 #endif | |
| 636 } | |
| 637 | |
| 638 // As part of the migration from per-profile to per-partition HostZoomMaps, | 579 // As part of the migration from per-profile to per-partition HostZoomMaps, |
| 639 // we need to detect if an existing per-profile set of preferences exist, and | 580 // we need to detect if an existing per-profile set of preferences exist, and |
| 640 // if so convert them to be per-partition. We migrate any per-profile zoom | 581 // if so convert them to be per-partition. We migrate any per-profile zoom |
| 641 // level prefs via zoom_level_prefs. | 582 // level prefs via zoom_level_prefs. |
| 642 // Code that updates zoom prefs in the profile prefs store has been removed, | 583 // Code that updates zoom prefs in the profile prefs store has been removed, |
| 643 // so once we clear these values here, they should never get set again. | 584 // so once we clear these values here, they should never get set again. |
| 644 // TODO(wjmaclean): Remove this migration machinery after histograms show | 585 // TODO(wjmaclean): Remove this migration machinery after histograms show |
| 645 // that an aceptable percentage of users have been migrated. | 586 // that an aceptable percentage of users have been migrated. |
| 646 // crbug.com/420643 | 587 // crbug.com/420643 |
| 647 void MigrateProfileZoomLevelPrefs(Profile* profile) { | 588 void MigrateProfileZoomLevelPrefs(Profile* profile) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 host_zoom_dictionary, false /* sanitize_partition_host_zoom_levels */); | 623 host_zoom_dictionary, false /* sanitize_partition_host_zoom_levels */); |
| 683 | 624 |
| 684 // We're done migrating the profile per-host zoom level values, so we clear | 625 // We're done migrating the profile per-host zoom level values, so we clear |
| 685 // them all. | 626 // them all. |
| 686 DictionaryPrefUpdate host_zoom_dictionary_update( | 627 DictionaryPrefUpdate host_zoom_dictionary_update( |
| 687 prefs, prefs::kPerHostZoomLevelsDeprecated); | 628 prefs, prefs::kPerHostZoomLevelsDeprecated); |
| 688 host_zoom_dictionary_update->Clear(); | 629 host_zoom_dictionary_update->Clear(); |
| 689 } | 630 } |
| 690 | 631 |
| 691 } // namespace chrome | 632 } // namespace chrome |
| OLD | NEW |