Chromium Code Reviews| Index: content/browser/host_zoom_map_impl.cc |
| diff --git a/content/browser/host_zoom_map_impl.cc b/content/browser/host_zoom_map_impl.cc |
| index 9c595ef0f24f17687add77b175740d964cc626d0..2ab83ed79fe6258e8ac1fa89fe23101ce5193fff 100644 |
| --- a/content/browser/host_zoom_map_impl.cc |
| +++ b/content/browser/host_zoom_map_impl.cc |
| @@ -21,6 +21,7 @@ |
| #include "content/public/browser/notification_types.h" |
| #include "content/public/browser/resource_context.h" |
| #include "content/public/common/page_zoom.h" |
| +#include "content/public/common/url_constants.h" |
| #include "net/base/net_util.h" |
| namespace content { |
| @@ -43,11 +44,21 @@ std::string GetHostFromProcessView(int render_process_id, int render_view_id) { |
| if (!entry) |
| return std::string(); |
| - return net::GetHostOrSpecFromURL(entry->GetURL()); |
| + return net::GetHostOrSpecFromURL(HostZoomMap::GetURLFromEntry(entry)); |
| } |
| } // namespace |
| +GURL HostZoomMap::GetURLFromEntry(const NavigationEntry* entry) { |
|
Charlie Reis
2014/10/28 16:36:21
I'm confused why we're defining HostZoomMap method
wjmaclean
2014/10/28 17:37:04
I think the idea was to create convenience functio
Charlie Reis
2014/10/28 19:09:44
Thanks. I realized there's precedent for this in
|
| + switch (entry->GetPageType()) { |
| + case PAGE_TYPE_ERROR: |
| + return GURL(kUnreachableWebDataURL); |
| + // In future, give interstitial pages special treatment as well. |
|
Charlie Reis
2014/10/28 16:36:21
nit: In future -> TODO(wjmaclean):
wjmaclean
2014/10/28 17:37:04
Done.
|
| + default: |
| + return entry->GetURL(); |
| + } |
| +} |
| + |
| HostZoomMap* HostZoomMap::GetDefaultForBrowserContext(BrowserContext* context) { |
| HostZoomMapImpl* rv = static_cast<HostZoomMapImpl*>( |
| context->GetUserData(kHostZoomMapKeyName)); |
| @@ -76,6 +87,14 @@ void HostZoomMap::SetZoomLevel(const WebContents* web_contents, double level) { |
| *static_cast<const WebContentsImpl*>(web_contents), level); |
| } |
| +void HostZoomMap::SendErrorPageZoomLevelRefresh( |
| + const WebContents* web_contents) { |
| + HostZoomMapImpl* host_zoom_map = |
| + static_cast<HostZoomMapImpl*>(HostZoomMap::GetDefaultForBrowserContext( |
| + web_contents->GetBrowserContext())); |
| + host_zoom_map->SendErrorPageZoomLevelRefresh(); |
| +} |
| + |
| HostZoomMapImpl::HostZoomMapImpl() |
| : default_zoom_level_(0.0) { |
| registrar_.Add( |
| @@ -253,7 +272,7 @@ double HostZoomMapImpl::GetZoomLevelForWebContents( |
| // It is possible for a WebContent's zoom level to be queried before |
| // a navigation has occurred. |
| if (entry) |
| - url = entry->GetURL(); |
| + url = GetURLFromEntry(entry); |
| return GetZoomLevelForHostAndScheme(url.scheme(), |
| net::GetHostOrSpecFromURL(url)); |
| } |
| @@ -277,7 +296,7 @@ void HostZoomMapImpl::SetZoomLevelForWebContents( |
| if (!entry) |
| return; |
| - GURL url = entry->GetURL(); |
| + GURL url = GetURLFromEntry(entry); |
| SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), level); |
| } |
| } |
| @@ -384,6 +403,16 @@ void HostZoomMapImpl::SendZoomLevelChange(const std::string& scheme, |
| } |
| } |
| +void HostZoomMapImpl::SendErrorPageZoomLevelRefresh() { |
| + GURL error_url(kUnreachableWebDataURL); |
| + std::string host = net::GetHostOrSpecFromURL(error_url); |
| + double error_page_zoom_level = GetZoomLevelForHost(host); |
| + if (error_page_zoom_level == default_zoom_level_) |
|
Charlie Reis
2014/10/28 16:36:21
What happens if the renderer had a different zoom
wjmaclean
2014/10/28 17:37:04
Good catch ... we should probably always just send
|
| + return; |
| + |
| + SendZoomLevelChange("", host, error_page_zoom_level); |
|
Bernhard Bauer
2014/10/28 14:55:22
Using an empty std::string() constructor instead o
wjmaclean
2014/10/28 17:37:04
I wondered if that might be better; I'll add it in
|
| +} |
| + |
| HostZoomMapImpl::~HostZoomMapImpl() { |
| } |