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..d9092df2e98f5302f1c11df64fedfadf481cd39b 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, |
+ prefs::kPartitionPerHostZoomLevels); |
} |
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, |
+ const char* dictionary_path) { |
std::vector<std::string> keys_to_remove; |
scoped_ptr<base::DictionaryValue> host_zoom_dictionary_copy( |
host_zoom_dictionary->DeepCopyWithoutEmptyChildren()); |
@@ -174,11 +178,18 @@ 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 (strcmp(dictionary_path, prefs::kPartitionPerHostZoomLevels) != 0) |
+ return; |
+ |
// Sanitize prefs to remove entries that match the default zoom level and/or |
// have an empty host. |
{ |
- DictionaryPrefUpdate update(pref_service_, |
- prefs::kPartitionPerHostZoomLevels); |
+ DictionaryPrefUpdate update(pref_service_, dictionary_path); |
base::DictionaryValue* host_zoom_dictionaries = update.Get(); |
base::DictionaryValue* host_zoom_dictionary = nullptr; |
host_zoom_dictionaries->GetDictionary(partition_key_, |