| 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 <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 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 // This method is being called to enter renderer-initiated fullscreen mode. | 1662 // This method is being called to enter renderer-initiated fullscreen mode. |
| 1663 // Make sure any existing fullscreen widget is shut down first. | 1663 // Make sure any existing fullscreen widget is shut down first. |
| 1664 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); | 1664 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); |
| 1665 if (widget_view) | 1665 if (widget_view) |
| 1666 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown(); | 1666 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown(); |
| 1667 | 1667 |
| 1668 if (delegate_) | 1668 if (delegate_) |
| 1669 delegate_->EnterFullscreenModeForTab(this, origin); | 1669 delegate_->EnterFullscreenModeForTab(this, origin); |
| 1670 | 1670 |
| 1671 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1671 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1672 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab( | 1672 DidToggleFullscreenModeForTab( |
| 1673 GetRenderViewHost()->GetWidget()))); | 1673 IsFullscreenForCurrentTab( |
| 1674 GetRenderViewHost()->GetWidget()), |
| 1675 false)); |
| 1674 } | 1676 } |
| 1675 | 1677 |
| 1676 void WebContentsImpl::ExitFullscreenMode() { | 1678 void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) { |
| 1677 // This method is being called to leave renderer-initiated fullscreen mode. | 1679 // This method is being called to leave renderer-initiated fullscreen mode. |
| 1678 // Make sure any existing fullscreen widget is shut down first. | 1680 // Make sure any existing fullscreen widget is shut down first. |
| 1679 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); | 1681 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); |
| 1680 if (widget_view) | 1682 if (widget_view) |
| 1681 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown(); | 1683 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown(); |
| 1682 | 1684 |
| 1683 #if defined(OS_ANDROID) | 1685 #if defined(OS_ANDROID) |
| 1684 ContentVideoView* video_view = ContentVideoView::GetInstance(); | 1686 ContentVideoView* video_view = ContentVideoView::GetInstance(); |
| 1685 if (video_view != NULL) | 1687 if (video_view != NULL) |
| 1686 video_view->OnExitFullscreen(); | 1688 video_view->OnExitFullscreen(); |
| 1687 #endif | 1689 #endif |
| 1688 | 1690 |
| 1689 if (delegate_) | 1691 if (delegate_) |
| 1690 delegate_->ExitFullscreenModeForTab(this); | 1692 delegate_->ExitFullscreenModeForTab(this); |
| 1691 | 1693 |
| 1692 // Ensure web contents exit fullscreen state by sending a resize message, | 1694 // Ensure web contents exit fullscreen state by sending a resize message, |
| 1693 // which includes the fullscreen state. This is required for the situation | 1695 // which includes the fullscreen state. This is required for the situation |
| 1694 // of the browser moving the view into a fullscreen state "browser fullscreen" | 1696 // of the browser moving the view into a fullscreen state "browser fullscreen" |
| 1695 // and then the contents entering "tab fullscreen". Exiting the contents | 1697 // and then the contents entering "tab fullscreen". Exiting the contents |
| 1696 // "tab fullscreen" then won't have the side effect of the view resizing, | 1698 // "tab fullscreen" then won't have the side effect of the view resizing, |
| 1697 // hence the explicit call here is required. | 1699 // hence the explicit call here is required. |
| 1698 if (RenderWidgetHostView* rwh_view = GetRenderWidgetHostView()) { | 1700 if (!will_cause_resize) { |
| 1699 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) | 1701 if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) { |
| 1700 render_widget_host->WasResized(); | 1702 if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost()) |
| 1703 render_widget_host->WasResized(); |
| 1704 } |
| 1701 } | 1705 } |
| 1702 | 1706 |
| 1703 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1707 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1704 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab( | 1708 DidToggleFullscreenModeForTab( |
| 1705 GetRenderViewHost()->GetWidget()))); | 1709 IsFullscreenForCurrentTab( |
| 1710 GetRenderViewHost()->GetWidget()), |
| 1711 will_cause_resize)); |
| 1706 } | 1712 } |
| 1707 | 1713 |
| 1708 bool WebContentsImpl::IsFullscreenForCurrentTab( | 1714 bool WebContentsImpl::IsFullscreenForCurrentTab( |
| 1709 RenderWidgetHostImpl* render_widget_host) const { | 1715 RenderWidgetHostImpl* render_widget_host) const { |
| 1710 if (!RenderViewHostImpl::From(render_widget_host)) | 1716 if (!RenderViewHostImpl::From(render_widget_host)) |
| 1711 return false; | 1717 return false; |
| 1712 | 1718 |
| 1713 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; | 1719 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; |
| 1714 } | 1720 } |
| 1715 | 1721 |
| (...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2868 } | 2874 } |
| 2869 | 2875 |
| 2870 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { | 2876 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { |
| 2871 manifest_manager_host_->GetManifest(GetMainFrame(), callback); | 2877 manifest_manager_host_->GetManifest(GetMainFrame(), callback); |
| 2872 } | 2878 } |
| 2873 | 2879 |
| 2874 void WebContentsImpl::HasManifest(const HasManifestCallback& callback) { | 2880 void WebContentsImpl::HasManifest(const HasManifestCallback& callback) { |
| 2875 manifest_manager_host_->HasManifest(GetMainFrame(), callback); | 2881 manifest_manager_host_->HasManifest(GetMainFrame(), callback); |
| 2876 } | 2882 } |
| 2877 | 2883 |
| 2878 void WebContentsImpl::ExitFullscreen() { | 2884 void WebContentsImpl::ExitFullscreen(bool will_cause_resize) { |
| 2879 // Clean up related state and initiate the fullscreen exit. | 2885 // Clean up related state and initiate the fullscreen exit. |
| 2880 GetRenderViewHost()->GetWidget()->RejectMouseLockOrUnlockIfNecessary(); | 2886 GetRenderViewHost()->GetWidget()->RejectMouseLockOrUnlockIfNecessary(); |
| 2881 ExitFullscreenMode(); | 2887 ExitFullscreenMode(will_cause_resize); |
| 2882 } | 2888 } |
| 2883 | 2889 |
| 2884 void WebContentsImpl::ResumeLoadingCreatedWebContents() { | 2890 void WebContentsImpl::ResumeLoadingCreatedWebContents() { |
| 2885 if (delayed_open_url_params_.get()) { | 2891 if (delayed_open_url_params_.get()) { |
| 2886 OpenURL(*delayed_open_url_params_.get()); | 2892 OpenURL(*delayed_open_url_params_.get()); |
| 2887 delayed_open_url_params_.reset(nullptr); | 2893 delayed_open_url_params_.reset(nullptr); |
| 2888 return; | 2894 return; |
| 2889 } | 2895 } |
| 2890 | 2896 |
| 2891 // Resume blocked requests for both the RenderViewHost and RenderFrameHost. | 2897 // Resume blocked requests for both the RenderViewHost and RenderFrameHost. |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3052 void WebContentsImpl::DidNavigateMainFramePreCommit( | 3058 void WebContentsImpl::DidNavigateMainFramePreCommit( |
| 3053 bool navigation_is_within_page) { | 3059 bool navigation_is_within_page) { |
| 3054 // Ensure fullscreen mode is exited before committing the navigation to a | 3060 // Ensure fullscreen mode is exited before committing the navigation to a |
| 3055 // different page. The next page will not start out assuming it is in | 3061 // different page. The next page will not start out assuming it is in |
| 3056 // fullscreen mode. | 3062 // fullscreen mode. |
| 3057 if (navigation_is_within_page) { | 3063 if (navigation_is_within_page) { |
| 3058 // No page change? Then, the renderer and browser can remain in fullscreen. | 3064 // No page change? Then, the renderer and browser can remain in fullscreen. |
| 3059 return; | 3065 return; |
| 3060 } | 3066 } |
| 3061 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) | 3067 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) |
| 3062 ExitFullscreen(); | 3068 ExitFullscreen(false); |
| 3063 DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())); | 3069 DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())); |
| 3064 } | 3070 } |
| 3065 | 3071 |
| 3066 void WebContentsImpl::DidNavigateMainFramePostCommit( | 3072 void WebContentsImpl::DidNavigateMainFramePostCommit( |
| 3067 RenderFrameHostImpl* render_frame_host, | 3073 RenderFrameHostImpl* render_frame_host, |
| 3068 const LoadCommittedDetails& details, | 3074 const LoadCommittedDetails& details, |
| 3069 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3075 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 3070 if (details.is_navigation_to_different_page()) { | 3076 if (details.is_navigation_to_different_page()) { |
| 3071 // Clear the status bubble. This is a workaround for a bug where WebKit | 3077 // Clear the status bubble. This is a workaround for a bug where WebKit |
| 3072 // doesn't let us know that the cursor left an element during a | 3078 // doesn't let us know that the cursor left an element during a |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3963 base::TerminationStatus status, | 3969 base::TerminationStatus status, |
| 3964 int error_code) { | 3970 int error_code) { |
| 3965 if (rvh != GetRenderViewHost()) { | 3971 if (rvh != GetRenderViewHost()) { |
| 3966 // The pending page's RenderViewHost is gone. | 3972 // The pending page's RenderViewHost is gone. |
| 3967 return; | 3973 return; |
| 3968 } | 3974 } |
| 3969 | 3975 |
| 3970 // Ensure fullscreen mode is exited in the |delegate_| since a crashed | 3976 // Ensure fullscreen mode is exited in the |delegate_| since a crashed |
| 3971 // renderer may not have made a clean exit. | 3977 // renderer may not have made a clean exit. |
| 3972 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) | 3978 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) |
| 3973 ExitFullscreenMode(); | 3979 ExitFullscreenMode(false); |
| 3974 | 3980 |
| 3975 // Cancel any visible dialogs so they are not left dangling over the sad tab. | 3981 // Cancel any visible dialogs so they are not left dangling over the sad tab. |
| 3976 CancelActiveAndPendingDialogs(); | 3982 CancelActiveAndPendingDialogs(); |
| 3977 | 3983 |
| 3978 if (delegate_) | 3984 if (delegate_) |
| 3979 delegate_->HideValidationMessage(this); | 3985 delegate_->HideValidationMessage(this); |
| 3980 | 3986 |
| 3981 SetIsLoading(false, true, nullptr); | 3987 SetIsLoading(false, true, nullptr); |
| 3982 NotifyDisconnected(); | 3988 NotifyDisconnected(); |
| 3983 SetIsCrashed(status, error_code); | 3989 SetIsCrashed(status, error_code); |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4817 return NULL; | 4823 return NULL; |
| 4818 } | 4824 } |
| 4819 | 4825 |
| 4820 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4826 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4821 force_disable_overscroll_content_ = force_disable; | 4827 force_disable_overscroll_content_ = force_disable; |
| 4822 if (view_) | 4828 if (view_) |
| 4823 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4829 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4824 } | 4830 } |
| 4825 | 4831 |
| 4826 } // namespace content | 4832 } // namespace content |
| OLD | NEW |