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 <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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 // TODO(bnc): https://crbug.com/401970 Remove migration code one year after | 575 // TODO(bnc): https://crbug.com/401970 Remove migration code one year after |
| 576 // M38. | 576 // M38. |
| 577 chrome_browser_net::MigrateNetworkPredictionUserPrefs(profile_prefs); | 577 chrome_browser_net::MigrateNetworkPredictionUserPrefs(profile_prefs); |
| 578 #endif | 578 #endif |
| 579 | 579 |
| 580 #if defined(OS_CHROMEOS) && defined(ENABLE_APP_LIST) | 580 #if defined(OS_CHROMEOS) && defined(ENABLE_APP_LIST) |
| 581 // Added 02/2015. | 581 // Added 02/2015. |
| 582 MigrateGoogleNowPrefs(profile); | 582 MigrateGoogleNowPrefs(profile); |
| 583 #endif | 583 #endif |
| 584 } | 584 } |
| 585 | 585 |
|
gab
2015/08/18 20:39:40
https://codereview.chromium.org/541103002/diff/104
wjmaclean
2015/08/19 13:53:34
Sorry, forgot about that.
| |
| 586 // As part of the migration from per-profile to per-partition HostZoomMaps, | |
| 587 // we need to detect if an existing per-profile set of preferences exist, and | |
| 588 // if so convert them to be per-partition. We migrate any per-profile zoom | |
| 589 // level prefs via zoom_level_prefs. | |
| 590 // Code that updates zoom prefs in the profile prefs store has been removed, | |
| 591 // so once we clear these values here, they should never get set again. | |
| 592 // TODO(wjmaclean): Remove this migration machinery after histograms show | |
| 593 // that an aceptable percentage of users have been migrated. | |
| 594 // crbug.com/420643 | |
| 595 void MigrateProfileZoomLevelPrefs(Profile* profile) { | |
| 596 PrefService* prefs = profile->GetPrefs(); | |
| 597 chrome::ChromeZoomLevelPrefs* zoom_level_prefs = profile->GetZoomLevelPrefs(); | |
| 598 DCHECK(zoom_level_prefs); | |
| 599 | |
| 600 bool migrated = false; | |
| 601 // Only migrate the default zoom level if it is not equal to the registered | |
| 602 // default for the preference. | |
| 603 const base::Value* per_profile_default_zoom_level_value = | |
| 604 prefs->GetUserPrefValue(prefs::kDefaultZoomLevelDeprecated); | |
| 605 if (per_profile_default_zoom_level_value) { | |
| 606 if (per_profile_default_zoom_level_value->GetType() == | |
| 607 base::Value::TYPE_DOUBLE) { | |
| 608 double per_profile_default_zoom_level = 0.0; | |
| 609 bool success = per_profile_default_zoom_level_value->GetAsDouble( | |
| 610 &per_profile_default_zoom_level); | |
| 611 DCHECK(success); | |
| 612 zoom_level_prefs->SetDefaultZoomLevelPref(per_profile_default_zoom_level); | |
| 613 } | |
| 614 prefs->ClearPref(prefs::kDefaultZoomLevelDeprecated); | |
| 615 migrated = true; | |
| 616 } | |
| 617 | |
| 618 const base::DictionaryValue* host_zoom_dictionary = | |
| 619 prefs->GetDictionary(prefs::kPerHostZoomLevelsDeprecated); | |
| 620 // Collect stats on frequency with which migrations are occuring. This measure | |
| 621 // is not perfect, since it will consider an un-migrated user with only | |
| 622 // default value as being already migrated, but it will catch all non-trivial | |
| 623 // migrations. | |
| 624 migrated |= !host_zoom_dictionary->empty(); | |
| 625 UMA_HISTOGRAM_BOOLEAN("Settings.ZoomLevelPreferencesMigrated", migrated); | |
|
gab
2015/08/18 20:39:40
Also mark this histogram as obsolete.
wjmaclean
2015/08/19 13:53:34
Done. I didn't realize that histograms had an 'obs
| |
| 626 | |
| 627 // Since |host_zoom_dictionary| is not partition-based, do not attempt to | |
| 628 // sanitize it. | |
| 629 zoom_level_prefs->ExtractPerHostZoomLevels( | |
| 630 host_zoom_dictionary, false /* sanitize_partition_host_zoom_levels */); | |
| 631 | |
| 632 // We're done migrating the profile per-host zoom level values, so we clear | |
| 633 // them all. | |
| 634 DictionaryPrefUpdate host_zoom_dictionary_update( | |
| 635 prefs, prefs::kPerHostZoomLevelsDeprecated); | |
| 636 host_zoom_dictionary_update->Clear(); | |
| 637 } | |
| 638 | |
| 639 } // namespace chrome | 586 } // namespace chrome |
| OLD | NEW |