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

Side by Side Diff: content/browser/host_zoom_map_impl.cc

Issue 320863002: Don't assume WebContents has a LastCommittedEntry when setting zoom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/host_zoom_map_impl.h" 5 #include "content/browser/host_zoom_map_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 double level) { 240 double level) {
241 int render_process_id = web_contents_impl.GetRenderProcessHost()->GetID(); 241 int render_process_id = web_contents_impl.GetRenderProcessHost()->GetID();
242 int render_view_id = web_contents_impl.GetRenderViewHost()->GetRoutingID(); 242 int render_view_id = web_contents_impl.GetRenderViewHost()->GetRoutingID();
243 if (UsesTemporaryZoomLevel(render_process_id, render_view_id)) { 243 if (UsesTemporaryZoomLevel(render_process_id, render_view_id)) {
244 SetTemporaryZoomLevel(render_process_id, render_view_id, level); 244 SetTemporaryZoomLevel(render_process_id, render_view_id, level);
245 } else { 245 } else {
246 // Get the url from the navigation controller directly, as calling 246 // Get the url from the navigation controller directly, as calling
247 // WebContentsImpl::GetLastCommittedURL() may give us a virtual url that 247 // WebContentsImpl::GetLastCommittedURL() may give us a virtual url that
248 // is different than what the render view is using. If the two don't match, 248 // is different than what the render view is using. If the two don't match,
249 // the attempt to set the zoom will fail. 249 // the attempt to set the zoom will fail.
250 GURL url;
251 NavigationEntry* entry = 250 NavigationEntry* entry =
252 web_contents_impl.GetController().GetLastCommittedEntry(); 251 web_contents_impl.GetController().GetLastCommittedEntry();
253 DCHECK(entry); 252 // Tests may invoke this function with a null entry, but we don't
254 url = entry->GetURL(); 253 // want to save zoom levels in this case.
254 if (!entry)
255 return;
256
257 GURL url = entry->GetURL();
255 SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), level); 258 SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), level);
256 } 259 }
257 } 260 }
258 261
259 void HostZoomMapImpl::SetZoomLevelForView(int render_process_id, 262 void HostZoomMapImpl::SetZoomLevelForView(int render_process_id,
260 int render_view_id, 263 int render_view_id,
261 double level, 264 double level,
262 const std::string& host) { 265 const std::string& host) {
263 if (UsesTemporaryZoomLevel(render_process_id, render_view_id)) 266 if (UsesTemporaryZoomLevel(render_process_id, render_view_id))
264 SetTemporaryZoomLevel(render_process_id, render_view_id, level); 267 SetTemporaryZoomLevel(render_process_id, render_view_id, level);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 zoom_level(0.0) { 387 zoom_level(0.0) {
385 } 388 }
386 389
387 bool HostZoomMapImpl::TemporaryZoomLevel::operator==( 390 bool HostZoomMapImpl::TemporaryZoomLevel::operator==(
388 const TemporaryZoomLevel& other) const { 391 const TemporaryZoomLevel& other) const {
389 return other.render_process_id == render_process_id && 392 return other.render_process_id == render_process_id &&
390 other.render_view_id == render_view_id; 393 other.render_view_id == render_view_id;
391 } 394 }
392 395
393 } // namespace content 396 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698