| 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 "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 5 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 266 } |
| 267 | 267 |
| 268 content::RenderWidgetHostView* const current_fs_view = | 268 content::RenderWidgetHostView* const current_fs_view = |
| 269 old_contents->GetFullscreenRenderWidgetHostView(); | 269 old_contents->GetFullscreenRenderWidgetHostView(); |
| 270 if (current_fs_view) | 270 if (current_fs_view) |
| 271 current_fs_view->SetSize(old_contents->GetPreferredSize()); | 271 current_fs_view->SetSize(old_contents->GetPreferredSize()); |
| 272 ResizeWebContents(old_contents, old_contents->GetPreferredSize()); | 272 ResizeWebContents(old_contents, old_contents->GetPreferredSize()); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void FullscreenController::OnTabClosing(WebContents* web_contents) { | 275 void FullscreenController::OnTabClosing(WebContents* web_contents) { |
| 276 if (IsFullscreenForCapturedTab(web_contents)) { | 276 if (IsFullscreenForCapturedTab(web_contents)) |
| 277 web_contents->ExitFullscreen(); | 277 web_contents->ExitFullscreen( |
| 278 } else { | 278 /* will_cause_resize */ IsFullscreenCausedByTab()); |
| 279 else |
| 279 ExclusiveAccessControllerBase::OnTabClosing(web_contents); | 280 ExclusiveAccessControllerBase::OnTabClosing(web_contents); |
| 280 } | |
| 281 } | 281 } |
| 282 | 282 |
| 283 void FullscreenController::WindowFullscreenStateChanged() { | 283 void FullscreenController::WindowFullscreenStateChanged() { |
| 284 reentrant_window_state_change_call_check_ = true; | 284 reentrant_window_state_change_call_check_ = true; |
| 285 ExclusiveAccessContext* const exclusive_access_context = | 285 ExclusiveAccessContext* const exclusive_access_context = |
| 286 exclusive_access_manager()->context(); | 286 exclusive_access_manager()->context(); |
| 287 bool exiting_fullscreen = !exclusive_access_context->IsFullscreen(); | 287 bool exiting_fullscreen = !exclusive_access_context->IsFullscreen(); |
| 288 | 288 |
| 289 PostFullscreenChangeNotification(!exiting_fullscreen); | 289 PostFullscreenChangeNotification(!exiting_fullscreen); |
| 290 if (exiting_fullscreen) { | 290 if (exiting_fullscreen) { |
| 291 toggled_into_fullscreen_ = false; | 291 toggled_into_fullscreen_ = false; |
| 292 extension_caused_fullscreen_ = GURL(); | 292 extension_caused_fullscreen_ = GURL(); |
| 293 NotifyTabExclusiveAccessLost(); | 293 NotifyTabExclusiveAccessLost(); |
| 294 exclusive_access_context->UnhideDownloadShelf(); | 294 exclusive_access_context->UnhideDownloadShelf(); |
| 295 } else { | 295 } else { |
| 296 exclusive_access_context->HideDownloadShelf(); | 296 exclusive_access_context->HideDownloadShelf(); |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 bool FullscreenController::HandleUserPressedEscape() { | 300 bool FullscreenController::HandleUserPressedEscape() { |
| 301 WebContents* const active_web_contents = | 301 WebContents* const active_web_contents = |
| 302 exclusive_access_manager()->context()->GetActiveWebContents(); | 302 exclusive_access_manager()->context()->GetActiveWebContents(); |
| 303 if (IsFullscreenForCapturedTab(active_web_contents)) { | 303 if (IsFullscreenForCapturedTab(active_web_contents)) { |
| 304 active_web_contents->ExitFullscreen(); | 304 active_web_contents->ExitFullscreen( |
| 305 return true; | 305 /* will_cause_resize */ IsFullscreenCausedByTab()); |
| 306 } else if (IsWindowFullscreenForTabOrPending()) { | |
| 307 ExitExclusiveAccessIfNecessary(); | |
| 308 return true; | 306 return true; |
| 309 } | 307 } |
| 310 | 308 |
| 311 return false; | 309 if (!IsWindowFullscreenForTabOrPending()) |
| 310 return false; |
| 311 |
| 312 ExitExclusiveAccessIfNecessary(); |
| 313 return true; |
| 312 } | 314 } |
| 313 | 315 |
| 314 void FullscreenController::ExitExclusiveAccessToPreviousState() { | 316 void FullscreenController::ExitExclusiveAccessToPreviousState() { |
| 315 if (IsWindowFullscreenForTabOrPending()) | 317 if (IsWindowFullscreenForTabOrPending()) |
| 316 ExitFullscreenModeForTab(exclusive_access_tab()); | 318 ExitFullscreenModeForTab(exclusive_access_tab()); |
| 317 else if (IsFullscreenForBrowser()) | 319 else if (IsFullscreenForBrowser()) |
| 318 ExitFullscreenModeInternal(); | 320 ExitFullscreenModeInternal(); |
| 319 } | 321 } |
| 320 | 322 |
| 321 bool FullscreenController::OnAcceptExclusiveAccessPermission() { | 323 bool FullscreenController::OnAcceptExclusiveAccessPermission() { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 405 chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 404 content::Source<FullscreenController>(this), | 406 content::Source<FullscreenController>(this), |
| 405 content::Details<bool>(&is_fullscreen)); | 407 content::Details<bool>(&is_fullscreen)); |
| 406 } | 408 } |
| 407 | 409 |
| 408 void FullscreenController::NotifyTabExclusiveAccessLost() { | 410 void FullscreenController::NotifyTabExclusiveAccessLost() { |
| 409 if (exclusive_access_tab()) { | 411 if (exclusive_access_tab()) { |
| 410 WebContents* web_contents = exclusive_access_tab(); | 412 WebContents* web_contents = exclusive_access_tab(); |
| 411 SetTabWithExclusiveAccess(nullptr); | 413 SetTabWithExclusiveAccess(nullptr); |
| 412 fullscreened_origin_ = GURL(); | 414 fullscreened_origin_ = GURL(); |
| 415 bool will_cause_resize = IsFullscreenCausedByTab(); |
| 413 state_prior_to_tab_fullscreen_ = STATE_INVALID; | 416 state_prior_to_tab_fullscreen_ = STATE_INVALID; |
| 414 tab_fullscreen_accepted_ = false; | 417 tab_fullscreen_accepted_ = false; |
| 415 web_contents->ExitFullscreen(); | 418 web_contents->ExitFullscreen(will_cause_resize); |
| 416 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 419 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
| 417 } | 420 } |
| 418 } | 421 } |
| 419 | 422 |
| 420 void FullscreenController::ToggleFullscreenModeInternal( | 423 void FullscreenController::ToggleFullscreenModeInternal( |
| 421 FullscreenInternalOption option) { | 424 FullscreenInternalOption option) { |
| 422 #if defined(OS_WIN) | 425 #if defined(OS_WIN) |
| 423 // When in Metro snap mode, toggling in and out of fullscreen is prevented. | 426 // When in Metro snap mode, toggling in and out of fullscreen is prevented. |
| 424 if (IsInMetroSnapMode()) | 427 if (IsInMetroSnapMode()) |
| 425 return; | 428 return; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 return fullscreened_origin_; | 601 return fullscreened_origin_; |
| 599 | 602 |
| 600 return exclusive_access_tab()->GetLastCommittedURL(); | 603 return exclusive_access_tab()->GetLastCommittedURL(); |
| 601 } | 604 } |
| 602 | 605 |
| 603 GURL FullscreenController::GetEmbeddingOrigin() const { | 606 GURL FullscreenController::GetEmbeddingOrigin() const { |
| 604 DCHECK(exclusive_access_tab()); | 607 DCHECK(exclusive_access_tab()); |
| 605 | 608 |
| 606 return exclusive_access_tab()->GetLastCommittedURL(); | 609 return exclusive_access_tab()->GetLastCommittedURL(); |
| 607 } | 610 } |
| OLD | NEW |