Chromium Code Reviews| 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_controller.h" | 5 #include "chrome/browser/ui/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.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 return false; | 56 return false; |
| 57 DCHECK(tab == browser_->GetSelectedWebContents()); | 57 DCHECK(tab == browser_->GetSelectedWebContents()); |
| 58 return true; | 58 return true; |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool FullscreenController::IsMouseLockRequested() const { | 61 bool FullscreenController::IsMouseLockRequested() const { |
| 62 return mouse_lock_state_ == MOUSELOCK_REQUESTED; | 62 return mouse_lock_state_ == MOUSELOCK_REQUESTED; |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool FullscreenController::IsMouseLocked() const { | 65 bool FullscreenController::IsMouseLocked() const { |
| 66 return mouse_lock_state_ == MOUSELOCK_ACCEPTED; | 66 return mouse_lock_state_ == MOUSELOCK_ACCEPTED |
| 67 || mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENT; | |
| 67 } | 68 } |
| 68 | 69 |
| 69 void FullscreenController::RequestToLockMouse(WebContents* tab, | 70 void FullscreenController::RequestToLockMouse(WebContents* tab, |
| 70 bool user_gesture) { | 71 bool user_gesture, bool after_unlocked_by_target) { |
| 71 DCHECK(!IsMouseLocked()); | 72 DCHECK(!IsMouseLocked()); |
| 72 NotifyMouseLockChange(); | 73 NotifyMouseLockChange(); |
| 73 | 74 |
| 74 // Must have a user gesture, or we must already be in tab fullscreen. | 75 // Must have a user gesture, or we must already be in tab fullscreen. |
|
scheib
2012/05/26 01:12:34
Update comment, e.g.:
Must have a user gesture to
dmurph
2012/05/30 00:17:51
ok
| |
| 75 if (!user_gesture && !IsFullscreenForTabOrPending(tab)) { | 76 if (!after_unlocked_by_target && !user_gesture |
| 77 && !IsFullscreenForTabOrPending(tab)) { | |
| 76 tab->GotResponseToLockMouseRequest(false); | 78 tab->GotResponseToLockMouseRequest(false); |
| 77 return; | 79 return; |
| 78 } | 80 } |
| 79 | 81 |
| 80 mouse_lock_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); | 82 mouse_lock_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); |
| 81 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); | 83 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); |
| 82 | 84 |
| 83 switch (GetMouseLockSetting(tab->GetURL())) { | 85 switch (GetMouseLockSetting(tab->GetURL())) { |
| 84 case CONTENT_SETTING_ALLOW: | 86 case CONTENT_SETTING_ALLOW: |
| 85 // If bubble already displaying buttons we must not lock the mouse yet, | 87 // If bubble already displaying buttons we must not lock the mouse yet, |
| 86 // or it would prevent pressing those buttons. Instead, merge the request. | 88 // or it would prevent pressing those buttons. Instead, merge the request. |
| 87 if (fullscreen_bubble::ShowButtonsForType(bubble_type)) { | 89 if (fullscreen_bubble::ShowButtonsForType(bubble_type)) { |
| 88 mouse_lock_state_ = MOUSELOCK_REQUESTED; | 90 mouse_lock_state_ = MOUSELOCK_REQUESTED; |
| 89 } else { | 91 } else { |
| 90 // Lock mouse. | 92 // Lock mouse. |
| 91 if (tab->GotResponseToLockMouseRequest(true)) { | 93 if (tab->GotResponseToLockMouseRequest(true)) { |
| 92 mouse_lock_state_ = MOUSELOCK_ACCEPTED; | 94 if (after_unlocked_by_target) { |
| 95 mouse_lock_state_ = MOUSELOCK_ACCEPTED_SILENT; | |
| 96 } else { | |
| 97 mouse_lock_state_ = MOUSELOCK_ACCEPTED; | |
| 98 } | |
| 93 } else { | 99 } else { |
| 94 mouse_lock_tab_ = NULL; | 100 mouse_lock_tab_ = NULL; |
| 95 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 101 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
| 96 } | 102 } |
| 97 } | 103 } |
| 98 break; | 104 break; |
| 99 case CONTENT_SETTING_BLOCK: | 105 case CONTENT_SETTING_BLOCK: |
| 100 tab->GotResponseToLockMouseRequest(false); | 106 tab->GotResponseToLockMouseRequest(false); |
| 101 mouse_lock_tab_ = NULL; | 107 mouse_lock_tab_ = NULL; |
| 102 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 108 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 | 389 |
| 384 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() | 390 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() |
| 385 const { | 391 const { |
| 386 // In kiosk mode we always want to be fullscreen and do not want to show | 392 // In kiosk mode we always want to be fullscreen and do not want to show |
| 387 // exit instructions for browser mode fullscreen. | 393 // exit instructions for browser mode fullscreen. |
| 388 bool kiosk = false; | 394 bool kiosk = false; |
| 389 #if !defined(OS_MACOSX) // Kiosk mode not available on Mac. | 395 #if !defined(OS_MACOSX) // Kiosk mode not available on Mac. |
| 390 kiosk = CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 396 kiosk = CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
| 391 #endif | 397 #endif |
| 392 | 398 |
| 399 if(mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENT) { | |
| 400 return FEB_TYPE_NONE; | |
| 401 } | |
| 402 | |
| 393 if (fullscreened_tab_) { | 403 if (fullscreened_tab_) { |
| 394 if (tab_fullscreen_accepted_) { | 404 if (tab_fullscreen_accepted_) { |
| 395 if (IsMouseLocked()) { | 405 if (IsMouseLocked()) { |
| 396 return FEB_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION; | 406 return FEB_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION; |
| 397 } else if (IsMouseLockRequested()) { | 407 } else if (IsMouseLockRequested()) { |
| 398 return FEB_TYPE_MOUSELOCK_BUTTONS; | 408 return FEB_TYPE_MOUSELOCK_BUTTONS; |
| 399 } else { | 409 } else { |
| 400 return FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION; | 410 return FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION; |
| 401 } | 411 } |
| 402 } else { // Full screen not yet accepted. | 412 } else { // Full screen not yet accepted. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 window_->ExitFullscreen(); | 503 window_->ExitFullscreen(); |
| 494 extension_caused_fullscreen_ = GURL(); | 504 extension_caused_fullscreen_ = GURL(); |
| 495 } | 505 } |
| 496 UpdateFullscreenExitBubbleContent(); | 506 UpdateFullscreenExitBubbleContent(); |
| 497 | 507 |
| 498 // Once the window has become fullscreen it'll call back to | 508 // Once the window has become fullscreen it'll call back to |
| 499 // WindowFullscreenStateChanged(). We don't do this immediately as | 509 // WindowFullscreenStateChanged(). We don't do this immediately as |
| 500 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let | 510 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let |
| 501 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate. | 511 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate. |
| 502 } | 512 } |
| OLD | NEW |