Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5820)

Unified Diff: chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc

Issue 665283002: Fix crash in ChromeZoomLevelPrefs::ExtractPerHostZoomLevels(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wjmResetZoomLevel
Patch Set: Convert parameter to bool. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/zoom/chrome_zoom_level_prefs.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc
diff --git a/chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc b/chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc
index 08879def07c1dc960e1f442cf673f1844a61ca1a..c49e0d3d3321a9f4a585e9b053336fd6954b91e2 100644
--- a/chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc
+++ b/chrome/browser/ui/zoom/chrome_zoom_level_prefs.cc
@@ -78,7 +78,8 @@ void ChromeZoomLevelPrefs::InitPrefsAndCopyToHostZoomMap(
// Since we're calling this before setting up zoom_subscription_ below we
// don't need to worry that host_zoom_dictionary is indirectly affected
// by calls to HostZoomMap::SetZoomLevelForHost().
- ExtractPerHostZoomLevels(host_zoom_dictionary);
+ ExtractPerHostZoomLevels(host_zoom_dictionary,
+ true /* sanitize_partition_host_zoom_levels */);
}
zoom_subscription_ = host_zoom_map_->AddZoomLevelChangedCallback(base::Bind(
&ChromeZoomLevelPrefs::OnZoomLevelChanged, base::Unretained(this)));
@@ -144,8 +145,11 @@ void ChromeZoomLevelPrefs::OnZoomLevelChanged(
host_zoom_dictionary->SetDoubleWithoutPathExpansion(change.host, level);
}
+// TODO(wjmaclean): Remove the dictionary_path once the migration code is
+// removed. crbug.com/420643
void ChromeZoomLevelPrefs::ExtractPerHostZoomLevels(
- const base::DictionaryValue* host_zoom_dictionary) {
+ const base::DictionaryValue* host_zoom_dictionary,
+ bool sanitize_partition_host_zoom_levels) {
std::vector<std::string> keys_to_remove;
scoped_ptr<base::DictionaryValue> host_zoom_dictionary_copy(
host_zoom_dictionary->DeepCopyWithoutEmptyChildren());
@@ -174,6 +178,14 @@ void ChromeZoomLevelPrefs::ExtractPerHostZoomLevels(
host_zoom_map_->SetZoomLevelForHost(host, zoom_level);
}
+ // We don't bother sanitizing non-partition dictionaries as they will be
+ // discarded in the migration process. Note: since the structure of partition
+ // per-host zoom level dictionaries is different from the legacy profile
+ // per-host zoom level dictionaries, the following code will fail if run
+ // on the legacy dictionaries.
+ if (!sanitize_partition_host_zoom_levels)
+ return;
+
// Sanitize prefs to remove entries that match the default zoom level and/or
// have an empty host.
{
« no previous file with comments | « chrome/browser/ui/zoom/chrome_zoom_level_prefs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698