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

Unified 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: Update for silent mouse relock Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/fullscreen_controller.cc
diff --git a/chrome/browser/ui/fullscreen_controller.cc b/chrome/browser/ui/fullscreen_controller.cc
index 1280bc3e60b8ca9b3e44dbc314bf6c058ce824ca..94bc237670f53f3d688118b03d60d43f32dbeee8 100644
--- a/chrome/browser/ui/fullscreen_controller.cc
+++ b/chrome/browser/ui/fullscreen_controller.cc
@@ -63,16 +63,24 @@ bool FullscreenController::IsMouseLockRequested() const {
}
bool FullscreenController::IsMouseLocked() const {
- return mouse_lock_state_ == MOUSELOCK_ACCEPTED;
+ return mouse_lock_state_ == MOUSELOCK_ACCEPTED
+ || mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY;
}
-void FullscreenController::RequestToLockMouse(WebContents* tab,
- bool user_gesture) {
+void FullscreenController::RequestToLockMouse(
+ content::WebContents* tab,
+ content::MouseLockSource lock_source,
+ content::MouseUnlockSource previous_unlock_source) {
DCHECK(!IsMouseLocked());
NotifyMouseLockChange();
- // Must have a user gesture, or we must already be in tab fullscreen.
- if (!user_gesture && !IsFullscreenForTabOrPending(tab)) {
+ // Must have a user gesture to prevent misbehaving sites from constantly
+ // re-locking the mouse. Exceptions are when the page has unlocked
+ // (i.e. not the user), or if we're in tab fullscreen (user gesture required
+ // for that)
+ if (previous_unlock_source != content::TARGET &&
+ lock_source != content::USER_GESTURE &&
+ !IsFullscreenForTabOrPending(tab)) {
tab->GotResponseToLockMouseRequest(false);
return;
}
@@ -89,7 +97,11 @@ void FullscreenController::RequestToLockMouse(WebContents* tab,
} else {
// Lock mouse.
if (tab->GotResponseToLockMouseRequest(true)) {
- mouse_lock_state_ = MOUSELOCK_ACCEPTED;
+ if (previous_unlock_source == content::TARGET) {
+ mouse_lock_state_ = MOUSELOCK_ACCEPTED_SILENTLY;
+ } else {
+ mouse_lock_state_ = MOUSELOCK_ACCEPTED;
+ }
} else {
mouse_lock_tab_ = NULL;
mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
@@ -390,6 +402,10 @@ FullscreenExitBubbleType FullscreenController::GetFullscreenExitBubbleType()
kiosk = CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode);
#endif
+ if(mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY) {
+ return FEB_TYPE_NONE;
+ }
+
if (fullscreened_tab_) {
if (tab_fullscreen_accepted_) {
if (IsMouseLocked()) {

Powered by Google App Engine
This is Rietveld 408576698