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

Side by Side Diff: chrome/browser/ui/fullscreen_controller.cc

Issue 10443045: Silent mouse lock after unlock by target (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Changed back to booleans Created 8 years, 6 months 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 "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
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_SILENTLY;
67 } 68 }
68 69
69 void FullscreenController::RequestToLockMouse(WebContents* tab, 70 void FullscreenController::RequestToLockMouse(WebContents* tab,
70 bool user_gesture) { 71 bool user_gesture,
72 bool after_unlocked_by_target) {
71 DCHECK(!IsMouseLocked()); 73 DCHECK(!IsMouseLocked());
72 NotifyMouseLockChange(); 74 NotifyMouseLockChange();
73 75
74 // Must have a user gesture, or we must already be in tab fullscreen. 76 // Must have a user gesture to prevent misbehaving sites from constantly
75 if (!user_gesture && !IsFullscreenForTabOrPending(tab)) { 77 // re-locking the mouse. Exceptions are when the page has unlocked
78 // (i.e. not the user), or if we're in tab fullscreen (user gesture required
79 // for that)
80 if (!after_unlocked_by_target && !user_gesture
81 && !IsFullscreenForTabOrPending(tab)) {
76 tab->GotResponseToLockMouseRequest(false); 82 tab->GotResponseToLockMouseRequest(false);
77 return; 83 return;
78 } 84 }
79
80 mouse_lock_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); 85 mouse_lock_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab);
81 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); 86 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType();
82 87
83 switch (GetMouseLockSetting(tab->GetURL())) { 88 switch (GetMouseLockSetting(tab->GetURL())) {
84 case CONTENT_SETTING_ALLOW: 89 case CONTENT_SETTING_ALLOW:
85 // If bubble already displaying buttons we must not lock the mouse yet, 90 // If bubble already displaying buttons we must not lock the mouse yet,
86 // or it would prevent pressing those buttons. Instead, merge the request. 91 // or it would prevent pressing those buttons. Instead, merge the request.
87 if (fullscreen_bubble::ShowButtonsForType(bubble_type)) { 92 if (fullscreen_bubble::ShowButtonsForType(bubble_type)) {
88 mouse_lock_state_ = MOUSELOCK_REQUESTED; 93 mouse_lock_state_ = MOUSELOCK_REQUESTED;
89 } else { 94 } else {
90 // Lock mouse. 95 // Lock mouse.
91 if (tab->GotResponseToLockMouseRequest(true)) { 96 if (tab->GotResponseToLockMouseRequest(true)) {
92 mouse_lock_state_ = MOUSELOCK_ACCEPTED; 97 if (after_unlocked_by_target) {
98 mouse_lock_state_ = MOUSELOCK_ACCEPTED_SILENTLY;
99 } else {
100 mouse_lock_state_ = MOUSELOCK_ACCEPTED;
101 }
93 } else { 102 } else {
94 mouse_lock_tab_ = NULL; 103 mouse_lock_tab_ = NULL;
95 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; 104 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
96 } 105 }
97 } 106 }
98 break; 107 break;
99 case CONTENT_SETTING_BLOCK: 108 case CONTENT_SETTING_BLOCK:
100 tab->GotResponseToLockMouseRequest(false); 109 tab->GotResponseToLockMouseRequest(false);
101 mouse_lock_tab_ = NULL; 110 mouse_lock_tab_ = NULL;
102 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; 111 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 392
384 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType() 393 FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType()
385 const { 394 const {
386 // In kiosk mode we always want to be fullscreen and do not want to show 395 // In kiosk mode we always want to be fullscreen and do not want to show
387 // exit instructions for browser mode fullscreen. 396 // exit instructions for browser mode fullscreen.
388 bool kiosk = false; 397 bool kiosk = false;
389 #if !defined(OS_MACOSX) // Kiosk mode not available on Mac. 398 #if !defined(OS_MACOSX) // Kiosk mode not available on Mac.
390 kiosk = CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); 399 kiosk = CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode);
391 #endif 400 #endif
392 401
402 if(mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY) {
403 return FEB_TYPE_NONE;
404 }
405
393 if (fullscreened_tab_) { 406 if (fullscreened_tab_) {
394 if (tab_fullscreen_accepted_) { 407 if (tab_fullscreen_accepted_) {
395 if (IsMouseLocked()) { 408 if (IsMouseLocked()) {
396 return FEB_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION; 409 return FEB_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION;
397 } else if (IsMouseLockRequested()) { 410 } else if (IsMouseLockRequested()) {
398 return FEB_TYPE_MOUSELOCK_BUTTONS; 411 return FEB_TYPE_MOUSELOCK_BUTTONS;
399 } else { 412 } else {
400 return FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION; 413 return FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION;
401 } 414 }
402 } else { // Full screen not yet accepted. 415 } else { // Full screen not yet accepted.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 window_->ExitFullscreen(); 506 window_->ExitFullscreen();
494 extension_caused_fullscreen_ = GURL(); 507 extension_caused_fullscreen_ = GURL();
495 } 508 }
496 UpdateFullscreenExitBubbleContent(); 509 UpdateFullscreenExitBubbleContent();
497 510
498 // Once the window has become fullscreen it'll call back to 511 // Once the window has become fullscreen it'll call back to
499 // WindowFullscreenStateChanged(). We don't do this immediately as 512 // WindowFullscreenStateChanged(). We don't do this immediately as
500 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let 513 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let
501 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate. 514 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate.
502 } 515 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698