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

Side by Side Diff: content/renderer/mouse_lock_dispatcher.cc

Issue 10512011: Only set MouseLockDispatcher unlocked_by_target_ after mouse lock confirmed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge to tip of tree 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/renderer/mouse_lock_dispatcher.h" 5 #include "content/renderer/mouse_lock_dispatcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
9 9
10 MouseLockDispatcher::MouseLockDispatcher() : mouse_locked_(false), 10 MouseLockDispatcher::MouseLockDispatcher() : mouse_locked_(false),
(...skipping 14 matching lines...) Expand all
25 target_ = target; 25 target_ = target;
26 26
27 SendLockMouseRequest(unlocked_by_target_); 27 SendLockMouseRequest(unlocked_by_target_);
28 unlocked_by_target_ = false; 28 unlocked_by_target_ = false;
29 return true; 29 return true;
30 } 30 }
31 31
32 void MouseLockDispatcher::UnlockMouse(LockTarget* target) { 32 void MouseLockDispatcher::UnlockMouse(LockTarget* target) {
33 if (target && target == target_ && !pending_unlock_request_) { 33 if (target && target == target_ && !pending_unlock_request_) {
34 pending_unlock_request_ = true; 34 pending_unlock_request_ = true;
35 unlocked_by_target_ = true; 35
36 // When a target application voluntarily unlocks the mouse we permit
37 // relocking the mouse silently and with no user gesture requirement.
38 // Check that the lock request is not currently pending and not yet
39 // accepted by the browser process before setting |unlocked_by_target_|.
40 if (!pending_lock_request_)
41 unlocked_by_target_ = true;
42
36 SendUnlockMouseRequest(); 43 SendUnlockMouseRequest();
37 } 44 }
38 } 45 }
39 46
40 void MouseLockDispatcher::OnLockTargetDestroyed(LockTarget* target) { 47 void MouseLockDispatcher::OnLockTargetDestroyed(LockTarget* target) {
41 if (target == target_) { 48 if (target == target_) {
42 UnlockMouse(target); 49 UnlockMouse(target);
43 target_ = NULL; 50 target_ = NULL;
44 } 51 }
45 } 52 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 93
87 LockTarget* last_target = target_; 94 LockTarget* last_target = target_;
88 target_ = NULL; 95 target_ = NULL;
89 96
90 // Callbacks made after all state modification to prevent reentrant errors 97 // Callbacks made after all state modification to prevent reentrant errors
91 // such as OnMouseLockLost() synchronously calling LockMouse(). 98 // such as OnMouseLockLost() synchronously calling LockMouse().
92 99
93 if (last_target) 100 if (last_target)
94 last_target->OnMouseLockLost(); 101 last_target->OnMouseLockLost();
95 } 102 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698