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

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

Issue 6413014: Original patch from issue 570048 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a few fixes 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 prefs->RegisterDictionaryPref(prefs::kPerHostZoomLevels); 93 prefs->RegisterDictionaryPref(prefs::kPerHostZoomLevels);
94 } 94 }
95 95
96 double HostZoomMap::GetZoomLevel(const GURL& url) const { 96 double HostZoomMap::GetZoomLevel(const GURL& url) const {
97 std::string host(net::GetHostOrSpecFromURL(url)); 97 std::string host(net::GetHostOrSpecFromURL(url));
98 base::AutoLock auto_lock(lock_); 98 base::AutoLock auto_lock(lock_);
99 HostZoomLevels::const_iterator i(host_zoom_levels_.find(host)); 99 HostZoomLevels::const_iterator i(host_zoom_levels_.find(host));
100 return (i == host_zoom_levels_.end()) ? default_zoom_level_ : i->second; 100 return (i == host_zoom_levels_.end()) ? default_zoom_level_ : i->second;
101 } 101 }
102 102
103 void HostZoomMap::SetZoomLevel(const GURL& url, double level) { 103 void HostZoomMap::SetZoomLevel(const GURL& url, int request_id, double level) {
104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
105 if (!profile_) 105 if (!profile_)
106 return; 106 return;
107 107
108 std::string host(net::GetHostOrSpecFromURL(url)); 108 std::string host(net::GetHostOrSpecFromURL(url));
109 109
110 { 110 {
111 base::AutoLock auto_lock(lock_); 111 base::AutoLock auto_lock(lock_);
112 if (level == default_zoom_level_) 112 if (level == default_zoom_level_)
113 host_zoom_levels_.erase(host); 113 host_zoom_levels_.erase(host);
114 else 114 else
115 host_zoom_levels_[host] = level; 115 host_zoom_levels_[host] = level;
116 } 116 }
117 117
118 NotificationService::current()->Notify(NotificationType::ZOOM_LEVEL_CHANGED, 118 NotificationService::current()->Notify(NotificationType::ZOOM_LEVEL_CHANGED,
119 Source<Profile>(profile_), 119 Source<Profile>(profile_),
120 NotificationService::NoDetails()); 120 Details<int>(&request_id));
121 121
122 // If we're in incognito mode, don't persist changes to the prefs. We'll keep 122 // If we're in incognito mode, don't persist changes to the prefs. We'll keep
123 // them in memory only so they will be forgotten on exiting incognito. 123 // them in memory only so they will be forgotten on exiting incognito.
124 if (profile_->IsOffTheRecord()) 124 if (profile_->IsOffTheRecord())
125 return; 125 return;
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 =
(...skipping 15 matching lines...) Expand all
146 if (temporary_zoom_levels_[i].render_process_id == render_process_id && 146 if (temporary_zoom_levels_[i].render_process_id == render_process_id &&
147 temporary_zoom_levels_[i].render_view_id == render_view_id) { 147 temporary_zoom_levels_[i].render_view_id == render_view_id) {
148 return temporary_zoom_levels_[i].zoom_level; 148 return temporary_zoom_levels_[i].zoom_level;
149 } 149 }
150 } 150 }
151 return 0; 151 return 0;
152 } 152 }
153 153
154 void HostZoomMap::SetTemporaryZoomLevel(int render_process_id, 154 void HostZoomMap::SetTemporaryZoomLevel(int render_process_id,
155 int render_view_id, 155 int render_view_id,
156 int request_id,
156 double level) { 157 double level) {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 if (!profile_) 159 if (!profile_)
159 return; 160 return;
160 161
161 { 162 {
162 base::AutoLock auto_lock(lock_); 163 base::AutoLock auto_lock(lock_);
163 size_t i; 164 size_t i;
164 for (i = 0; i < temporary_zoom_levels_.size(); ++i) { 165 for (i = 0; i < temporary_zoom_levels_.size(); ++i) {
165 if (temporary_zoom_levels_[i].render_process_id == render_process_id && 166 if (temporary_zoom_levels_[i].render_process_id == render_process_id &&
(...skipping 11 matching lines...) Expand all
177 TemporaryZoomLevel temp; 178 TemporaryZoomLevel temp;
178 temp.render_process_id = render_process_id; 179 temp.render_process_id = render_process_id;
179 temp.render_view_id = render_view_id; 180 temp.render_view_id = render_view_id;
180 temp.zoom_level = level; 181 temp.zoom_level = level;
181 temporary_zoom_levels_.push_back(temp); 182 temporary_zoom_levels_.push_back(temp);
182 } 183 }
183 } 184 }
184 185
185 NotificationService::current()->Notify(NotificationType::ZOOM_LEVEL_CHANGED, 186 NotificationService::current()->Notify(NotificationType::ZOOM_LEVEL_CHANGED,
186 Source<Profile>(profile_), 187 Source<Profile>(profile_),
187 NotificationService::NoDetails()); 188 Details<int>(&request_id));
188 } 189 }
189 190
190 void HostZoomMap::ResetToDefaults() { 191 void HostZoomMap::ResetToDefaults() {
191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
192 if (!profile_) 193 if (!profile_)
193 return; 194 return;
194 195
195 { 196 {
196 base::AutoLock auto_lock(lock_); 197 base::AutoLock auto_lock(lock_);
197 host_zoom_levels_.clear(); 198 host_zoom_levels_.clear();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 break; 252 break;
252 } 253 }
253 default: 254 default:
254 NOTREACHED() << "Unexpected preference observed."; 255 NOTREACHED() << "Unexpected preference observed.";
255 } 256 }
256 } 257 }
257 258
258 HostZoomMap::~HostZoomMap() { 259 HostZoomMap::~HostZoomMap() {
259 Shutdown(); 260 Shutdown();
260 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698