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

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

Issue 1488653002: Fix scroll restoration when exiting fullscreen mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from avi@ Created 4 years, 11 months 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); 1649 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
1650 if (widget_view) { 1650 if (widget_view) {
1651 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) 1651 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())
1652 ->ShutdownAndDestroyWidget(true); 1652 ->ShutdownAndDestroyWidget(true);
1653 } 1653 }
1654 1654
1655 if (delegate_) 1655 if (delegate_)
1656 delegate_->EnterFullscreenModeForTab(this, origin); 1656 delegate_->EnterFullscreenModeForTab(this, origin);
1657 1657
1658 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1658 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1659 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab( 1659 DidToggleFullscreenModeForTab(
1660 GetRenderViewHost()->GetWidget()))); 1660 IsFullscreenForCurrentTab(
1661 GetRenderViewHost()->GetWidget()),
1662 false));
1661 } 1663 }
1662 1664
1663 void WebContentsImpl::ExitFullscreenMode() { 1665 void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) {
1664 // This method is being called to leave renderer-initiated fullscreen mode. 1666 // This method is being called to leave renderer-initiated fullscreen mode.
1665 // Make sure any existing fullscreen widget is shut down first. 1667 // Make sure any existing fullscreen widget is shut down first.
1666 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); 1668 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
1667 if (widget_view) { 1669 if (widget_view) {
1668 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) 1670 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())
1669 ->ShutdownAndDestroyWidget(true); 1671 ->ShutdownAndDestroyWidget(true);
1670 } 1672 }
1671 1673
1672 #if defined(OS_ANDROID) 1674 #if defined(OS_ANDROID)
1673 ContentVideoView* video_view = ContentVideoView::GetInstance(); 1675 ContentVideoView* video_view = ContentVideoView::GetInstance();
1674 if (video_view != NULL) 1676 if (video_view != NULL)
1675 video_view->OnExitFullscreen(); 1677 video_view->OnExitFullscreen();
1676 #endif 1678 #endif
1677 1679
1678 if (delegate_) 1680 if (delegate_)
1679 delegate_->ExitFullscreenModeForTab(this); 1681 delegate_->ExitFullscreenModeForTab(this);
1680 1682
1681 // Ensure web contents exit fullscreen state by sending a resize message, 1683 // The fullscreen state is communicated to the renderer through a resize
1682 // which includes the fullscreen state. This is required for the situation 1684 // message. If the change in fullscreen state doesn't cause a view resize
1683 // of the browser moving the view into a fullscreen state "browser fullscreen" 1685 // then we must ensure web contents exit the fullscreen state by explicitly
1684 // and then the contents entering "tab fullscreen". Exiting the contents 1686 // sending a resize message. This is required for the situation of the browser
1685 // "tab fullscreen" then won't have the side effect of the view resizing, 1687 // moving the view into a "browser fullscreen" state and then the contents
1686 // hence the explicit call here is required. 1688 // entering "tab fullscreen". Exiting the contents "tab fullscreen" then won't
1687 if (RenderWidgetHostView* rwh_view = GetRenderWidgetHostView()) { 1689 // have the side effect of the view resizing, hence the explicit call here is
1688 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) 1690 // required.
1689 render_widget_host->WasResized(); 1691 if (!will_cause_resize) {
1692 if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) {
1693 if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost())
1694 render_widget_host->WasResized();
1695 }
1690 } 1696 }
1691 1697
1692 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1698 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1693 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab( 1699 DidToggleFullscreenModeForTab(
1694 GetRenderViewHost()->GetWidget()))); 1700 IsFullscreenForCurrentTab(
1701 GetRenderViewHost()->GetWidget()),
1702 will_cause_resize));
1695 } 1703 }
1696 1704
1697 bool WebContentsImpl::IsFullscreenForCurrentTab( 1705 bool WebContentsImpl::IsFullscreenForCurrentTab(
1698 RenderWidgetHostImpl* render_widget_host) const { 1706 RenderWidgetHostImpl* render_widget_host) const {
1699 if (!RenderViewHostImpl::From(render_widget_host)) 1707 if (!RenderViewHostImpl::From(render_widget_host))
1700 return false; 1708 return false;
1701 1709
1702 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; 1710 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false;
1703 } 1711 }
1704 1712
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 } 2861 }
2854 2862
2855 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { 2863 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) {
2856 manifest_manager_host_->GetManifest(GetMainFrame(), callback); 2864 manifest_manager_host_->GetManifest(GetMainFrame(), callback);
2857 } 2865 }
2858 2866
2859 void WebContentsImpl::HasManifest(const HasManifestCallback& callback) { 2867 void WebContentsImpl::HasManifest(const HasManifestCallback& callback) {
2860 manifest_manager_host_->HasManifest(GetMainFrame(), callback); 2868 manifest_manager_host_->HasManifest(GetMainFrame(), callback);
2861 } 2869 }
2862 2870
2863 void WebContentsImpl::ExitFullscreen() { 2871 void WebContentsImpl::ExitFullscreen(bool will_cause_resize) {
2864 // Clean up related state and initiate the fullscreen exit. 2872 // Clean up related state and initiate the fullscreen exit.
2865 GetRenderViewHost()->GetWidget()->RejectMouseLockOrUnlockIfNecessary(); 2873 GetRenderViewHost()->GetWidget()->RejectMouseLockOrUnlockIfNecessary();
2866 ExitFullscreenMode(); 2874 ExitFullscreenMode(will_cause_resize);
2867 } 2875 }
2868 2876
2869 void WebContentsImpl::ResumeLoadingCreatedWebContents() { 2877 void WebContentsImpl::ResumeLoadingCreatedWebContents() {
2870 if (delayed_open_url_params_.get()) { 2878 if (delayed_open_url_params_.get()) {
2871 OpenURL(*delayed_open_url_params_.get()); 2879 OpenURL(*delayed_open_url_params_.get());
2872 delayed_open_url_params_.reset(nullptr); 2880 delayed_open_url_params_.reset(nullptr);
2873 return; 2881 return;
2874 } 2882 }
2875 2883
2876 // Resume blocked requests for both the RenderViewHost and RenderFrameHost. 2884 // Resume blocked requests for both the RenderViewHost and RenderFrameHost.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3039 void WebContentsImpl::DidNavigateMainFramePreCommit( 3047 void WebContentsImpl::DidNavigateMainFramePreCommit(
3040 bool navigation_is_within_page) { 3048 bool navigation_is_within_page) {
3041 // Ensure fullscreen mode is exited before committing the navigation to a 3049 // Ensure fullscreen mode is exited before committing the navigation to a
3042 // different page. The next page will not start out assuming it is in 3050 // different page. The next page will not start out assuming it is in
3043 // fullscreen mode. 3051 // fullscreen mode.
3044 if (navigation_is_within_page) { 3052 if (navigation_is_within_page) {
3045 // No page change? Then, the renderer and browser can remain in fullscreen. 3053 // No page change? Then, the renderer and browser can remain in fullscreen.
3046 return; 3054 return;
3047 } 3055 }
3048 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) 3056 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget()))
3049 ExitFullscreen(); 3057 ExitFullscreen(false);
3050 DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())); 3058 DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget()));
3051 } 3059 }
3052 3060
3053 void WebContentsImpl::DidNavigateMainFramePostCommit( 3061 void WebContentsImpl::DidNavigateMainFramePostCommit(
3054 RenderFrameHostImpl* render_frame_host, 3062 RenderFrameHostImpl* render_frame_host,
3055 const LoadCommittedDetails& details, 3063 const LoadCommittedDetails& details,
3056 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 3064 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
3057 if (details.is_navigation_to_different_page()) { 3065 if (details.is_navigation_to_different_page()) {
3058 // Clear the status bubble. This is a workaround for a bug where WebKit 3066 // Clear the status bubble. This is a workaround for a bug where WebKit
3059 // doesn't let us know that the cursor left an element during a 3067 // doesn't let us know that the cursor left an element during a
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
3911 base::TerminationStatus status, 3919 base::TerminationStatus status,
3912 int error_code) { 3920 int error_code) {
3913 if (rvh != GetRenderViewHost()) { 3921 if (rvh != GetRenderViewHost()) {
3914 // The pending page's RenderViewHost is gone. 3922 // The pending page's RenderViewHost is gone.
3915 return; 3923 return;
3916 } 3924 }
3917 3925
3918 // Ensure fullscreen mode is exited in the |delegate_| since a crashed 3926 // Ensure fullscreen mode is exited in the |delegate_| since a crashed
3919 // renderer may not have made a clean exit. 3927 // renderer may not have made a clean exit.
3920 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) 3928 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget()))
3921 ExitFullscreenMode(); 3929 ExitFullscreenMode(false);
3922 3930
3923 // Cancel any visible dialogs so they are not left dangling over the sad tab. 3931 // Cancel any visible dialogs so they are not left dangling over the sad tab.
3924 CancelActiveAndPendingDialogs(); 3932 CancelActiveAndPendingDialogs();
3925 3933
3926 if (delegate_) 3934 if (delegate_)
3927 delegate_->HideValidationMessage(this); 3935 delegate_->HideValidationMessage(this);
3928 3936
3929 SetIsLoading(false, true, nullptr); 3937 SetIsLoading(false, true, nullptr);
3930 NotifyDisconnected(); 3938 NotifyDisconnected();
3931 SetIsCrashed(status, error_code); 3939 SetIsCrashed(status, error_code);
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
4721 const WebContentsObserver::MediaPlayerId& id) { 4729 const WebContentsObserver::MediaPlayerId& id) {
4722 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); 4730 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id));
4723 } 4731 }
4724 4732
4725 void WebContentsImpl::MediaStoppedPlaying( 4733 void WebContentsImpl::MediaStoppedPlaying(
4726 const WebContentsObserver::MediaPlayerId& id) { 4734 const WebContentsObserver::MediaPlayerId& id) {
4727 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); 4735 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id));
4728 } 4736 }
4729 4737
4730 } // namespace content 4738 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698