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

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: update webcontentsdelegateandroid Created 6 years 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 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 } 1282 }
1283 1283
1284 std::set<RenderWidgetHostImpl*>::iterator iter = 1284 std::set<RenderWidgetHostImpl*>::iterator iter =
1285 created_widgets_.find(render_widget_host); 1285 created_widgets_.find(render_widget_host);
1286 if (iter != created_widgets_.end()) 1286 if (iter != created_widgets_.end())
1287 created_widgets_.erase(iter); 1287 created_widgets_.erase(iter);
1288 1288
1289 if (render_widget_host && 1289 if (render_widget_host &&
1290 render_widget_host->GetRoutingID() == fullscreen_widget_routing_id_) { 1290 render_widget_host->GetRoutingID() == fullscreen_widget_routing_id_) {
1291 if (delegate_ && delegate_->EmbedsFullscreenWidget()) 1291 if (delegate_ && delegate_->EmbedsFullscreenWidget())
1292 delegate_->ToggleFullscreenModeForTab(this, false); 1292 delegate_->ExitFullscreenModeForTab(this);
1293 FOR_EACH_OBSERVER(WebContentsObserver, 1293 FOR_EACH_OBSERVER(WebContentsObserver,
1294 observers_, 1294 observers_,
1295 DidDestroyFullscreenWidget( 1295 DidDestroyFullscreenWidget(
1296 fullscreen_widget_routing_id_)); 1296 fullscreen_widget_routing_id_));
1297 fullscreen_widget_routing_id_ = MSG_ROUTING_NONE; 1297 fullscreen_widget_routing_id_ = MSG_ROUTING_NONE;
1298 if (fullscreen_widget_had_focus_at_shutdown_) 1298 if (fullscreen_widget_had_focus_at_shutdown_)
1299 view_->RestoreFocus(); 1299 view_->RestoreFocus();
1300 } 1300 }
1301 } 1301 }
1302 1302
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 void WebContentsImpl::HandleGestureBegin() { 1410 void WebContentsImpl::HandleGestureBegin() {
1411 if (delegate_) 1411 if (delegate_)
1412 delegate_->HandleGestureBegin(); 1412 delegate_->HandleGestureBegin();
1413 } 1413 }
1414 1414
1415 void WebContentsImpl::HandleGestureEnd() { 1415 void WebContentsImpl::HandleGestureEnd() {
1416 if (delegate_) 1416 if (delegate_)
1417 delegate_->HandleGestureEnd(); 1417 delegate_->HandleGestureEnd();
1418 } 1418 }
1419 1419
1420 void WebContentsImpl::ToggleFullscreenMode(bool enter_fullscreen) { 1420 void WebContentsImpl::ExitFullscreen() {
scheib 2014/12/10 21:36:30 declaration & definition order should match: http:
mlamouri (slow - plz ping) 2014/12/11 16:03:19 Done.
1421 // The callers of this method seem to call it when they expect |WebContents|
Charlie Reis 2014/12/10 19:22:57 This seems a bit hand-wavy. Let's just say "Clean
mlamouri (slow - plz ping) 2014/12/11 16:03:20 Done.
1422 // to clean-up or to actually initiate the exit. This will do both.
1423 GetRenderViewHostImpl()->RejectMouseLockOrUnlockIfNecessary();
1424 ExitFullscreenMode();
1425 }
1426
1427 void WebContentsImpl::EnterFullscreenMode(const GURL& origin) {
1421 // This method is being called to enter or leave renderer-initiated fullscreen 1428 // This method is being called to enter or leave renderer-initiated fullscreen
Charlie Reis 2014/12/10 19:22:57 nit: Remove "or leave"
mlamouri (slow - plz ping) 2014/12/11 16:03:19 Done. Updated the comment for both ::EnterFullscre
1422 // mode. Either way, make sure any existing fullscreen widget is shut down 1429 // mode. Either way, make sure any existing fullscreen widget is shut down
1423 // first. 1430 // first.
1431 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
1432 if (widget_view)
1433 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown();
1434
1435 if (delegate_)
1436 delegate_->EnterFullscreenModeForTab(this, origin);
1437
1438 FOR_EACH_OBSERVER(WebContentsObserver,
1439 observers_,
1440 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab()));
1441 }
1442
1443 void WebContentsImpl::ExitFullscreenMode() {
1444 // This method is being called to enter or leave renderer-initiated fullscreen
1445 // mode. Either way, make sure any existing fullscreen widget is shut down
1446 // first.
1424 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); 1447 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
1425 if (widget_view) 1448 if (widget_view)
1426 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown(); 1449 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown();
1427 1450
1428 if (delegate_) 1451 if (delegate_)
1429 delegate_->ToggleFullscreenModeForTab(this, enter_fullscreen); 1452 delegate_->ExitFullscreenModeForTab(this);
1430 1453
1431 FOR_EACH_OBSERVER(WebContentsObserver, 1454 FOR_EACH_OBSERVER(WebContentsObserver,
1432 observers_, 1455 observers_,
1433 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab())); 1456 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab()));
1434 } 1457 }
1435 1458
1436 bool WebContentsImpl::IsFullscreenForCurrentTab() const { 1459 bool WebContentsImpl::IsFullscreenForCurrentTab() const {
1437 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; 1460 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false;
1438 } 1461 }
1439 1462
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 } else { 1705 } else {
1683 view = GetRenderWidgetHostView(); 1706 view = GetRenderWidgetHostView();
1684 } 1707 }
1685 1708
1686 if (is_fullscreen) { 1709 if (is_fullscreen) {
1687 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_); 1710 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_);
1688 view_->StoreFocus(); 1711 view_->StoreFocus();
1689 fullscreen_widget_routing_id_ = route_id; 1712 fullscreen_widget_routing_id_ = route_id;
1690 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { 1713 if (delegate_ && delegate_->EmbedsFullscreenWidget()) {
1691 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView()); 1714 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView());
1692 delegate_->ToggleFullscreenModeForTab(this, true); 1715 delegate_->EnterFullscreenModeForTab(this, GURL());
1693 } else { 1716 } else {
1694 widget_host_view->InitAsFullscreen(view); 1717 widget_host_view->InitAsFullscreen(view);
1695 } 1718 }
1696 FOR_EACH_OBSERVER(WebContentsObserver, 1719 FOR_EACH_OBSERVER(WebContentsObserver,
1697 observers_, 1720 observers_,
1698 DidShowFullscreenWidget(route_id)); 1721 DidShowFullscreenWidget(route_id));
1699 if (!widget_host_view->HasFocus()) 1722 if (!widget_host_view->HasFocus())
1700 widget_host_view->Focus(); 1723 widget_host_view->Focus();
1701 } else { 1724 } else {
1702 widget_host_view->InitAsPopup(view, initial_pos); 1725 widget_host_view->InitAsPopup(view, initial_pos);
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 void WebContentsImpl::DidNavigateMainFramePreCommit( 2579 void WebContentsImpl::DidNavigateMainFramePreCommit(
2557 bool navigation_is_within_page) { 2580 bool navigation_is_within_page) {
2558 // Ensure fullscreen mode is exited before committing the navigation to a 2581 // Ensure fullscreen mode is exited before committing the navigation to a
2559 // different page. The next page will not start out assuming it is in 2582 // different page. The next page will not start out assuming it is in
2560 // fullscreen mode. 2583 // fullscreen mode.
2561 if (navigation_is_within_page) { 2584 if (navigation_is_within_page) {
2562 // No page change? Then, the renderer and browser can remain in fullscreen. 2585 // No page change? Then, the renderer and browser can remain in fullscreen.
2563 return; 2586 return;
2564 } 2587 }
2565 if (IsFullscreenForCurrentTab()) 2588 if (IsFullscreenForCurrentTab())
2566 GetRenderViewHost()->ExitFullscreen(); 2589 ExitFullscreen();
2567 DCHECK(!IsFullscreenForCurrentTab()); 2590 DCHECK(!IsFullscreenForCurrentTab());
2568 } 2591 }
2569 2592
2570 void WebContentsImpl::DidNavigateMainFramePostCommit( 2593 void WebContentsImpl::DidNavigateMainFramePostCommit(
2571 const LoadCommittedDetails& details, 2594 const LoadCommittedDetails& details,
2572 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 2595 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
2573 if (details.is_navigation_to_different_page()) { 2596 if (details.is_navigation_to_different_page()) {
2574 // Clear the status bubble. This is a workaround for a bug where WebKit 2597 // Clear the status bubble. This is a workaround for a bug where WebKit
2575 // doesn't let us know that the cursor left an element during a 2598 // doesn't let us know that the cursor left an element during a
2576 // transition (this is also why the mouse cursor remains as a hand after 2599 // transition (this is also why the mouse cursor remains as a hand after
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
3567 base::TerminationStatus status, 3590 base::TerminationStatus status,
3568 int error_code) { 3591 int error_code) {
3569 if (rvh != GetRenderViewHost()) { 3592 if (rvh != GetRenderViewHost()) {
3570 // The pending page's RenderViewHost is gone. 3593 // The pending page's RenderViewHost is gone.
3571 return; 3594 return;
3572 } 3595 }
3573 3596
3574 // Ensure fullscreen mode is exited in the |delegate_| since a crashed 3597 // Ensure fullscreen mode is exited in the |delegate_| since a crashed
3575 // renderer may not have made a clean exit. 3598 // renderer may not have made a clean exit.
3576 if (IsFullscreenForCurrentTab()) 3599 if (IsFullscreenForCurrentTab())
3577 ToggleFullscreenMode(false); 3600 ExitFullscreenMode();
3578 3601
3579 // Cancel any visible dialogs so they are not left dangling over the sad tab. 3602 // Cancel any visible dialogs so they are not left dangling over the sad tab.
3580 if (dialog_manager_) 3603 if (dialog_manager_)
3581 dialog_manager_->CancelActiveAndPendingDialogs(this); 3604 dialog_manager_->CancelActiveAndPendingDialogs(this);
3582 3605
3583 if (delegate_) 3606 if (delegate_)
3584 delegate_->HideValidationMessage(this); 3607 delegate_->HideValidationMessage(this);
3585 3608
3586 SetIsLoading(rvh, false, true, NULL); 3609 SetIsLoading(rvh, false, true, NULL);
3587 NotifyDisconnected(); 3610 NotifyDisconnected();
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
4355 node->render_manager()->ResumeResponseDeferredAtStart(); 4378 node->render_manager()->ResumeResponseDeferredAtStart();
4356 } 4379 }
4357 4380
4358 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4381 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4359 force_disable_overscroll_content_ = force_disable; 4382 force_disable_overscroll_content_ = force_disable;
4360 if (view_) 4383 if (view_)
4361 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4384 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4362 } 4385 }
4363 4386
4364 } // namespace content 4387 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698