| 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 <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); | 1678 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); |
| 1679 if (widget_view) { | 1679 if (widget_view) { |
| 1680 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) | 1680 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) |
| 1681 ->ShutdownAndDestroyWidget(true); | 1681 ->ShutdownAndDestroyWidget(true); |
| 1682 } | 1682 } |
| 1683 | 1683 |
| 1684 if (delegate_) | 1684 if (delegate_) |
| 1685 delegate_->EnterFullscreenModeForTab(this, origin); | 1685 delegate_->EnterFullscreenModeForTab(this, origin); |
| 1686 | 1686 |
| 1687 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1687 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1688 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab( | 1688 DidToggleFullscreenModeForTab( |
| 1689 GetRenderViewHost()->GetWidget()))); | 1689 IsFullscreenForCurrentTab( |
| 1690 GetRenderViewHost()->GetWidget()), |
| 1691 false)); |
| 1690 } | 1692 } |
| 1691 | 1693 |
| 1692 void WebContentsImpl::ExitFullscreenMode() { | 1694 void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) { |
| 1693 // This method is being called to leave renderer-initiated fullscreen mode. | 1695 // This method is being called to leave renderer-initiated fullscreen mode. |
| 1694 // Make sure any existing fullscreen widget is shut down first. | 1696 // Make sure any existing fullscreen widget is shut down first. |
| 1695 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); | 1697 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); |
| 1696 if (widget_view) { | 1698 if (widget_view) { |
| 1697 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) | 1699 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) |
| 1698 ->ShutdownAndDestroyWidget(true); | 1700 ->ShutdownAndDestroyWidget(true); |
| 1699 } | 1701 } |
| 1700 | 1702 |
| 1701 #if defined(OS_ANDROID) | 1703 #if defined(OS_ANDROID) |
| 1702 ContentVideoView* video_view = ContentVideoView::GetInstance(); | 1704 ContentVideoView* video_view = ContentVideoView::GetInstance(); |
| 1703 if (video_view != NULL) | 1705 if (video_view != NULL) |
| 1704 video_view->ExitFullscreen(); | 1706 video_view->ExitFullscreen(); |
| 1705 #endif | 1707 #endif |
| 1706 | 1708 |
| 1707 if (delegate_) | 1709 if (delegate_) |
| 1708 delegate_->ExitFullscreenModeForTab(this); | 1710 delegate_->ExitFullscreenModeForTab(this); |
| 1709 | 1711 |
| 1710 // Ensure web contents exit fullscreen state by sending a resize message, | 1712 // The fullscreen state is communicated to the renderer through a resize |
| 1711 // which includes the fullscreen state. This is required for the situation | 1713 // message. If the change in fullscreen state doesn't cause a view resize |
| 1712 // of the browser moving the view into a fullscreen state "browser fullscreen" | 1714 // then we must ensure web contents exit the fullscreen state by explicitly |
| 1713 // and then the contents entering "tab fullscreen". Exiting the contents | 1715 // sending a resize message. This is required for the situation of the browser |
| 1714 // "tab fullscreen" then won't have the side effect of the view resizing, | 1716 // moving the view into a "browser fullscreen" state and then the contents |
| 1715 // hence the explicit call here is required. | 1717 // entering "tab fullscreen". Exiting the contents "tab fullscreen" then won't |
| 1716 if (RenderWidgetHostView* rwh_view = GetRenderWidgetHostView()) { | 1718 // have the side effect of the view resizing, hence the explicit call here is |
| 1717 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) | 1719 // required. |
| 1718 render_widget_host->WasResized(); | 1720 if (!will_cause_resize) { |
| 1721 if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) { |
| 1722 if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost()) |
| 1723 render_widget_host->WasResized(); |
| 1724 } |
| 1719 } | 1725 } |
| 1720 | 1726 |
| 1721 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1727 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1722 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab( | 1728 DidToggleFullscreenModeForTab( |
| 1723 GetRenderViewHost()->GetWidget()))); | 1729 IsFullscreenForCurrentTab( |
| 1730 GetRenderViewHost()->GetWidget()), |
| 1731 will_cause_resize)); |
| 1724 } | 1732 } |
| 1725 | 1733 |
| 1726 bool WebContentsImpl::IsFullscreenForCurrentTab( | 1734 bool WebContentsImpl::IsFullscreenForCurrentTab( |
| 1727 RenderWidgetHostImpl* render_widget_host) const { | 1735 RenderWidgetHostImpl* render_widget_host) const { |
| 1728 if (!RenderViewHostImpl::From(render_widget_host)) | 1736 if (!RenderViewHostImpl::From(render_widget_host)) |
| 1729 return false; | 1737 return false; |
| 1730 | 1738 |
| 1731 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; | 1739 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; |
| 1732 } | 1740 } |
| 1733 | 1741 |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2878 } | 2886 } |
| 2879 | 2887 |
| 2880 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { | 2888 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { |
| 2881 manifest_manager_host_->GetManifest(GetMainFrame(), callback); | 2889 manifest_manager_host_->GetManifest(GetMainFrame(), callback); |
| 2882 } | 2890 } |
| 2883 | 2891 |
| 2884 void WebContentsImpl::HasManifest(const HasManifestCallback& callback) { | 2892 void WebContentsImpl::HasManifest(const HasManifestCallback& callback) { |
| 2885 manifest_manager_host_->HasManifest(GetMainFrame(), callback); | 2893 manifest_manager_host_->HasManifest(GetMainFrame(), callback); |
| 2886 } | 2894 } |
| 2887 | 2895 |
| 2888 void WebContentsImpl::ExitFullscreen() { | 2896 void WebContentsImpl::ExitFullscreen(bool will_cause_resize) { |
| 2889 // Clean up related state and initiate the fullscreen exit. | 2897 // Clean up related state and initiate the fullscreen exit. |
| 2890 GetRenderViewHost()->GetWidget()->RejectMouseLockOrUnlockIfNecessary(); | 2898 GetRenderViewHost()->GetWidget()->RejectMouseLockOrUnlockIfNecessary(); |
| 2891 ExitFullscreenMode(); | 2899 ExitFullscreenMode(will_cause_resize); |
| 2892 } | 2900 } |
| 2893 | 2901 |
| 2894 void WebContentsImpl::ResumeLoadingCreatedWebContents() { | 2902 void WebContentsImpl::ResumeLoadingCreatedWebContents() { |
| 2895 if (delayed_open_url_params_.get()) { | 2903 if (delayed_open_url_params_.get()) { |
| 2896 OpenURL(*delayed_open_url_params_.get()); | 2904 OpenURL(*delayed_open_url_params_.get()); |
| 2897 delayed_open_url_params_.reset(nullptr); | 2905 delayed_open_url_params_.reset(nullptr); |
| 2898 return; | 2906 return; |
| 2899 } | 2907 } |
| 2900 | 2908 |
| 2901 // Resume blocked requests for both the RenderViewHost and RenderFrameHost. | 2909 // Resume blocked requests for both the RenderViewHost and RenderFrameHost. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3064 void WebContentsImpl::DidNavigateMainFramePreCommit( | 3072 void WebContentsImpl::DidNavigateMainFramePreCommit( |
| 3065 bool navigation_is_within_page) { | 3073 bool navigation_is_within_page) { |
| 3066 // Ensure fullscreen mode is exited before committing the navigation to a | 3074 // Ensure fullscreen mode is exited before committing the navigation to a |
| 3067 // different page. The next page will not start out assuming it is in | 3075 // different page. The next page will not start out assuming it is in |
| 3068 // fullscreen mode. | 3076 // fullscreen mode. |
| 3069 if (navigation_is_within_page) { | 3077 if (navigation_is_within_page) { |
| 3070 // No page change? Then, the renderer and browser can remain in fullscreen. | 3078 // No page change? Then, the renderer and browser can remain in fullscreen. |
| 3071 return; | 3079 return; |
| 3072 } | 3080 } |
| 3073 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) | 3081 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) |
| 3074 ExitFullscreen(); | 3082 ExitFullscreen(false); |
| 3075 DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())); | 3083 DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())); |
| 3076 } | 3084 } |
| 3077 | 3085 |
| 3078 void WebContentsImpl::DidNavigateMainFramePostCommit( | 3086 void WebContentsImpl::DidNavigateMainFramePostCommit( |
| 3079 RenderFrameHostImpl* render_frame_host, | 3087 RenderFrameHostImpl* render_frame_host, |
| 3080 const LoadCommittedDetails& details, | 3088 const LoadCommittedDetails& details, |
| 3081 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3089 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 3082 if (details.is_navigation_to_different_page()) { | 3090 if (details.is_navigation_to_different_page()) { |
| 3083 // Clear the status bubble. This is a workaround for a bug where WebKit | 3091 // Clear the status bubble. This is a workaround for a bug where WebKit |
| 3084 // doesn't let us know that the cursor left an element during a | 3092 // 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... |
| 3936 base::TerminationStatus status, | 3944 base::TerminationStatus status, |
| 3937 int error_code) { | 3945 int error_code) { |
| 3938 if (rvh != GetRenderViewHost()) { | 3946 if (rvh != GetRenderViewHost()) { |
| 3939 // The pending page's RenderViewHost is gone. | 3947 // The pending page's RenderViewHost is gone. |
| 3940 return; | 3948 return; |
| 3941 } | 3949 } |
| 3942 | 3950 |
| 3943 // Ensure fullscreen mode is exited in the |delegate_| since a crashed | 3951 // Ensure fullscreen mode is exited in the |delegate_| since a crashed |
| 3944 // renderer may not have made a clean exit. | 3952 // renderer may not have made a clean exit. |
| 3945 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) | 3953 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) |
| 3946 ExitFullscreenMode(); | 3954 ExitFullscreenMode(false); |
| 3947 | 3955 |
| 3948 // Cancel any visible dialogs so they are not left dangling over the sad tab. | 3956 // Cancel any visible dialogs so they are not left dangling over the sad tab. |
| 3949 CancelActiveAndPendingDialogs(); | 3957 CancelActiveAndPendingDialogs(); |
| 3950 | 3958 |
| 3951 if (delegate_) | 3959 if (delegate_) |
| 3952 delegate_->HideValidationMessage(this); | 3960 delegate_->HideValidationMessage(this); |
| 3953 | 3961 |
| 3954 SetIsLoading(false, true, nullptr); | 3962 SetIsLoading(false, true, nullptr); |
| 3955 NotifyDisconnected(); | 3963 NotifyDisconnected(); |
| 3956 SetIsCrashed(status, error_code); | 3964 SetIsCrashed(status, error_code); |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4746 const WebContentsObserver::MediaPlayerId& id) { | 4754 const WebContentsObserver::MediaPlayerId& id) { |
| 4747 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); | 4755 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); |
| 4748 } | 4756 } |
| 4749 | 4757 |
| 4750 void WebContentsImpl::MediaStoppedPlaying( | 4758 void WebContentsImpl::MediaStoppedPlaying( |
| 4751 const WebContentsObserver::MediaPlayerId& id) { | 4759 const WebContentsObserver::MediaPlayerId& id) { |
| 4752 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); | 4760 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); |
| 4753 } | 4761 } |
| 4754 | 4762 |
| 4755 } // namespace content | 4763 } // namespace content |
| OLD | NEW |