| 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/fullscreen/fullscreen_controller.h" | 5 #include "chrome/browser/ui/fullscreen/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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/app_mode/app_mode_utils.h" | 10 #include "chrome/browser/app_mode/app_mode_utils.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 void FullscreenController::LostMouseLock() { | 448 void FullscreenController::LostMouseLock() { |
| 449 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 449 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
| 450 SetMouseLockTab(NULL); | 450 SetMouseLockTab(NULL); |
| 451 NotifyMouseLockChange(); | 451 NotifyMouseLockChange(); |
| 452 UpdateFullscreenExitBubbleContent(); | 452 UpdateFullscreenExitBubbleContent(); |
| 453 } | 453 } |
| 454 | 454 |
| 455 void FullscreenController::Observe(int type, | 455 void FullscreenController::Observe(int type, |
| 456 const content::NotificationSource& source, | 456 const content::NotificationSource& source, |
| 457 const content::NotificationDetails& details) { | 457 const content::NotificationDetails& details) { |
| 458 switch (type) { | 458 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); |
| 459 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: | 459 if (content::Details<content::LoadCommittedDetails>(details)-> |
| 460 if (content::Details<content::LoadCommittedDetails>(details)-> | 460 is_navigation_to_different_page()) |
| 461 is_navigation_to_different_page()) { | 461 ExitTabFullscreenOrMouseLockIfNecessary(); |
| 462 ExitTabFullscreenOrMouseLockIfNecessary(); | |
| 463 } | |
| 464 break; | |
| 465 | |
| 466 default: | |
| 467 NOTREACHED() << "Got a notification we didn't register for."; | |
| 468 } | |
| 469 } | 462 } |
| 470 | 463 |
| 471 GURL FullscreenController::GetFullscreenExitBubbleURL() const { | 464 GURL FullscreenController::GetFullscreenExitBubbleURL() const { |
| 472 if (fullscreened_tab_) | 465 if (fullscreened_tab_) |
| 473 return fullscreened_tab_->GetURL(); | 466 return fullscreened_tab_->GetURL(); |
| 474 else if (mouse_lock_tab_) | 467 if (mouse_lock_tab_) |
| 475 return mouse_lock_tab_->GetURL(); | 468 return mouse_lock_tab_->GetURL(); |
| 476 else if (!extension_caused_fullscreen_.is_empty()) | 469 return extension_caused_fullscreen_; |
| 477 return extension_caused_fullscreen_; | |
| 478 else | |
| 479 return GURL(); | |
| 480 } | 470 } |
| 481 | 471 |
| 482 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() | 472 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() |
| 483 const { | 473 const { |
| 484 // In kiosk and exclusive app mode we always want to be fullscreen and do not | 474 // In kiosk and exclusive app mode we always want to be fullscreen and do not |
| 485 // want to show exit instructions for browser mode fullscreen. | 475 // want to show exit instructions for browser mode fullscreen. |
| 486 bool app_mode = false; | 476 bool app_mode = false; |
| 487 #if !defined(OS_MACOSX) // App mode (kiosk) is not available on Mac yet. | 477 #if !defined(OS_MACOSX) // App mode (kiosk) is not available on Mac yet. |
| 488 app_mode = chrome::IsRunningInAppMode(); | 478 app_mode = chrome::IsRunningInAppMode(); |
| 489 #endif | 479 #endif |
| 490 | 480 |
| 491 if (mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY) { | 481 if (mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY) |
| 482 return FEB_TYPE_NONE; |
| 483 |
| 484 if (!fullscreened_tab_) { |
| 485 if (IsMouseLocked()) |
| 486 return FEB_TYPE_MOUSELOCK_EXIT_INSTRUCTION; |
| 487 if (IsMouseLockRequested()) |
| 488 return FEB_TYPE_MOUSELOCK_BUTTONS; |
| 489 if (!extension_caused_fullscreen_.is_empty()) |
| 490 return FEB_TYPE_BROWSER_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION; |
| 491 if (toggled_into_fullscreen_ && !app_mode) |
| 492 return FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION; |
| 492 return FEB_TYPE_NONE; | 493 return FEB_TYPE_NONE; |
| 493 } | 494 } |
| 494 | 495 |
| 495 if (fullscreened_tab_) { | 496 if (tab_fullscreen_accepted_) { |
| 496 if (tab_fullscreen_accepted_) { | 497 if (IsPrivilegedFullscreenForTab()) |
| 497 if (IsPrivilegedFullscreenForTab()) { | 498 return FEB_TYPE_NONE; |
| 498 return FEB_TYPE_NONE; | 499 if (IsMouseLocked()) |
| 499 } else if (IsMouseLocked()) { | 500 return FEB_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION; |
| 500 return FEB_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION; | 501 if (IsMouseLockRequested()) |
| 501 } else if (IsMouseLockRequested()) { | |
| 502 return FEB_TYPE_MOUSELOCK_BUTTONS; | |
| 503 } else { | |
| 504 return FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION; | |
| 505 } | |
| 506 } else { // Full screen not yet accepted. | |
| 507 if (IsMouseLockRequested()) { | |
| 508 return FEB_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS; | |
| 509 } else { | |
| 510 return FEB_TYPE_FULLSCREEN_BUTTONS; | |
| 511 } | |
| 512 } | |
| 513 } else { // Not tab full screen. | |
| 514 if (IsMouseLocked()) { | |
| 515 return FEB_TYPE_MOUSELOCK_EXIT_INSTRUCTION; | |
| 516 } else if (IsMouseLockRequested()) { | |
| 517 return FEB_TYPE_MOUSELOCK_BUTTONS; | 502 return FEB_TYPE_MOUSELOCK_BUTTONS; |
| 518 } else { | 503 return FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION; |
| 519 if (!extension_caused_fullscreen_.is_empty()) { | |
| 520 return FEB_TYPE_BROWSER_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION; | |
| 521 } else if (toggled_into_fullscreen_ && !app_mode) { | |
| 522 return FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION; | |
| 523 } else { | |
| 524 return FEB_TYPE_NONE; | |
| 525 } | |
| 526 } | |
| 527 } | 504 } |
| 528 NOTREACHED(); | 505 |
| 529 return FEB_TYPE_NONE; | 506 if (IsMouseLockRequested()) |
| 507 return FEB_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS; |
| 508 return FEB_TYPE_FULLSCREEN_BUTTONS; |
| 530 } | 509 } |
| 531 | 510 |
| 532 void FullscreenController::UpdateNotificationRegistrations() { | 511 void FullscreenController::UpdateNotificationRegistrations() { |
| 533 if (fullscreened_tab_ && mouse_lock_tab_) | 512 if (fullscreened_tab_ && mouse_lock_tab_) |
| 534 DCHECK(fullscreened_tab_ == mouse_lock_tab_); | 513 DCHECK(fullscreened_tab_ == mouse_lock_tab_); |
| 535 | 514 |
| 536 WebContents* tab = fullscreened_tab_ ? fullscreened_tab_ : mouse_lock_tab_; | 515 WebContents* tab = fullscreened_tab_ ? fullscreened_tab_ : mouse_lock_tab_; |
| 537 | 516 |
| 538 if (tab && registrar_.IsEmpty()) { | 517 if (tab && registrar_.IsEmpty()) { |
| 539 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 518 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ? | 769 (fullscreened_tab_ == mouse_lock_tab_ && IsPrivilegedFullscreenForTab()) ? |
| 791 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL; | 770 mouse_lock_tab_->GetFullscreenRenderWidgetHostView() : NULL; |
| 792 if (!mouse_lock_view) { | 771 if (!mouse_lock_view) { |
| 793 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost(); | 772 RenderViewHost* const rvh = mouse_lock_tab_->GetRenderViewHost(); |
| 794 if (rvh) | 773 if (rvh) |
| 795 mouse_lock_view = rvh->GetView(); | 774 mouse_lock_view = rvh->GetView(); |
| 796 } | 775 } |
| 797 if (mouse_lock_view) | 776 if (mouse_lock_view) |
| 798 mouse_lock_view->UnlockMouse(); | 777 mouse_lock_view->UnlockMouse(); |
| 799 } | 778 } |
| OLD | NEW |