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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1408393003: Propagate pageScaleFactor to GuestViews (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Give OnPageScaleFactorChanged suitable behaviour upon navigation Created 5 years, 1 month 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
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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), 406 fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
407 fullscreen_widget_had_focus_at_shutdown_(false), 407 fullscreen_widget_had_focus_at_shutdown_(false),
408 is_subframe_(false), 408 is_subframe_(false),
409 force_disable_overscroll_content_(false), 409 force_disable_overscroll_content_(false),
410 last_dialog_suppressed_(false), 410 last_dialog_suppressed_(false),
411 geolocation_service_context_(new GeolocationServiceContext()), 411 geolocation_service_context_(new GeolocationServiceContext()),
412 accessibility_mode_( 412 accessibility_mode_(
413 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), 413 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()),
414 audio_stream_monitor_(this), 414 audio_stream_monitor_(this),
415 virtual_keyboard_requested_(false), 415 virtual_keyboard_requested_(false),
416 page_scale_factor_is_one_(true),
416 loading_weak_factory_(this) { 417 loading_weak_factory_(this) {
417 frame_tree_.SetFrameRemoveListener( 418 frame_tree_.SetFrameRemoveListener(
418 base::Bind(&WebContentsImpl::OnFrameRemoved, 419 base::Bind(&WebContentsImpl::OnFrameRemoved,
419 base::Unretained(this))); 420 base::Unretained(this)));
420 #if defined(ENABLE_BROWSER_CDMS) 421 #if defined(ENABLE_BROWSER_CDMS)
421 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); 422 media_web_contents_observer_.reset(new MediaWebContentsObserver(this));
422 #endif 423 #endif
423 } 424 }
424 425
425 WebContentsImpl::~WebContentsImpl() { 426 WebContentsImpl::~WebContentsImpl() {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint, 631 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint,
631 OnFirstVisuallyNonEmptyPaint) 632 OnFirstVisuallyNonEmptyPaint)
632 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache, 633 IPC_MESSAGE_HANDLER(FrameHostMsg_DidLoadResourceFromMemoryCache,
633 OnDidLoadResourceFromMemoryCache) 634 OnDidLoadResourceFromMemoryCache)
634 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent, 635 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayInsecureContent,
635 OnDidDisplayInsecureContent) 636 OnDidDisplayInsecureContent)
636 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent, 637 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent,
637 OnDidRunInsecureContent) 638 OnDidRunInsecureContent)
638 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) 639 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset)
639 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) 640 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits)
641 IPC_MESSAGE_HANDLER(ViewHostMsg_PageScaleFactorChanged,
642 OnPageScaleFactorChanged)
640 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) 643 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory)
641 IPC_MESSAGE_HANDLER(FrameHostMsg_RegisterProtocolHandler, 644 IPC_MESSAGE_HANDLER(FrameHostMsg_RegisterProtocolHandler,
642 OnRegisterProtocolHandler) 645 OnRegisterProtocolHandler)
643 IPC_MESSAGE_HANDLER(FrameHostMsg_UnregisterProtocolHandler, 646 IPC_MESSAGE_HANDLER(FrameHostMsg_UnregisterProtocolHandler,
644 OnUnregisterProtocolHandler) 647 OnUnregisterProtocolHandler)
645 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdatePageImportanceSignals, 648 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdatePageImportanceSignals,
646 OnUpdatePageImportanceSignals) 649 OnUpdatePageImportanceSignals)
647 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) 650 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply)
648 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) 651 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed)
649 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) 652 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend)
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after
2621 } 2624 }
2622 2625
2623 int WebContentsImpl::GetMinimumZoomPercent() const { 2626 int WebContentsImpl::GetMinimumZoomPercent() const {
2624 return minimum_zoom_percent_; 2627 return minimum_zoom_percent_;
2625 } 2628 }
2626 2629
2627 int WebContentsImpl::GetMaximumZoomPercent() const { 2630 int WebContentsImpl::GetMaximumZoomPercent() const {
2628 return maximum_zoom_percent_; 2631 return maximum_zoom_percent_;
2629 } 2632 }
2630 2633
2631 void WebContentsImpl::ResetPageScale() { 2634 void WebContentsImpl::SetPageScale(float page_scale_factor) {
2632 Send(new ViewMsg_ResetPageScale(GetRoutingID())); 2635 Send(new ViewMsg_SetPageScale(GetRoutingID(), page_scale_factor));
2633 } 2636 }
2634 2637
2635 gfx::Size WebContentsImpl::GetPreferredSize() const { 2638 gfx::Size WebContentsImpl::GetPreferredSize() const {
2636 return capturer_count_ == 0 ? preferred_size_ : preferred_size_for_capture_; 2639 return capturer_count_ == 0 ? preferred_size_ : preferred_size_for_capture_;
2637 } 2640 }
2638 2641
2639 bool WebContentsImpl::GotResponseToLockMouseRequest(bool allowed) { 2642 bool WebContentsImpl::GotResponseToLockMouseRequest(bool allowed) {
2640 if (GetBrowserPluginGuest()) 2643 if (GetBrowserPluginGuest())
2641 return GetBrowserPluginGuest()->LockMouse(allowed); 2644 return GetBrowserPluginGuest()->LockMouse(allowed);
2642 2645
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2961 2964
2962 RenderWidgetHostViewBase* rwhvb = 2965 RenderWidgetHostViewBase* rwhvb =
2963 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); 2966 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView());
2964 if (rwhvb) 2967 if (rwhvb)
2965 rwhvb->OnDidNavigateMainFrameToNewPage(); 2968 rwhvb->OnDidNavigateMainFrameToNewPage();
2966 2969
2967 did_first_visually_non_empty_paint_ = false; 2970 did_first_visually_non_empty_paint_ = false;
2968 2971
2969 // Reset theme color on navigation to new page. 2972 // Reset theme color on navigation to new page.
2970 theme_color_ = SK_ColorTRANSPARENT; 2973 theme_color_ = SK_ColorTRANSPARENT;
2974
2975 // We need the renderer to send us its page scale factor
2976 // so that we have a notification for the inital page scale factor,
2977 // and so that we are notified upon navigation to a page with a default
2978 // page scale factor (notifications about resetting the page scale factor
2979 // upon navigation are filtered in the RenderView while it's swapped out
2980 // so we ask for it again here).
2981 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.
2971 } 2982 }
2972 2983
2973 if (!details.is_in_page) { 2984 if (!details.is_in_page) {
2974 // Once the main frame is navigated, we're no longer considered to have 2985 // Once the main frame is navigated, we're no longer considered to have
2975 // displayed insecure content. 2986 // displayed insecure content.
2976 displayed_insecure_content_ = false; 2987 displayed_insecure_content_ = false;
2977 SSLManager::NotifySSLInternalStateChanged( 2988 SSLManager::NotifySSLInternalStateChanged(
2978 GetController().GetBrowserContext()); 2989 GetController().GetBrowserContext());
2979 } 2990 }
2980 2991
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3120 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) 3131 if (!delegate_ || delegate_->OnGoToEntryOffset(offset))
3121 controller_.GoToOffset(offset); 3132 controller_.GoToOffset(offset);
3122 } 3133 }
3123 3134
3124 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, 3135 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent,
3125 int maximum_percent) { 3136 int maximum_percent) {
3126 minimum_zoom_percent_ = minimum_percent; 3137 minimum_zoom_percent_ = minimum_percent;
3127 maximum_zoom_percent_ = maximum_percent; 3138 maximum_zoom_percent_ = maximum_percent;
3128 } 3139 }
3129 3140
3141 void WebContentsImpl::OnPageScaleFactorChanged(float page_scale_factor) {
3142 bool is_one = page_scale_factor == 1.f;
3143 if (is_one != page_scale_factor_is_one_) {
3144 page_scale_factor_is_one_ = is_one;
3145
3146 HostZoomMapImpl* host_zoom_map =
3147 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this));
3148
3149 if (host_zoom_map && GetRenderProcessHost()) {
3150 host_zoom_map->SetPageScaleFactorIsOneForView(
3151 GetRenderProcessHost()->GetID(), GetRoutingID(),
3152 page_scale_factor_is_one_);
3153 }
3154 }
3155
3156 FOR_EACH_OBSERVER(WebContentsObserver,
3157 observers_,
3158 OnPageScaleFactorChanged(page_scale_factor));
3159 }
3160
3130 void WebContentsImpl::OnEnumerateDirectory(int request_id, 3161 void WebContentsImpl::OnEnumerateDirectory(int request_id,
3131 const base::FilePath& path) { 3162 const base::FilePath& path) {
3132 if (!delegate_) 3163 if (!delegate_)
3133 return; 3164 return;
3134 3165
3135 ChildProcessSecurityPolicyImpl* policy = 3166 ChildProcessSecurityPolicyImpl* policy =
3136 ChildProcessSecurityPolicyImpl::GetInstance(); 3167 ChildProcessSecurityPolicyImpl::GetInstance();
3137 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path)) 3168 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path))
3138 delegate_->EnumerateDirectory(this, request_id, path); 3169 delegate_->EnumerateDirectory(this, request_id, path);
3139 } 3170 }
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after
4650 return NULL; 4681 return NULL;
4651 } 4682 }
4652 4683
4653 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4684 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4654 force_disable_overscroll_content_ = force_disable; 4685 force_disable_overscroll_content_ = force_disable;
4655 if (view_) 4686 if (view_)
4656 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4687 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4657 } 4688 }
4658 4689
4659 } // namespace content 4690 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698