Index: content/browser/web_contents/web_contents_impl.cc |
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc |
index 6b1407b78e0ace939218a24a5478b0c23d48f1c3..d5585bbad278bdbefa61112f7021e822305aaf2d 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -413,6 +413,7 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context) |
BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), |
audio_stream_monitor_(this), |
virtual_keyboard_requested_(false), |
+ page_scale_factor_is_one_(true), |
loading_weak_factory_(this) { |
frame_tree_.SetFrameRemoveListener( |
base::Bind(&WebContentsImpl::OnFrameRemoved, |
@@ -637,6 +638,8 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, |
OnDidRunInsecureContent) |
IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_PageScaleFactorChanged, |
+ OnPageScaleFactorChanged) |
IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
IPC_MESSAGE_HANDLER(FrameHostMsg_RegisterProtocolHandler, |
OnRegisterProtocolHandler) |
@@ -2628,8 +2631,8 @@ int WebContentsImpl::GetMaximumZoomPercent() const { |
return maximum_zoom_percent_; |
} |
-void WebContentsImpl::ResetPageScale() { |
- Send(new ViewMsg_ResetPageScale(GetRoutingID())); |
+void WebContentsImpl::SetPageScale(float page_scale_factor) { |
+ Send(new ViewMsg_SetPageScale(GetRoutingID(), page_scale_factor)); |
} |
gfx::Size WebContentsImpl::GetPreferredSize() const { |
@@ -2968,6 +2971,14 @@ void WebContentsImpl::DidNavigateMainFramePostCommit( |
// Reset theme color on navigation to new page. |
theme_color_ = SK_ColorTRANSPARENT; |
+ |
+ // We need the renderer to send us its page scale factor |
+ // so that we have a notification for the inital page scale factor, |
+ // and so that we are notified upon navigation to a page with a default |
+ // page scale factor (notifications about resetting the page scale factor |
+ // upon navigation are filtered in the RenderView while it's swapped out |
+ // so we ask for it again here). |
+ Send(new ViewMsg_GetPageScale(GetRoutingID())); |
Charlie Reis
2015/10/30 18:42:58
This doesn't make sense to me. The renderer proce
Kevin McNee - google account
2015/10/30 21:41:31
Done.
Yeah, that works.
|
} |
if (!details.is_in_page) { |
@@ -3127,6 +3138,26 @@ void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, |
maximum_zoom_percent_ = maximum_percent; |
} |
+void WebContentsImpl::OnPageScaleFactorChanged(float page_scale_factor) { |
+ bool is_one = page_scale_factor == 1.f; |
+ if (is_one != page_scale_factor_is_one_) { |
+ page_scale_factor_is_one_ = is_one; |
+ |
+ HostZoomMapImpl* host_zoom_map = |
+ static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); |
+ |
+ if (host_zoom_map && GetRenderProcessHost()) { |
+ host_zoom_map->SetPageScaleFactorIsOneForView( |
+ GetRenderProcessHost()->GetID(), GetRoutingID(), |
+ page_scale_factor_is_one_); |
+ } |
+ } |
+ |
+ FOR_EACH_OBSERVER(WebContentsObserver, |
+ observers_, |
+ OnPageScaleFactorChanged(page_scale_factor)); |
+} |
+ |
void WebContentsImpl::OnEnumerateDirectory(int request_id, |
const base::FilePath& path) { |
if (!delegate_) |