OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/zoom/chrome_zoom_level_prefs.h" | 5 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/json_pref_store.h" | 8 #include "base/prefs/json_pref_store.h" |
9 #include "base/prefs/pref_filter.h" | 9 #include "base/prefs/pref_filter.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 else | 123 else |
124 host_zoom_dictionary->SetDoubleWithoutPathExpansion(change.host, level); | 124 host_zoom_dictionary->SetDoubleWithoutPathExpansion(change.host, level); |
125 } | 125 } |
126 | 126 |
127 // TODO(wjmaclean): Remove the dictionary_path once the migration code is | 127 // TODO(wjmaclean): Remove the dictionary_path once the migration code is |
128 // removed. crbug.com/420643 | 128 // removed. crbug.com/420643 |
129 void ChromeZoomLevelPrefs::ExtractPerHostZoomLevels( | 129 void ChromeZoomLevelPrefs::ExtractPerHostZoomLevels( |
130 const base::DictionaryValue* host_zoom_dictionary, | 130 const base::DictionaryValue* host_zoom_dictionary, |
131 bool sanitize_partition_host_zoom_levels) { | 131 bool sanitize_partition_host_zoom_levels) { |
132 std::vector<std::string> keys_to_remove; | 132 std::vector<std::string> keys_to_remove; |
133 scoped_ptr<base::DictionaryValue> host_zoom_dictionary_copy( | 133 scoped_ptr<base::DictionaryValue> host_zoom_dictionary_copy = |
134 host_zoom_dictionary->DeepCopyWithoutEmptyChildren()); | 134 host_zoom_dictionary->DeepCopyWithoutEmptyChildren(); |
135 for (base::DictionaryValue::Iterator i(*host_zoom_dictionary_copy); | 135 for (base::DictionaryValue::Iterator i(*host_zoom_dictionary_copy); |
136 !i.IsAtEnd(); | 136 !i.IsAtEnd(); |
137 i.Advance()) { | 137 i.Advance()) { |
138 const std::string& host(i.key()); | 138 const std::string& host(i.key()); |
139 double zoom_level = 0; | 139 double zoom_level = 0; |
140 | 140 |
141 bool has_valid_zoom_level = i.value().GetAsDouble(&zoom_level); | 141 bool has_valid_zoom_level = i.value().GetAsDouble(&zoom_level); |
142 | 142 |
143 // Filter out A) the empty host, B) zoom levels equal to the default; and | 143 // Filter out A) the empty host, B) zoom levels equal to the default; and |
144 // remember them, so that we can later erase them from Prefs. | 144 // remember them, so that we can later erase them from Prefs. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // don't need to worry that host_zoom_dictionary is indirectly affected | 200 // don't need to worry that host_zoom_dictionary is indirectly affected |
201 // by calls to HostZoomMap::SetZoomLevelForHost(). | 201 // by calls to HostZoomMap::SetZoomLevelForHost(). |
202 ExtractPerHostZoomLevels(host_zoom_dictionary, | 202 ExtractPerHostZoomLevels(host_zoom_dictionary, |
203 true /* sanitize_partition_host_zoom_levels */); | 203 true /* sanitize_partition_host_zoom_levels */); |
204 } | 204 } |
205 zoom_subscription_ = host_zoom_map_->AddZoomLevelChangedCallback(base::Bind( | 205 zoom_subscription_ = host_zoom_map_->AddZoomLevelChangedCallback(base::Bind( |
206 &ChromeZoomLevelPrefs::OnZoomLevelChanged, base::Unretained(this))); | 206 &ChromeZoomLevelPrefs::OnZoomLevelChanged, base::Unretained(this))); |
207 } | 207 } |
208 | 208 |
209 } // namespace chrome | 209 } // namespace chrome |
OLD | NEW |