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 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 // Make sure any existing fullscreen widget is shut down first. | 1817 // Make sure any existing fullscreen widget is shut down first. |
1818 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); | 1818 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); |
1819 if (widget_view) { | 1819 if (widget_view) { |
1820 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) | 1820 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) |
1821 ->ShutdownAndDestroyWidget(true); | 1821 ->ShutdownAndDestroyWidget(true); |
1822 } | 1822 } |
1823 | 1823 |
1824 if (delegate_) | 1824 if (delegate_) |
1825 delegate_->EnterFullscreenModeForTab(this, origin); | 1825 delegate_->EnterFullscreenModeForTab(this, origin); |
1826 | 1826 |
1827 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1827 FOR_EACH_OBSERVER( |
1828 DidToggleFullscreenModeForTab( | 1828 WebContentsObserver, observers_, |
1829 IsFullscreenForCurrentTab( | 1829 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), false)); |
1830 GetRenderViewHost()->GetWidget()), | |
1831 false)); | |
1832 } | 1830 } |
1833 | 1831 |
1834 void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) { | 1832 void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) { |
1835 // This method is being called to leave renderer-initiated fullscreen mode. | 1833 // This method is being called to leave renderer-initiated fullscreen mode. |
1836 // Make sure any existing fullscreen widget is shut down first. | 1834 // Make sure any existing fullscreen widget is shut down first. |
1837 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); | 1835 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); |
1838 if (widget_view) { | 1836 if (widget_view) { |
1839 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) | 1837 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) |
1840 ->ShutdownAndDestroyWidget(true); | 1838 ->ShutdownAndDestroyWidget(true); |
1841 } | 1839 } |
(...skipping 16 matching lines...) Expand all Loading... |
1858 // have the side effect of the view resizing, hence the explicit call here is | 1856 // have the side effect of the view resizing, hence the explicit call here is |
1859 // required. | 1857 // required. |
1860 if (!will_cause_resize) { | 1858 if (!will_cause_resize) { |
1861 if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) { | 1859 if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) { |
1862 if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost()) | 1860 if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost()) |
1863 render_widget_host->WasResized(); | 1861 render_widget_host->WasResized(); |
1864 } | 1862 } |
1865 } | 1863 } |
1866 | 1864 |
1867 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1865 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1868 DidToggleFullscreenModeForTab( | 1866 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), |
1869 IsFullscreenForCurrentTab( | 1867 will_cause_resize)); |
1870 GetRenderViewHost()->GetWidget()), | |
1871 will_cause_resize)); | |
1872 } | 1868 } |
1873 | 1869 |
1874 // TODO(alexmos): Remove the unused |render_widget_host| parameter. | 1870 bool WebContentsImpl::IsFullscreenForCurrentTab() const { |
1875 bool WebContentsImpl::IsFullscreenForCurrentTab( | |
1876 RenderWidgetHostImpl* render_widget_host) const { | |
1877 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; | 1871 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; |
1878 } | 1872 } |
1879 | 1873 |
1880 blink::WebDisplayMode WebContentsImpl::GetDisplayMode( | 1874 blink::WebDisplayMode WebContentsImpl::GetDisplayMode( |
1881 RenderWidgetHostImpl* render_widget_host) const { | 1875 RenderWidgetHostImpl* render_widget_host) const { |
1882 if (!RenderViewHostImpl::From(render_widget_host)) | 1876 if (!RenderViewHostImpl::From(render_widget_host)) |
1883 return blink::WebDisplayModeBrowser; | 1877 return blink::WebDisplayModeBrowser; |
1884 | 1878 |
1885 return delegate_ ? delegate_->GetDisplayMode(this) | 1879 return delegate_ ? delegate_->GetDisplayMode(this) |
1886 : blink::WebDisplayModeBrowser; | 1880 : blink::WebDisplayModeBrowser; |
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3281 | 3275 |
3282 void WebContentsImpl::DidNavigateMainFramePreCommit( | 3276 void WebContentsImpl::DidNavigateMainFramePreCommit( |
3283 bool navigation_is_within_page) { | 3277 bool navigation_is_within_page) { |
3284 // Ensure fullscreen mode is exited before committing the navigation to a | 3278 // Ensure fullscreen mode is exited before committing the navigation to a |
3285 // different page. The next page will not start out assuming it is in | 3279 // different page. The next page will not start out assuming it is in |
3286 // fullscreen mode. | 3280 // fullscreen mode. |
3287 if (navigation_is_within_page) { | 3281 if (navigation_is_within_page) { |
3288 // No page change? Then, the renderer and browser can remain in fullscreen. | 3282 // No page change? Then, the renderer and browser can remain in fullscreen. |
3289 return; | 3283 return; |
3290 } | 3284 } |
3291 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) | 3285 if (IsFullscreenForCurrentTab()) |
3292 ExitFullscreen(false); | 3286 ExitFullscreen(false); |
3293 DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())); | 3287 DCHECK(!IsFullscreenForCurrentTab()); |
3294 } | 3288 } |
3295 | 3289 |
3296 void WebContentsImpl::DidNavigateMainFramePostCommit( | 3290 void WebContentsImpl::DidNavigateMainFramePostCommit( |
3297 RenderFrameHostImpl* render_frame_host, | 3291 RenderFrameHostImpl* render_frame_host, |
3298 const LoadCommittedDetails& details, | 3292 const LoadCommittedDetails& details, |
3299 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3293 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
3300 if (details.is_navigation_to_different_page()) { | 3294 if (details.is_navigation_to_different_page()) { |
3301 // Clear the status bubble. This is a workaround for a bug where WebKit | 3295 // Clear the status bubble. This is a workaround for a bug where WebKit |
3302 // doesn't let us know that the cursor left an element during a | 3296 // doesn't let us know that the cursor left an element during a |
3303 // transition (this is also why the mouse cursor remains as a hand after | 3297 // transition (this is also why the mouse cursor remains as a hand after |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4184 void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh, | 4178 void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh, |
4185 base::TerminationStatus status, | 4179 base::TerminationStatus status, |
4186 int error_code) { | 4180 int error_code) { |
4187 if (rvh != GetRenderViewHost()) { | 4181 if (rvh != GetRenderViewHost()) { |
4188 // The pending page's RenderViewHost is gone. | 4182 // The pending page's RenderViewHost is gone. |
4189 return; | 4183 return; |
4190 } | 4184 } |
4191 | 4185 |
4192 // Ensure fullscreen mode is exited in the |delegate_| since a crashed | 4186 // Ensure fullscreen mode is exited in the |delegate_| since a crashed |
4193 // renderer may not have made a clean exit. | 4187 // renderer may not have made a clean exit. |
4194 if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget())) | 4188 if (IsFullscreenForCurrentTab()) |
4195 ExitFullscreenMode(false); | 4189 ExitFullscreenMode(false); |
4196 | 4190 |
4197 // Cancel any visible dialogs so they are not left dangling over the sad tab. | 4191 // Cancel any visible dialogs so they are not left dangling over the sad tab. |
4198 CancelActiveAndPendingDialogs(); | 4192 CancelActiveAndPendingDialogs(); |
4199 | 4193 |
4200 if (delegate_) | 4194 if (delegate_) |
4201 delegate_->HideValidationMessage(this); | 4195 delegate_->HideValidationMessage(this); |
4202 | 4196 |
4203 // Reset the loading progress. TODO(avi): What does it mean to have a | 4197 // Reset the loading progress. TODO(avi): What does it mean to have a |
4204 // "renderer crash" when there is more than one renderer process serving a | 4198 // "renderer crash" when there is more than one renderer process serving a |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5070 for (RenderViewHost* render_view_host : render_view_host_set) | 5064 for (RenderViewHost* render_view_host : render_view_host_set) |
5071 render_view_host->OnWebkitPreferencesChanged(); | 5065 render_view_host->OnWebkitPreferencesChanged(); |
5072 } | 5066 } |
5073 | 5067 |
5074 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5068 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
5075 JavaScriptDialogManager* dialog_manager) { | 5069 JavaScriptDialogManager* dialog_manager) { |
5076 dialog_manager_ = dialog_manager; | 5070 dialog_manager_ = dialog_manager; |
5077 } | 5071 } |
5078 | 5072 |
5079 } // namespace content | 5073 } // namespace content |
OLD | NEW |