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

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: review comments 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::EnterFullscreenMode(const GURL& origin) {
1421 // This method is being called to enter or leave renderer-initiated fullscreen 1421 // This method is being called to enter renderer-initiated fullscreen mode.
1422 // mode. Either way, make sure any existing fullscreen widget is shut down 1422 // Make sure any existing fullscreen widget is shut down first.
1423 // first.
1424 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); 1423 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
1425 if (widget_view) 1424 if (widget_view)
1426 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown(); 1425 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown();
1427 1426
1428 if (delegate_) 1427 if (delegate_)
1429 delegate_->ToggleFullscreenModeForTab(this, enter_fullscreen); 1428 delegate_->EnterFullscreenModeForTab(this, origin);
1430 1429
1431 FOR_EACH_OBSERVER(WebContentsObserver, 1430 FOR_EACH_OBSERVER(WebContentsObserver,
1432 observers_, 1431 observers_,
1432 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab()));
1433 }
1434
1435 void WebContentsImpl::ExitFullscreenMode() {
1436 // This method is being called to leave renderer-initiated fullscreen mode.
1437 // Make sure any existing fullscreen widget is shut down first.
1438 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
1439 if (widget_view)
1440 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown();
1441
1442 if (delegate_)
1443 delegate_->ExitFullscreenModeForTab(this);
1444
1445 FOR_EACH_OBSERVER(WebContentsObserver,
1446 observers_,
1433 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab())); 1447 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab()));
1434 } 1448 }
1435 1449
1436 bool WebContentsImpl::IsFullscreenForCurrentTab() const { 1450 bool WebContentsImpl::IsFullscreenForCurrentTab() const {
1437 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; 1451 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false;
1438 } 1452 }
1439 1453
1440 void WebContentsImpl::RequestToLockMouse(bool user_gesture, 1454 void WebContentsImpl::RequestToLockMouse(bool user_gesture,
1441 bool last_unlocked_by_target) { 1455 bool last_unlocked_by_target) {
1442 if (delegate_) { 1456 if (delegate_) {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 } else { 1696 } else {
1683 view = GetRenderWidgetHostView(); 1697 view = GetRenderWidgetHostView();
1684 } 1698 }
1685 1699
1686 if (is_fullscreen) { 1700 if (is_fullscreen) {
1687 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_); 1701 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_);
1688 view_->StoreFocus(); 1702 view_->StoreFocus();
1689 fullscreen_widget_routing_id_ = route_id; 1703 fullscreen_widget_routing_id_ = route_id;
1690 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { 1704 if (delegate_ && delegate_->EmbedsFullscreenWidget()) {
1691 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView()); 1705 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView());
1692 delegate_->ToggleFullscreenModeForTab(this, true); 1706 delegate_->EnterFullscreenModeForTab(this, GURL());
1693 } else { 1707 } else {
1694 widget_host_view->InitAsFullscreen(view); 1708 widget_host_view->InitAsFullscreen(view);
1695 } 1709 }
1696 FOR_EACH_OBSERVER(WebContentsObserver, 1710 FOR_EACH_OBSERVER(WebContentsObserver,
1697 observers_, 1711 observers_,
1698 DidShowFullscreenWidget(route_id)); 1712 DidShowFullscreenWidget(route_id));
1699 if (!widget_host_view->HasFocus()) 1713 if (!widget_host_view->HasFocus())
1700 widget_host_view->Focus(); 1714 widget_host_view->Focus();
1701 } else { 1715 } else {
1702 widget_host_view->InitAsPopup(view, initial_pos); 1716 widget_host_view->InitAsPopup(view, initial_pos);
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 } 2445 }
2432 2446
2433 bool WebContentsImpl::WasRecentlyAudible() { 2447 bool WebContentsImpl::WasRecentlyAudible() {
2434 return audio_stream_monitor_.WasRecentlyAudible(); 2448 return audio_stream_monitor_.WasRecentlyAudible();
2435 } 2449 }
2436 2450
2437 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { 2451 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) {
2438 manifest_manager_host_->GetManifest(GetMainFrame(), callback); 2452 manifest_manager_host_->GetManifest(GetMainFrame(), callback);
2439 } 2453 }
2440 2454
2455 void WebContentsImpl::ExitFullscreen() {
2456 // Clean up related state and initiate the fullscreen exit.
2457 GetRenderViewHostImpl()->RejectMouseLockOrUnlockIfNecessary();
2458 ExitFullscreenMode();
2459 }
2460
2441 bool WebContentsImpl::FocusLocationBarByDefault() { 2461 bool WebContentsImpl::FocusLocationBarByDefault() {
2442 NavigationEntry* entry = controller_.GetVisibleEntry(); 2462 NavigationEntry* entry = controller_.GetVisibleEntry();
2443 if (entry && entry->GetURL() == GURL(url::kAboutBlankURL)) 2463 if (entry && entry->GetURL() == GURL(url::kAboutBlankURL))
2444 return true; 2464 return true;
2445 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); 2465 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this);
2446 } 2466 }
2447 2467
2448 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { 2468 void WebContentsImpl::SetFocusToLocationBar(bool select_all) {
2449 if (delegate_) 2469 if (delegate_)
2450 delegate_->SetFocusToLocationBar(select_all); 2470 delegate_->SetFocusToLocationBar(select_all);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 void WebContentsImpl::DidNavigateMainFramePreCommit( 2576 void WebContentsImpl::DidNavigateMainFramePreCommit(
2557 bool navigation_is_within_page) { 2577 bool navigation_is_within_page) {
2558 // Ensure fullscreen mode is exited before committing the navigation to a 2578 // 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 2579 // different page. The next page will not start out assuming it is in
2560 // fullscreen mode. 2580 // fullscreen mode.
2561 if (navigation_is_within_page) { 2581 if (navigation_is_within_page) {
2562 // No page change? Then, the renderer and browser can remain in fullscreen. 2582 // No page change? Then, the renderer and browser can remain in fullscreen.
2563 return; 2583 return;
2564 } 2584 }
2565 if (IsFullscreenForCurrentTab()) 2585 if (IsFullscreenForCurrentTab())
2566 GetRenderViewHost()->ExitFullscreen(); 2586 ExitFullscreen();
2567 DCHECK(!IsFullscreenForCurrentTab()); 2587 DCHECK(!IsFullscreenForCurrentTab());
2568 } 2588 }
2569 2589
2570 void WebContentsImpl::DidNavigateMainFramePostCommit( 2590 void WebContentsImpl::DidNavigateMainFramePostCommit(
2571 const LoadCommittedDetails& details, 2591 const LoadCommittedDetails& details,
2572 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 2592 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
2573 if (details.is_navigation_to_different_page()) { 2593 if (details.is_navigation_to_different_page()) {
2574 // Clear the status bubble. This is a workaround for a bug where WebKit 2594 // 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 2595 // 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 2596 // 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, 3587 base::TerminationStatus status,
3568 int error_code) { 3588 int error_code) {
3569 if (rvh != GetRenderViewHost()) { 3589 if (rvh != GetRenderViewHost()) {
3570 // The pending page's RenderViewHost is gone. 3590 // The pending page's RenderViewHost is gone.
3571 return; 3591 return;
3572 } 3592 }
3573 3593
3574 // Ensure fullscreen mode is exited in the |delegate_| since a crashed 3594 // Ensure fullscreen mode is exited in the |delegate_| since a crashed
3575 // renderer may not have made a clean exit. 3595 // renderer may not have made a clean exit.
3576 if (IsFullscreenForCurrentTab()) 3596 if (IsFullscreenForCurrentTab())
3577 ToggleFullscreenMode(false); 3597 ExitFullscreenMode();
3578 3598
3579 // Cancel any visible dialogs so they are not left dangling over the sad tab. 3599 // Cancel any visible dialogs so they are not left dangling over the sad tab.
3580 if (dialog_manager_) 3600 if (dialog_manager_)
3581 dialog_manager_->CancelActiveAndPendingDialogs(this); 3601 dialog_manager_->CancelActiveAndPendingDialogs(this);
3582 3602
3583 if (delegate_) 3603 if (delegate_)
3584 delegate_->HideValidationMessage(this); 3604 delegate_->HideValidationMessage(this);
3585 3605
3586 SetIsLoading(rvh, false, true, NULL); 3606 SetIsLoading(rvh, false, true, NULL);
3587 NotifyDisconnected(); 3607 NotifyDisconnected();
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
4355 node->render_manager()->ResumeResponseDeferredAtStart(); 4375 node->render_manager()->ResumeResponseDeferredAtStart();
4356 } 4376 }
4357 4377
4358 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4378 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4359 force_disable_overscroll_content_ = force_disable; 4379 force_disable_overscroll_content_ = force_disable;
4360 if (view_) 4380 if (view_)
4361 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4381 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4362 } 4382 }
4363 4383
4364 } // namespace content 4384 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698