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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 enum MigratedPreferences { | 223 enum MigratedPreferences { |
224 NO_PREFS = 0, | 224 NO_PREFS = 0, |
225 DNS_PREFS = 1 << 0, | 225 DNS_PREFS = 1 << 0, |
226 WINDOWS_PREFS = 1 << 1, | 226 WINDOWS_PREFS = 1 << 1, |
227 }; | 227 }; |
228 | 228 |
229 // A previous feature (see | 229 // A previous feature (see |
230 // chrome/browser/protector/protected_prefs_watcher.cc in source | 230 // chrome/browser/protector/protected_prefs_watcher.cc in source |
231 // control history) used this string as a prefix for various prefs it | 231 // control history) used this string as a prefix for various prefs it |
232 // registered. We keep it here for now to clear out those old prefs in | 232 // registered. We keep it here for now to clear out those old prefs in |
233 // MigrateUserPrefs. | 233 // MigrateObsoleteProfilePrefs. |
234 const char kBackupPref[] = "backup"; | 234 const char kBackupPref[] = "backup"; |
gab
2015/02/23 16:09:38
Remove it completely.
rkaplow
2015/02/23 22:55:04
Done.
| |
235 | 235 |
236 #if !defined(OS_ANDROID) | 236 #if !defined(OS_ANDROID) |
237 // The AutomaticProfileResetter service used this preference to save that the | 237 // The AutomaticProfileResetter service used this preference to save that the |
238 // profile reset prompt had already been shown, however, the preference has been | 238 // profile reset prompt had already been shown, however, the preference has been |
239 // renamed in Local State. We keep the name here for now so that we can clear | 239 // renamed in Local State. We keep the name here for now so that we can clear |
240 // out legacy values. | 240 // out legacy values. |
241 // TODO(engedy): Remove this and usages in M42 or later. See crbug.com/398813. | 241 // TODO(engedy): Remove this and usages in M42 or later. See crbug.com/398813. |
242 const char kLegacyProfileResetPromptMemento[] = "profile.reset_prompt_memento"; | 242 const char kLegacyProfileResetPromptMemento[] = "profile.reset_prompt_memento"; |
243 #endif | 243 #endif |
244 | 244 |
245 } // namespace | 245 } // namespace |
246 | 246 |
247 namespace chrome { | 247 namespace chrome { |
248 | 248 |
249 void RegisterLocalState(PrefRegistrySimple* registry) { | 249 void RegisterLocalState(PrefRegistrySimple* registry) { |
250 // Prefs in Local State. | |
251 registry->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); | |
252 | 250 |
253 // Please keep this list alphabetized. | 251 // Please keep this list alphabetized. |
254 AppListService::RegisterPrefs(registry); | 252 AppListService::RegisterPrefs(registry); |
255 browser_shutdown::RegisterPrefs(registry); | 253 browser_shutdown::RegisterPrefs(registry); |
256 BrowserProcessImpl::RegisterPrefs(registry); | 254 BrowserProcessImpl::RegisterPrefs(registry); |
257 ChromeMetricsServiceClient::RegisterPrefs(registry); | 255 ChromeMetricsServiceClient::RegisterPrefs(registry); |
258 chrome_prefs::RegisterPrefs(registry); | 256 chrome_prefs::RegisterPrefs(registry); |
259 chrome_variations::VariationsService::RegisterPrefs(registry); | 257 chrome_variations::VariationsService::RegisterPrefs(registry); |
260 component_updater::RegisterPrefsForRecoveryComponent(registry); | 258 component_updater::RegisterPrefsForRecoveryComponent(registry); |
261 component_updater::SupervisedUserWhitelistInstaller::RegisterPrefs(registry); | 259 component_updater::SupervisedUserWhitelistInstaller::RegisterPrefs(registry); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 } | 546 } |
549 | 547 |
550 #if defined(OS_CHROMEOS) | 548 #if defined(OS_CHROMEOS) |
551 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 549 void RegisterLoginProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
552 RegisterProfilePrefs(registry); | 550 RegisterProfilePrefs(registry); |
553 | 551 |
554 chromeos::PowerPrefs::RegisterLoginProfilePrefs(registry); | 552 chromeos::PowerPrefs::RegisterLoginProfilePrefs(registry); |
555 } | 553 } |
556 #endif | 554 #endif |
557 | 555 |
558 void MigrateUserPrefs(Profile* profile) { | 556 void MigrateObsoleteProfilePrefs(PrefService* profile_prefs) { |
559 PrefService* prefs = profile->GetPrefs(); | 557 // This method should prune away migrations year+ old. |
gab
2015/02/23 16:09:38
s/migrations year+ old/year+ old migrations/
gab
2015/02/23 16:09:38
s/should prune away/should be pruned from/
(i.e.
rkaplow
2015/02/23 22:55:04
Done.
rkaplow
2015/02/23 22:55:04
true, wording was odd ;)
| |
560 | 558 |
561 // Cleanup prefs from now-removed protector feature. | 559 #if defined(OS_MACOSX) && !defined(OS_IOS) |
562 prefs->ClearPref(kBackupPref); | 560 // Added 06/2014. |
561 autofill::AutofillManager::MigrateUserPrefs(profile_prefs); | |
562 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | |
563 | |
564 // Added 07/2014. | |
565 translate::TranslatePrefs::MigrateUserPrefs(profile_prefs, | |
566 prefs::kAcceptLanguages); | |
563 | 567 |
564 #if !defined(OS_ANDROID) | 568 #if !defined(OS_ANDROID) |
569 // Added 08/2014. | |
565 // Migrate kNetworkPredictionEnabled to kNetworkPredictionOptions when not on | 570 // Migrate kNetworkPredictionEnabled to kNetworkPredictionOptions when not on |
566 // Android. On Android, platform-specific code performs preference migration. | 571 // Android. On Android, platform-specific code performs preference migration. |
567 // TODO(bnc): https://crbug.com/401970 Remove migration code one year after | 572 // TODO(bnc): https://crbug.com/401970 Remove migration code one year after |
568 // M38. | 573 // M38. |
569 chrome_browser_net::MigrateNetworkPredictionUserPrefs(prefs); | 574 chrome_browser_net::MigrateNetworkPredictionUserPrefs(profile_prefs); |
575 #endif | |
576 } | |
gab
2015/02/23 16:09:38
Looks like you'll need to sync/merge again for the
rkaplow
2015/02/23 22:55:04
Done.
| |
577 | |
578 void MigrateObsoleteBrowserPrefs(PrefService* local_state) { | |
579 // This method should prune away migrations year+ old. | |
gab
2015/02/23 16:09:37
Same comments as above.
rkaplow
2015/02/23 22:55:04
Done.
| |
580 | |
581 // Added 05/2014. | |
582 #if defined(TOOLKIT_VIEWS) | |
583 MigrateBrowserTabStripPrefs(local_state); | |
570 #endif | 584 #endif |
571 | 585 |
572 PromoResourceService::MigrateUserPrefs(prefs); | 586 // Added 08/2014. |
573 translate::TranslatePrefs::MigrateUserPrefs(prefs, prefs::kAcceptLanguages); | |
574 | |
575 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
576 autofill::AutofillManager::MigrateUserPrefs(prefs); | |
577 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | |
578 } | |
579 | |
580 void MigrateBrowserPrefs(Profile* profile, PrefService* local_state) { | |
581 // Copy pref values which have been migrated to user_prefs from local_state, | |
582 // or remove them from local_state outright, if copying is not required. | |
583 int current_version = | |
584 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); | |
585 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>( | |
586 local_state->DeprecatedGetPrefRegistry()); | |
gab
2015/02/23 16:09:38
Woot, one less call to DeprecatedGetPrefRegistry()
rkaplow
2015/02/23 23:27:52
:)
| |
587 | |
588 if (!(current_version & DNS_PREFS)) { | |
gab
2015/02/23 16:09:37
Looks like you can now also get rid of the enum de
rkaplow
2015/02/23 23:27:52
Done.
| |
589 registry->RegisterListPref(prefs::kDnsStartupPrefetchList); | |
590 local_state->ClearPref(prefs::kDnsStartupPrefetchList); | |
591 | |
592 registry->RegisterListPref(prefs::kDnsHostReferralList); | |
593 local_state->ClearPref(prefs::kDnsHostReferralList); | |
594 | |
595 current_version |= DNS_PREFS; | |
596 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | |
597 current_version); | |
598 } | |
599 | |
600 PrefService* user_prefs = profile->GetPrefs(); | |
601 if (!(current_version & WINDOWS_PREFS)) { | |
602 registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | |
603 if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) { | |
604 const PrefService::Preference* pref = | |
605 local_state->FindPreference(prefs::kBrowserWindowPlacement); | |
606 DCHECK(pref); | |
607 user_prefs->Set(prefs::kBrowserWindowPlacement, | |
608 *(pref->GetValue())); | |
609 } | |
610 local_state->ClearPref(prefs::kBrowserWindowPlacement); | |
611 | |
612 current_version |= WINDOWS_PREFS; | |
613 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | |
614 current_version); | |
615 } | |
616 | |
617 #if !defined(OS_ANDROID) | 587 #if !defined(OS_ANDROID) |
618 local_state->ClearPref(kLegacyProfileResetPromptMemento); | 588 local_state->ClearPref(kLegacyProfileResetPromptMemento); |
619 #endif | 589 #endif |
620 | |
621 #if defined(OS_CHROMEOS) | |
622 chromeos::default_pinned_apps_field_trial::MigratePrefs(local_state); | |
gab
2015/02/23 16:09:38
Also clean up this no longer call method (and all
rkaplow
2015/02/23 23:27:52
Done.
| |
623 #endif | |
624 | |
625 #if defined(TOOLKIT_VIEWS) | |
626 MigrateBrowserTabStripPrefs(local_state); | |
gab
2015/02/23 16:09:38
Also remove call (and associated registrations) @
rkaplow
2015/02/23 23:27:52
Done.
| |
627 #endif | |
628 } | 590 } |
629 | 591 |
630 // As part of the migration from per-profile to per-partition HostZoomMaps, | 592 // As part of the migration from per-profile to per-partition HostZoomMaps, |
631 // we need to detect if an existing per-profile set of preferences exist, and | 593 // we need to detect if an existing per-profile set of preferences exist, and |
632 // if so convert them to be per-partition. We migrate any per-profile zoom | 594 // if so convert them to be per-partition. We migrate any per-profile zoom |
633 // level prefs via zoom_level_prefs. | 595 // level prefs via zoom_level_prefs. |
634 // Code that updates zoom prefs in the profile prefs store has been removed, | 596 // Code that updates zoom prefs in the profile prefs store has been removed, |
635 // so once we clear these values here, they should never get set again. | 597 // so once we clear these values here, they should never get set again. |
636 // TODO(wjmaclean): Remove this migration machinery after histograms show | 598 // TODO(wjmaclean): Remove this migration machinery after histograms show |
637 // that an aceptable percentage of users have been migrated. | 599 // that an aceptable percentage of users have been migrated. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 host_zoom_dictionary, false /* sanitize_partition_host_zoom_levels */); | 636 host_zoom_dictionary, false /* sanitize_partition_host_zoom_levels */); |
675 | 637 |
676 // We're done migrating the profile per-host zoom level values, so we clear | 638 // We're done migrating the profile per-host zoom level values, so we clear |
677 // them all. | 639 // them all. |
678 DictionaryPrefUpdate host_zoom_dictionary_update( | 640 DictionaryPrefUpdate host_zoom_dictionary_update( |
679 prefs, prefs::kPerHostZoomLevelsDeprecated); | 641 prefs, prefs::kPerHostZoomLevelsDeprecated); |
680 host_zoom_dictionary_update->Clear(); | 642 host_zoom_dictionary_update->Clear(); |
681 } | 643 } |
682 | 644 |
683 } // namespace chrome | 645 } // namespace chrome |
OLD | NEW |