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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/metrics/histogram.h" | |
| 10 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
| 11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/prefs/scoped_user_pref_update.h" | |
| 12 #include "chrome/browser/about_flags.h" | 14 #include "chrome/browser/about_flags.h" |
| 13 #include "chrome/browser/accessibility/invert_bubble_prefs.h" | 15 #include "chrome/browser/accessibility/invert_bubble_prefs.h" |
| 14 #include "chrome/browser/apps/drive/drive_app_mapping.h" | 16 #include "chrome/browser/apps/drive/drive_app_mapping.h" |
| 15 #include "chrome/browser/apps/shortcut_manager.h" | 17 #include "chrome/browser/apps/shortcut_manager.h" |
| 16 #include "chrome/browser/autocomplete/zero_suggest_provider.h" | 18 #include "chrome/browser/autocomplete/zero_suggest_provider.h" |
| 17 #include "chrome/browser/background/background_mode_manager.h" | 19 #include "chrome/browser/background/background_mode_manager.h" |
| 18 #include "chrome/browser/browser_process_impl.h" | 20 #include "chrome/browser/browser_process_impl.h" |
| 19 #include "chrome/browser/browser_shutdown.h" | 21 #include "chrome/browser/browser_shutdown.h" |
| 20 #include "chrome/browser/chrome_content_browser_client.h" | 22 #include "chrome/browser/chrome_content_browser_client.h" |
| 21 #include "chrome/browser/component_updater/recovery_component_installer.h" | 23 #include "chrome/browser/component_updater/recovery_component_installer.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 73 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
| 72 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" | 74 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
| 73 #include "chrome/browser/ui/startup/autolaunch_prompt.h" | 75 #include "chrome/browser/ui/startup/autolaunch_prompt.h" |
| 74 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 76 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
| 75 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 77 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
| 76 #include "chrome/browser/ui/webui/flags_ui.h" | 78 #include "chrome/browser/ui/webui/flags_ui.h" |
| 77 #include "chrome/browser/ui/webui/instant_ui.h" | 79 #include "chrome/browser/ui/webui/instant_ui.h" |
| 78 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 80 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 79 #include "chrome/browser/ui/webui/plugins_ui.h" | 81 #include "chrome/browser/ui/webui/plugins_ui.h" |
| 80 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h" | 82 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h" |
| 83 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | |
| 81 #include "chrome/browser/upgrade_detector.h" | 84 #include "chrome/browser/upgrade_detector.h" |
| 82 #include "chrome/browser/web_resource/promo_resource_service.h" | 85 #include "chrome/browser/web_resource/promo_resource_service.h" |
| 83 #include "chrome/common/pref_names.h" | 86 #include "chrome/common/pref_names.h" |
| 84 #include "components/autofill/core/browser/autofill_manager.h" | 87 #include "components/autofill/core/browser/autofill_manager.h" |
| 85 #include "components/bookmarks/browser/bookmark_utils.h" | 88 #include "components/bookmarks/browser/bookmark_utils.h" |
| 86 #include "components/dom_distiller/core/distilled_page_prefs.h" | 89 #include "components/dom_distiller/core/distilled_page_prefs.h" |
| 87 #include "components/enhanced_bookmarks/bookmark_server_cluster_service.h" | 90 #include "components/enhanced_bookmarks/bookmark_server_cluster_service.h" |
| 88 #include "components/gcm_driver/gcm_channel_status_syncer.h" | 91 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
| 89 #include "components/google/core/browser/google_pref_names.h" | 92 #include "components/google/core/browser/google_pref_names.h" |
| 90 #include "components/google/core/browser/google_url_tracker.h" | 93 #include "components/google/core/browser/google_url_tracker.h" |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 | 636 |
| 634 #if defined(OS_CHROMEOS) | 637 #if defined(OS_CHROMEOS) |
| 635 chromeos::default_pinned_apps_field_trial::MigratePrefs(local_state); | 638 chromeos::default_pinned_apps_field_trial::MigratePrefs(local_state); |
| 636 #endif | 639 #endif |
| 637 | 640 |
| 638 #if defined(TOOLKIT_VIEWS) | 641 #if defined(TOOLKIT_VIEWS) |
| 639 MigrateBrowserTabStripPrefs(local_state); | 642 MigrateBrowserTabStripPrefs(local_state); |
| 640 #endif | 643 #endif |
| 641 } | 644 } |
| 642 | 645 |
| 646 // As part of the migration from per-profile to per-partition HostZoomMaps, | |
| 647 // we need to detect if an existing per-profile set of preferences exist, and | |
| 648 // if so convert them to be per-partition. We migrate any per-profile zoom | |
| 649 // level prefs via zoom_level_prefs. | |
| 650 // Code that updates zoom prefs in the profile prefs store has been removed, | |
| 651 // so once we clear these values here, they should never get set again. | |
| 652 // TODO(wjmaclean): Remove this migration machinery after histograms show | |
| 653 // that an aceptable percentage of users have been migrated. | |
| 654 // crbug.com/420643 | |
| 655 void MigrateProfileZoomLevelPrefs(Profile* profile) { | |
|
sky
2014/10/10 19:43:59
Is there test coverage of this?
wjmaclean
2014/10/10 20:23:02
Yes, a browser_test:
HostZoomMapMigrationBrowserT
| |
| 656 PrefService* prefs = profile->GetPrefs(); | |
| 657 chrome::ChromeZoomLevelPrefs* zoom_level_prefs = profile->GetZoomLevelPrefs(); | |
| 658 DCHECK(zoom_level_prefs); | |
| 659 | |
| 660 bool migrated = false; | |
| 661 // Only migrate the default zoom level if it is not equal to the registered | |
| 662 // default for the preference. | |
| 663 const base::Value* per_profile_default_zoom_level_value = | |
| 664 prefs->GetUserPrefValue(prefs::kDefaultZoomLevelDeprecated); | |
| 665 if (per_profile_default_zoom_level_value) { | |
| 666 if (per_profile_default_zoom_level_value->GetType() == | |
| 667 base::Value::TYPE_DOUBLE) { | |
| 668 double per_profile_default_zoom_level = 0.0; | |
| 669 per_profile_default_zoom_level_value->GetAsDouble( | |
|
sky
2014/10/10 19:43:59
Add a temp here and DCHECK returns true.
wjmaclean
2014/10/10 20:23:02
Done.
| |
| 670 &per_profile_default_zoom_level); | |
| 671 zoom_level_prefs->SetDefaultZoomLevelPref(per_profile_default_zoom_level); | |
| 672 } | |
| 673 prefs->ClearPref(prefs::kDefaultZoomLevelDeprecated); | |
| 674 migrated = true; | |
| 675 } | |
| 676 | |
| 677 const base::DictionaryValue* host_zoom_dictionary = | |
| 678 prefs->GetDictionary(prefs::kPerHostZoomLevelsDeprecated); | |
| 679 // Collect stats on frequency with which migrations are occuring. This measure | |
| 680 // is not perfect, since it will consider an un-migrated user with only | |
| 681 // default value as being already migrated, but it will catch all non-trivial | |
| 682 // migrations. | |
| 683 migrated |= !host_zoom_dictionary->empty(); | |
| 684 UMA_HISTOGRAM_BOOLEAN("Settings.ZoomLevelPreferencesMigrated", migrated); | |
| 685 | |
| 686 zoom_level_prefs->ExtractPerHostZoomLevels(host_zoom_dictionary); | |
| 687 | |
| 688 // We're done migrating the profile per-host zoom level values, so we clear | |
| 689 // them all. | |
| 690 DictionaryPrefUpdate host_zoom_dictionary_update( | |
| 691 prefs, prefs::kPerHostZoomLevelsDeprecated); | |
| 692 host_zoom_dictionary_update->Clear(); | |
| 693 } | |
| 694 | |
| 643 } // namespace chrome | 695 } // namespace chrome |
| OLD | NEW |