summaryrefslogtreecommitdiffstats
path: root/content/browser/host_zoom_map_impl.cc
diff options
context:
space:
mode:
authorwjmaclean@chromium.org <wjmaclean@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 23:13:30 +0000
committerwjmaclean@chromium.org <wjmaclean@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 23:13:30 +0000
commitacda0ef3c7584b332255eb0f232ed0b147fe784d (patch)
treea8d3ecdb5639cf35806a12f4abc5fae6a5faab02 /content/browser/host_zoom_map_impl.cc
parent4733b04fdfe90f0d2c4cafe4a40d96d91d05fe36 (diff)
downloadchromium_src-acda0ef3c7584b332255eb0f232ed0b147fe784d.zip
chromium_src-acda0ef3c7584b332255eb0f232ed0b147fe784d.tar.gz
chromium_src-acda0ef3c7584b332255eb0f232ed0b147fe784d.tar.bz2
Fix issue with Virtual vs. real URLs.
In r273854 a regression was introduced in which HostZoomMapImpl::SetZoomLevelForWebContents() used a virtual url for setting page zoom, when the real url is required. This CL fixes that by calling GetLastCommittedEntry() on the WebContents navigation controller, instead of calling it directly on the WebContents; the latter returns a virtual url. BUG=379622 Review URL: https://codereview.chromium.org/301243018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275268 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/host_zoom_map_impl.cc')
-rw-r--r--content/browser/host_zoom_map_impl.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/content/browser/host_zoom_map_impl.cc b/content/browser/host_zoom_map_impl.cc
index a14b163..a0a68da 100644
--- a/content/browser/host_zoom_map_impl.cc
+++ b/content/browser/host_zoom_map_impl.cc
@@ -221,13 +221,16 @@ double HostZoomMapImpl::GetZoomLevelForWebContents(
if (UsesTemporaryZoomLevel(render_process_id, routing_id))
return GetTemporaryZoomLevel(render_process_id, routing_id);
- // Since zoom map is updated using the url as stored in the navigation
- // controller, we use that URL to get the zoom level.
+ // Get the url from the navigation controller directly, as calling
+ // WebContentsImpl::GetLastCommittedURL() may give us a virtual url that
+ // is different than is stored in the map.
GURL url;
NavigationEntry* entry =
web_contents_impl.GetController().GetLastCommittedEntry();
+ // It is possible for a WebContent's zoom level to be queried before
+ // a navigation has occurred.
if (entry)
- url = entry->GetURL();
+ url = entry->GetURL();
return GetZoomLevelForHostAndScheme(url.scheme(),
net::GetHostOrSpecFromURL(url));
}
@@ -238,12 +241,18 @@ void HostZoomMapImpl::SetZoomLevelForWebContents(
int render_process_id = web_contents_impl.GetRenderProcessHost()->GetID();
int render_view_id = web_contents_impl.GetRenderViewHost()->GetRoutingID();
if (UsesTemporaryZoomLevel(render_process_id, render_view_id)) {
-
SetTemporaryZoomLevel(render_process_id, render_view_id, level);
} else {
- SetZoomLevelForHost(
- net::GetHostOrSpecFromURL(web_contents_impl.GetLastCommittedURL()),
- level);
+ // Get the url from the navigation controller directly, as calling
+ // WebContentsImpl::GetLastCommittedURL() may give us a virtual url that
+ // is different than what the render view is using. If the two don't match,
+ // the attempt to set the zoom will fail.
+ GURL url;
+ NavigationEntry* entry =
+ web_contents_impl.GetController().GetLastCommittedEntry();
+ DCHECK(entry);
+ url = entry->GetURL();
+ SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), level);
}
}