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) { |
| 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 bool success = per_profile_default_zoom_level_value->GetAsDouble( |
| 670 &per_profile_default_zoom_level); |
| 671 DCHECK(success); |
| 672 zoom_level_prefs->SetDefaultZoomLevelPref(per_profile_default_zoom_level); |
| 673 } |
| 674 prefs->ClearPref(prefs::kDefaultZoomLevelDeprecated); |
| 675 migrated = true; |
| 676 } |
| 677 |
| 678 const base::DictionaryValue* host_zoom_dictionary = |
| 679 prefs->GetDictionary(prefs::kPerHostZoomLevelsDeprecated); |
| 680 // Collect stats on frequency with which migrations are occuring. This measure |
| 681 // is not perfect, since it will consider an un-migrated user with only |
| 682 // default value as being already migrated, but it will catch all non-trivial |
| 683 // migrations. |
| 684 migrated |= !host_zoom_dictionary->empty(); |
| 685 UMA_HISTOGRAM_BOOLEAN("Settings.ZoomLevelPreferencesMigrated", migrated); |
| 686 |
| 687 zoom_level_prefs->ExtractPerHostZoomLevels(host_zoom_dictionary); |
| 688 |
| 689 // We're done migrating the profile per-host zoom level values, so we clear |
| 690 // them all. |
| 691 DictionaryPrefUpdate host_zoom_dictionary_update( |
| 692 prefs, prefs::kPerHostZoomLevelsDeprecated); |
| 693 host_zoom_dictionary_update->Clear(); |
| 694 } |
| 695 |
643 } // namespace chrome | 696 } // namespace chrome |
OLD | NEW |