Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // Ensure web contents exit fullscreen state by sending a resize message, |
| 1682 // which includes the fullscreen state. This is required for the situation | 1684 // which includes the fullscreen state. This is required for the situation |
| 1683 // of the browser moving the view into a fullscreen state "browser fullscreen" | 1685 // of the browser moving the view into a fullscreen state "browser fullscreen" |
| 1684 // and then the contents entering "tab fullscreen". Exiting the contents | 1686 // and then the contents entering "tab fullscreen". Exiting the contents |
| 1685 // "tab fullscreen" then won't have the side effect of the view resizing, | 1687 // "tab fullscreen" then won't have the side effect of the view resizing, |
| 1686 // hence the explicit call here is required. | 1688 // hence the explicit call here is required. |
|
Avi (use Gerrit)
2016/01/05 16:17:57
Does this comment need a change? It talks about al
bokan
2016/01/05 17:15:47
I've made it clearer that this is only for the cas
| |
| 1687 if (RenderWidgetHostView* rwh_view = GetRenderWidgetHostView()) { | 1689 if (!will_cause_resize) { |
| 1688 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) | 1690 if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) { |
| 1689 render_widget_host->WasResized(); | 1691 if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost()) |
| 1692 render_widget_host->WasResized(); | |
| 1693 } | |
| 1690 } | 1694 } |
| 1691 | 1695 |
| 1692 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1696 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1693 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab( | 1697 DidToggleFullscreenModeForTab( |
| 1694 GetRenderViewHost()->GetWidget()))); | 1698 IsFullscreenForCurrentTab( |
| 1699 GetRenderViewHost()->GetWidget()), | |
| 1700 will_cause_resize)); | |
| 1695 } | 1701 } |
| 1696 | 1702 |
| 1697 bool WebContentsImpl::IsFullscreenForCurrentTab( | 1703 bool WebContentsImpl::IsFullscreenForCurrentTab( |
| 1698 RenderWidgetHostImpl* render_widget_host) const { | 1704 RenderWidgetHostImpl* render_widget_host) const { |
| 1699 if (!RenderViewHostImpl::From(render_widget_host)) | 1705 if (!RenderViewHostImpl::From(render_widget_host)) |
| 1700 return false; | 1706 return false; |
| 1701 | 1707 |
| 1702 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; | 1708 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; |
| 1703 } | 1709 } |
| 1704 | 1710 |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2853 } | 2859 } |
| 2854 | 2860 |
| 2855 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { | 2861 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { |
| 2856 manifest_manager_host_->GetManifest(GetMainFrame(), callback); | 2862 manifest_manager_host_->GetManifest(GetMainFrame(), callback); |
| 2857 } | 2863 } |
| 2858 | 2864 |
| 2859 void WebContentsImpl::HasManifest(const HasManifestCallback& callback) { | 2865 void WebContentsImpl::HasManifest(const HasManifestCallback& callback) { |
| 2860 manifest_manager_host_->HasManifest(GetMainFrame(), callback); | 2866 manifest_manager_host_->HasManifest(GetMainFrame(), callback); |
| 2861 } | 2867 } |
| 2862 | 2868 |
| 2863 void WebContentsImpl::ExitFullscreen() { | 2869 void WebContentsImpl::ExitFullscreen(bool will_cause_resize) { |
| 2864 // Clean up related state and initiate the fullscreen exit. | 2870 // Clean up related state and initiate the fullscreen exit. |
| 2865 GetRenderViewHost()->GetWidget()->RejectMouseLockOrUnlockIfNecessary(); | 2871 GetRenderViewHost()->GetWidget()->RejectMouseLockOrUnlockIfNecessary(); |
| 2866 ExitFullscreenMode(); | 2872 ExitFullscreenMode(will_cause_resize); |
| 2867 } | 2873 } |
| 2868 | 2874 |
| 2869 void WebContentsImpl::ResumeLoadingCreatedWebContents() { | 2875 void WebContentsImpl::ResumeLoadingCreatedWebContents() { |
| 2870 if (delayed_open_url_params_.get()) { | 2876 if (delayed_open_url_params_.get()) { |
| 2871 OpenURL(*delayed_open_url_params_.get()); | 2877 OpenURL(*delayed_open_url_params_.get()); |
| 2872 delayed_open_url_params_.reset(nullptr); | 2878 delayed_open_url_params_.reset(nullptr); |
| 2873 return; | 2879 return; |
| 2874 } | 2880 } |
| 2875 | 2881 |
| 2876 // Resume blocked requests for both the RenderViewHost and RenderFrameHost. | 2882 // Resume blocked requests for both the RenderViewHost and RenderFrameHost. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3039 void WebContentsImpl::DidNavigateMainFramePreCommit( | 3045 void WebContentsImpl::DidNavigateMainFramePreCommit( |
| 3040 bool navigation_is_within_page) { | 3046 bool navigation_is_within_page) { |
| 3041 // Ensure fullscreen mode is exited before committing the navigation to a | 3047 // 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 | 3048 // different page. The next page will not start out assuming it is in |
| 3043 // fullscreen mode. | 3049 // fullscreen mode. |
| 3044 if (navigation_is_within_page) { | 3050 if (navigation_is_within_page) { |
| 3045 // No page change? Then, the renderer and browser can remain in fullscreen. | 3051 // No page change? Then, the renderer and browser can remain in fullscreen. |
| 3046 return; | 3052 return; |
| 3047 } | 3053 } |
| 3048 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) | 3054 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) |
| 3049 ExitFullscreen(); | 3055 ExitFullscreen(false); |
| 3050 DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())); | 3056 DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())); |
| 3051 } | 3057 } |
| 3052 | 3058 |
| 3053 void WebContentsImpl::DidNavigateMainFramePostCommit( | 3059 void WebContentsImpl::DidNavigateMainFramePostCommit( |
| 3054 RenderFrameHostImpl* render_frame_host, | 3060 RenderFrameHostImpl* render_frame_host, |
| 3055 const LoadCommittedDetails& details, | 3061 const LoadCommittedDetails& details, |
| 3056 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3062 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 3057 if (details.is_navigation_to_different_page()) { | 3063 if (details.is_navigation_to_different_page()) { |
| 3058 // Clear the status bubble. This is a workaround for a bug where WebKit | 3064 // 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 | 3065 // 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 Loading... | |
| 3911 base::TerminationStatus status, | 3917 base::TerminationStatus status, |
| 3912 int error_code) { | 3918 int error_code) { |
| 3913 if (rvh != GetRenderViewHost()) { | 3919 if (rvh != GetRenderViewHost()) { |
| 3914 // The pending page's RenderViewHost is gone. | 3920 // The pending page's RenderViewHost is gone. |
| 3915 return; | 3921 return; |
| 3916 } | 3922 } |
| 3917 | 3923 |
| 3918 // Ensure fullscreen mode is exited in the |delegate_| since a crashed | 3924 // Ensure fullscreen mode is exited in the |delegate_| since a crashed |
| 3919 // renderer may not have made a clean exit. | 3925 // renderer may not have made a clean exit. |
| 3920 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) | 3926 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) |
| 3921 ExitFullscreenMode(); | 3927 ExitFullscreenMode(false); |
| 3922 | 3928 |
| 3923 // Cancel any visible dialogs so they are not left dangling over the sad tab. | 3929 // Cancel any visible dialogs so they are not left dangling over the sad tab. |
| 3924 CancelActiveAndPendingDialogs(); | 3930 CancelActiveAndPendingDialogs(); |
| 3925 | 3931 |
| 3926 if (delegate_) | 3932 if (delegate_) |
| 3927 delegate_->HideValidationMessage(this); | 3933 delegate_->HideValidationMessage(this); |
| 3928 | 3934 |
| 3929 SetIsLoading(false, true, nullptr); | 3935 SetIsLoading(false, true, nullptr); |
| 3930 NotifyDisconnected(); | 3936 NotifyDisconnected(); |
| 3931 SetIsCrashed(status, error_code); | 3937 SetIsCrashed(status, error_code); |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4721 const WebContentsObserver::MediaPlayerId& id) { | 4727 const WebContentsObserver::MediaPlayerId& id) { |
| 4722 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); | 4728 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); |
| 4723 } | 4729 } |
| 4724 | 4730 |
| 4725 void WebContentsImpl::MediaStoppedPlaying( | 4731 void WebContentsImpl::MediaStoppedPlaying( |
| 4726 const WebContentsObserver::MediaPlayerId& id) { | 4732 const WebContentsObserver::MediaPlayerId& id) { |
| 4727 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); | 4733 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); |
| 4728 } | 4734 } |
| 4729 | 4735 |
| 4730 } // namespace content | 4736 } // namespace content |
| OLD | NEW |