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

Side by Side Diff: chrome/browser/host_zoom_map.cc

Issue 6248026: Rename Real* to Double* in values.* and dependent files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More renames Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <cmath> 5 #include <cmath>
6 6
7 #include "chrome/browser/host_zoom_map.h" 7 #include "chrome/browser/host_zoom_map.h"
8 8
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 12 matching lines...) Expand all
23 #include "net/base/net_util.h" 23 #include "net/base/net_util.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
25 25
26 using WebKit::WebView; 26 using WebKit::WebView;
27 27
28 HostZoomMap::HostZoomMap(Profile* profile) 28 HostZoomMap::HostZoomMap(Profile* profile)
29 : profile_(profile), 29 : profile_(profile),
30 updating_preferences_(false) { 30 updating_preferences_(false) {
31 Load(); 31 Load();
32 default_zoom_level_ = 32 default_zoom_level_ =
33 profile_->GetPrefs()->GetReal(prefs::kDefaultZoomLevel); 33 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel);
34 registrar_.Add(this, NotificationType::PROFILE_DESTROYED, 34 registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
35 Source<Profile>(profile)); 35 Source<Profile>(profile));
36 // Don't observe pref changes (e.g. from sync) in Incognito; once we create 36 // Don't observe pref changes (e.g. from sync) in Incognito; once we create
37 // the incognito window it should have no further connection to the main 37 // the incognito window it should have no further connection to the main
38 // profile/prefs. 38 // profile/prefs.
39 if (!profile_->IsOffTheRecord()) { 39 if (!profile_->IsOffTheRecord()) {
40 pref_change_registrar_.Init(profile_->GetPrefs()); 40 pref_change_registrar_.Init(profile_->GetPrefs());
41 pref_change_registrar_.Add(prefs::kPerHostZoomLevels, this); 41 pref_change_registrar_.Add(prefs::kPerHostZoomLevels, this);
42 pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this); 42 pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this);
43 } 43 }
(...skipping 11 matching lines...) Expand all
55 host_zoom_levels_.clear(); 55 host_zoom_levels_.clear();
56 const DictionaryValue* host_zoom_dictionary = 56 const DictionaryValue* host_zoom_dictionary =
57 profile_->GetPrefs()->GetDictionary(prefs::kPerHostZoomLevels); 57 profile_->GetPrefs()->GetDictionary(prefs::kPerHostZoomLevels);
58 // Careful: The returned value could be NULL if the pref has never been set. 58 // Careful: The returned value could be NULL if the pref has never been set.
59 if (host_zoom_dictionary != NULL) { 59 if (host_zoom_dictionary != NULL) {
60 for (DictionaryValue::key_iterator i(host_zoom_dictionary->begin_keys()); 60 for (DictionaryValue::key_iterator i(host_zoom_dictionary->begin_keys());
61 i != host_zoom_dictionary->end_keys(); ++i) { 61 i != host_zoom_dictionary->end_keys(); ++i) {
62 const std::string& host(*i); 62 const std::string& host(*i);
63 double zoom_level = 0; 63 double zoom_level = 0;
64 64
65 bool success = host_zoom_dictionary->GetRealWithoutPathExpansion( 65 bool success = host_zoom_dictionary->GetDoubleWithoutPathExpansion(
66 host, &zoom_level); 66 host, &zoom_level);
67 if (!success) { 67 if (!success) {
68 // The data used to be stored as ints, so try that. 68 // The data used to be stored as ints, so try that.
69 int int_zoom_level; 69 int int_zoom_level;
70 success = host_zoom_dictionary->GetIntegerWithoutPathExpansion( 70 success = host_zoom_dictionary->GetIntegerWithoutPathExpansion(
71 host, &int_zoom_level); 71 host, &int_zoom_level);
72 if (success) { 72 if (success) {
73 zoom_level = static_cast<double>(int_zoom_level); 73 zoom_level = static_cast<double>(int_zoom_level);
74 // Since the values were once stored as non-clamped, clamp now. 74 // Since the values were once stored as non-clamped, clamp now.
75 double zoom_factor = WebView::zoomLevelToZoomFactor(zoom_level); 75 double zoom_factor = WebView::zoomLevelToZoomFactor(zoom_level);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 updating_preferences_ = true; 127 updating_preferences_ = true;
128 { 128 {
129 ScopedPrefUpdate update(profile_->GetPrefs(), prefs::kPerHostZoomLevels); 129 ScopedPrefUpdate update(profile_->GetPrefs(), prefs::kPerHostZoomLevels);
130 DictionaryValue* host_zoom_dictionary = 130 DictionaryValue* host_zoom_dictionary =
131 profile_->GetPrefs()->GetMutableDictionary(prefs::kPerHostZoomLevels); 131 profile_->GetPrefs()->GetMutableDictionary(prefs::kPerHostZoomLevels);
132 if (level == default_zoom_level_) { 132 if (level == default_zoom_level_) {
133 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL); 133 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL);
134 } else { 134 } else {
135 host_zoom_dictionary->SetWithoutPathExpansion( 135 host_zoom_dictionary->SetWithoutPathExpansion(
136 host, Value::CreateRealValue(level)); 136 host, Value::CreateDoubleValue(level));
137 } 137 }
138 } 138 }
139 updating_preferences_ = false; 139 updating_preferences_ = false;
140 } 140 }
141 141
142 double HostZoomMap::GetTemporaryZoomLevel(int render_process_id, 142 double HostZoomMap::GetTemporaryZoomLevel(int render_process_id,
143 int render_view_id) const { 143 int render_view_id) const {
144 base::AutoLock auto_lock(lock_); 144 base::AutoLock auto_lock(lock_);
145 for (size_t i = 0; i < temporary_zoom_levels_.size(); ++i) { 145 for (size_t i = 0; i < temporary_zoom_levels_.size(); ++i) {
146 if (temporary_zoom_levels_[i].render_process_id == render_process_id && 146 if (temporary_zoom_levels_[i].render_process_id == render_process_id &&
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 break; 238 break;
239 } 239 }
240 case NotificationType::PREF_CHANGED: { 240 case NotificationType::PREF_CHANGED: {
241 // If we are updating our own preference, don't reload. 241 // If we are updating our own preference, don't reload.
242 if (!updating_preferences_) { 242 if (!updating_preferences_) {
243 std::string* name = Details<std::string>(details).ptr(); 243 std::string* name = Details<std::string>(details).ptr();
244 if (prefs::kPerHostZoomLevels == *name) 244 if (prefs::kPerHostZoomLevels == *name)
245 Load(); 245 Load();
246 else if (prefs::kDefaultZoomLevel == *name) { 246 else if (prefs::kDefaultZoomLevel == *name) {
247 default_zoom_level_ = 247 default_zoom_level_ =
248 profile_->GetPrefs()->GetReal(prefs::kDefaultZoomLevel); 248 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel);
249 } 249 }
250 } 250 }
251 break; 251 break;
252 } 252 }
253 default: 253 default:
254 NOTREACHED() << "Unexpected preference observed."; 254 NOTREACHED() << "Unexpected preference observed.";
255 } 255 }
256 } 256 }
257 257
258 HostZoomMap::~HostZoomMap() { 258 HostZoomMap::~HostZoomMap() {
259 Shutdown(); 259 Shutdown();
260 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698