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

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

Issue 789533002: Fullscreen: make fullscreen requests come from RenderFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make try happy Created 5 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 <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 } 1297 }
1298 1298
1299 std::set<RenderWidgetHostImpl*>::iterator iter = 1299 std::set<RenderWidgetHostImpl*>::iterator iter =
1300 created_widgets_.find(render_widget_host); 1300 created_widgets_.find(render_widget_host);
1301 if (iter != created_widgets_.end()) 1301 if (iter != created_widgets_.end())
1302 created_widgets_.erase(iter); 1302 created_widgets_.erase(iter);
1303 1303
1304 if (render_widget_host && 1304 if (render_widget_host &&
1305 render_widget_host->GetRoutingID() == fullscreen_widget_routing_id_) { 1305 render_widget_host->GetRoutingID() == fullscreen_widget_routing_id_) {
1306 if (delegate_ && delegate_->EmbedsFullscreenWidget()) 1306 if (delegate_ && delegate_->EmbedsFullscreenWidget())
1307 delegate_->ToggleFullscreenModeForTab(this, false); 1307 delegate_->ExitFullscreenModeForTab(this);
1308 FOR_EACH_OBSERVER(WebContentsObserver, 1308 FOR_EACH_OBSERVER(WebContentsObserver,
1309 observers_, 1309 observers_,
1310 DidDestroyFullscreenWidget( 1310 DidDestroyFullscreenWidget(
1311 fullscreen_widget_routing_id_)); 1311 fullscreen_widget_routing_id_));
1312 fullscreen_widget_routing_id_ = MSG_ROUTING_NONE; 1312 fullscreen_widget_routing_id_ = MSG_ROUTING_NONE;
1313 if (fullscreen_widget_had_focus_at_shutdown_) 1313 if (fullscreen_widget_had_focus_at_shutdown_)
1314 view_->RestoreFocus(); 1314 view_->RestoreFocus();
1315 } 1315 }
1316 } 1316 }
1317 1317
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 void WebContentsImpl::HandleGestureBegin() { 1425 void WebContentsImpl::HandleGestureBegin() {
1426 if (delegate_) 1426 if (delegate_)
1427 delegate_->HandleGestureBegin(); 1427 delegate_->HandleGestureBegin();
1428 } 1428 }
1429 1429
1430 void WebContentsImpl::HandleGestureEnd() { 1430 void WebContentsImpl::HandleGestureEnd() {
1431 if (delegate_) 1431 if (delegate_)
1432 delegate_->HandleGestureEnd(); 1432 delegate_->HandleGestureEnd();
1433 } 1433 }
1434 1434
1435 void WebContentsImpl::ToggleFullscreenMode(bool enter_fullscreen) { 1435 void WebContentsImpl::EnterFullscreenMode(const GURL& origin) {
1436 // This method is being called to enter or leave renderer-initiated fullscreen 1436 // This method is being called to enter renderer-initiated fullscreen mode.
1437 // mode. Either way, make sure any existing fullscreen widget is shut down 1437 // Make sure any existing fullscreen widget is shut down first.
1438 // first.
1439 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); 1438 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
1440 if (widget_view) 1439 if (widget_view)
1441 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown(); 1440 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown();
1442 1441
1443 if (delegate_) 1442 if (delegate_)
1444 delegate_->ToggleFullscreenModeForTab(this, enter_fullscreen); 1443 delegate_->EnterFullscreenModeForTab(this, origin);
1444
1445 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1446 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab()));
1447 }
1448
1449 void WebContentsImpl::ExitFullscreenMode() {
1450 // This method is being called to leave renderer-initiated fullscreen mode.
1451 // Make sure any existing fullscreen widget is shut down first.
1452 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
1453 if (widget_view)
1454 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown();
1455
1456 if (delegate_)
1457 delegate_->ExitFullscreenModeForTab(this);
1445 1458
1446 FOR_EACH_OBSERVER(WebContentsObserver, 1459 FOR_EACH_OBSERVER(WebContentsObserver,
1447 observers_, 1460 observers_,
1448 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab())); 1461 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab()));
1449 } 1462 }
1450 1463
1451 bool WebContentsImpl::IsFullscreenForCurrentTab() const { 1464 bool WebContentsImpl::IsFullscreenForCurrentTab() const {
1452 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; 1465 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false;
1453 } 1466 }
1454 1467
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 } else { 1711 } else {
1699 view = GetRenderWidgetHostView(); 1712 view = GetRenderWidgetHostView();
1700 } 1713 }
1701 1714
1702 if (is_fullscreen) { 1715 if (is_fullscreen) {
1703 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_); 1716 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_);
1704 view_->StoreFocus(); 1717 view_->StoreFocus();
1705 fullscreen_widget_routing_id_ = route_id; 1718 fullscreen_widget_routing_id_ = route_id;
1706 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { 1719 if (delegate_ && delegate_->EmbedsFullscreenWidget()) {
1707 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView()); 1720 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView());
1708 delegate_->ToggleFullscreenModeForTab(this, true); 1721 delegate_->EnterFullscreenModeForTab(this, GURL());
1709 } else { 1722 } else {
1710 widget_host_view->InitAsFullscreen(view); 1723 widget_host_view->InitAsFullscreen(view);
1711 } 1724 }
1712 FOR_EACH_OBSERVER(WebContentsObserver, 1725 FOR_EACH_OBSERVER(WebContentsObserver,
1713 observers_, 1726 observers_,
1714 DidShowFullscreenWidget(route_id)); 1727 DidShowFullscreenWidget(route_id));
1715 if (!widget_host_view->HasFocus()) 1728 if (!widget_host_view->HasFocus())
1716 widget_host_view->Focus(); 1729 widget_host_view->Focus();
1717 } else { 1730 } else {
1718 widget_host_view->InitAsPopup(view, initial_pos); 1731 widget_host_view->InitAsPopup(view, initial_pos);
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 } 2464 }
2452 2465
2453 bool WebContentsImpl::WasRecentlyAudible() { 2466 bool WebContentsImpl::WasRecentlyAudible() {
2454 return audio_stream_monitor_.WasRecentlyAudible(); 2467 return audio_stream_monitor_.WasRecentlyAudible();
2455 } 2468 }
2456 2469
2457 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { 2470 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) {
2458 manifest_manager_host_->GetManifest(GetMainFrame(), callback); 2471 manifest_manager_host_->GetManifest(GetMainFrame(), callback);
2459 } 2472 }
2460 2473
2474 void WebContentsImpl::ExitFullscreen() {
2475 // Clean up related state and initiate the fullscreen exit.
2476 GetRenderViewHostImpl()->RejectMouseLockOrUnlockIfNecessary();
2477 ExitFullscreenMode();
2478 }
2479
2461 bool WebContentsImpl::FocusLocationBarByDefault() { 2480 bool WebContentsImpl::FocusLocationBarByDefault() {
2462 NavigationEntry* entry = controller_.GetVisibleEntry(); 2481 NavigationEntry* entry = controller_.GetVisibleEntry();
2463 if (entry && entry->GetURL() == GURL(url::kAboutBlankURL)) 2482 if (entry && entry->GetURL() == GURL(url::kAboutBlankURL))
2464 return true; 2483 return true;
2465 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); 2484 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this);
2466 } 2485 }
2467 2486
2468 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { 2487 void WebContentsImpl::SetFocusToLocationBar(bool select_all) {
2469 if (delegate_) 2488 if (delegate_)
2470 delegate_->SetFocusToLocationBar(select_all); 2489 delegate_->SetFocusToLocationBar(select_all);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2581 void WebContentsImpl::DidNavigateMainFramePreCommit( 2600 void WebContentsImpl::DidNavigateMainFramePreCommit(
2582 bool navigation_is_within_page) { 2601 bool navigation_is_within_page) {
2583 // Ensure fullscreen mode is exited before committing the navigation to a 2602 // Ensure fullscreen mode is exited before committing the navigation to a
2584 // different page. The next page will not start out assuming it is in 2603 // different page. The next page will not start out assuming it is in
2585 // fullscreen mode. 2604 // fullscreen mode.
2586 if (navigation_is_within_page) { 2605 if (navigation_is_within_page) {
2587 // No page change? Then, the renderer and browser can remain in fullscreen. 2606 // No page change? Then, the renderer and browser can remain in fullscreen.
2588 return; 2607 return;
2589 } 2608 }
2590 if (IsFullscreenForCurrentTab()) 2609 if (IsFullscreenForCurrentTab())
2591 GetRenderViewHost()->ExitFullscreen(); 2610 ExitFullscreen();
2592 DCHECK(!IsFullscreenForCurrentTab()); 2611 DCHECK(!IsFullscreenForCurrentTab());
2593 } 2612 }
2594 2613
2595 void WebContentsImpl::DidNavigateMainFramePostCommit( 2614 void WebContentsImpl::DidNavigateMainFramePostCommit(
2596 RenderFrameHostImpl* render_frame_host, 2615 RenderFrameHostImpl* render_frame_host,
2597 const LoadCommittedDetails& details, 2616 const LoadCommittedDetails& details,
2598 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 2617 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
2599 if (details.is_navigation_to_different_page()) { 2618 if (details.is_navigation_to_different_page()) {
2600 // Clear the status bubble. This is a workaround for a bug where WebKit 2619 // Clear the status bubble. This is a workaround for a bug where WebKit
2601 // doesn't let us know that the cursor left an element during a 2620 // doesn't let us know that the cursor left an element during a
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
3611 base::TerminationStatus status, 3630 base::TerminationStatus status,
3612 int error_code) { 3631 int error_code) {
3613 if (rvh != GetRenderViewHost()) { 3632 if (rvh != GetRenderViewHost()) {
3614 // The pending page's RenderViewHost is gone. 3633 // The pending page's RenderViewHost is gone.
3615 return; 3634 return;
3616 } 3635 }
3617 3636
3618 // Ensure fullscreen mode is exited in the |delegate_| since a crashed 3637 // Ensure fullscreen mode is exited in the |delegate_| since a crashed
3619 // renderer may not have made a clean exit. 3638 // renderer may not have made a clean exit.
3620 if (IsFullscreenForCurrentTab()) 3639 if (IsFullscreenForCurrentTab())
3621 ToggleFullscreenMode(false); 3640 ExitFullscreenMode();
3622 3641
3623 // Cancel any visible dialogs so they are not left dangling over the sad tab. 3642 // Cancel any visible dialogs so they are not left dangling over the sad tab.
3624 if (dialog_manager_) 3643 if (dialog_manager_)
3625 dialog_manager_->CancelActiveAndPendingDialogs(this); 3644 dialog_manager_->CancelActiveAndPendingDialogs(this);
3626 3645
3627 if (delegate_) 3646 if (delegate_)
3628 delegate_->HideValidationMessage(this); 3647 delegate_->HideValidationMessage(this);
3629 3648
3630 SetIsLoading(rvh, false, true, NULL); 3649 SetIsLoading(rvh, false, true, NULL);
3631 NotifyDisconnected(); 3650 NotifyDisconnected();
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
4407 node->render_manager()->ResumeResponseDeferredAtStart(); 4426 node->render_manager()->ResumeResponseDeferredAtStart();
4408 } 4427 }
4409 4428
4410 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4429 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4411 force_disable_overscroll_content_ = force_disable; 4430 force_disable_overscroll_content_ = force_disable;
4412 if (view_) 4431 if (view_)
4413 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4432 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4414 } 4433 }
4415 4434
4416 } // namespace content 4435 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698