Index: content/browser/loader/async_resource_handler.cc |
diff --git a/content/browser/loader/async_resource_handler.cc b/content/browser/loader/async_resource_handler.cc |
index 599767b01c1292ee6c3e7360492d120262fe7a5b..11f581486c1391a863828890f0490843f3aa7dd6 100644 |
--- a/content/browser/loader/async_resource_handler.cc |
+++ b/content/browser/loader/async_resource_handler.cc |
@@ -7,6 +7,7 @@ |
#include <algorithm> |
#include <vector> |
+#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/containers/hash_tables.h" |
#include "base/debug/alias.h" |
@@ -314,6 +315,30 @@ bool AsyncResourceHandler::OnRequestRedirected( |
GetRequestID(), redirect_info, response->head)); |
} |
+namespace { |
+ |
+// Defined here to be close to OnResponseStarted(), which is the only caller. |
+void SetZoomLevelForViewFromWebContents( |
+ ResourceRequestInfo::WebContentsGetter request_web_contents_getter, |
+ base::WeakPtr<ResourceMessageFilter> filter, |
+ int render_view_id, |
+ const GURL request_url) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ |
+ WebContents* web_contents = request_web_contents_getter.Run(); |
+ if (!web_contents) |
+ return; |
+ |
+ double zoom_level = HostZoomMap::GetZoomLevel(web_contents); |
+ |
+ if (filter) { |
+ filter->Send(new ViewMsg_SetZoomLevelForLoadingURL( |
+ render_view_id, request_url, zoom_level)); |
+ } |
+} |
+ |
+} // namespace anonymous |
+ |
bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response, |
bool* defer) { |
// For changes to the main frame, inform the renderer of the new URL's |
@@ -357,6 +382,18 @@ bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response, |
info->filter()->Send(new ViewMsg_SetZoomLevelForLoadingURL( |
render_view_id, request_url, zoom_level)); |
+ } else if (info->GetResourceType() == RESOURCE_TYPE_SUB_FRAME && |
+ host_zoom_map) { |
+ // Sub-frames should use the zoom level of their web-contents, regardless of |
+ // their URL. We must access the WebContents on the UI thread. |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind( |
+ &SetZoomLevelForViewFromWebContents, |
+ info->GetWebContentsGetterForRequest(), |
+ info->filter()->GetWeakPtr(), |
+ info->GetRouteID(), |
+ request()->url())); |
} |
// If the parent handler downloaded the resource to a file, grant the child |