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

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

Issue 2915613004: [PointerLock] Move "silent mouse lock" logic from renderer to RWHI (Closed)
Patch Set: jochen's comment: Remove 'const' before local bool Created 3 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 "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/public/platform/WebInputEvent.h" 8 #include "third_party/WebKit/public/platform/WebInputEvent.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 MouseLockDispatcher::MouseLockDispatcher() : mouse_locked_(false), 12 MouseLockDispatcher::MouseLockDispatcher() : mouse_locked_(false),
13 pending_lock_request_(false), 13 pending_lock_request_(false),
14 pending_unlock_request_(false), 14 pending_unlock_request_(false),
15 unlocked_by_target_(false),
16 target_(NULL) { 15 target_(NULL) {
17 } 16 }
18 17
19 MouseLockDispatcher::~MouseLockDispatcher() { 18 MouseLockDispatcher::~MouseLockDispatcher() {
20 } 19 }
21 20
22 bool MouseLockDispatcher::LockMouse(LockTarget* target) { 21 bool MouseLockDispatcher::LockMouse(LockTarget* target) {
23 if (MouseLockedOrPendingAction()) 22 if (MouseLockedOrPendingAction())
24 return false; 23 return false;
25 24
26 pending_lock_request_ = true; 25 pending_lock_request_ = true;
27 target_ = target; 26 target_ = target;
28 27
29 SendLockMouseRequest(unlocked_by_target_); 28 SendLockMouseRequest();
30 unlocked_by_target_ = false;
31 return true; 29 return true;
32 } 30 }
33 31
34 void MouseLockDispatcher::UnlockMouse(LockTarget* target) { 32 void MouseLockDispatcher::UnlockMouse(LockTarget* target) {
35 if (target && target == target_ && !pending_unlock_request_) { 33 if (target && target == target_ && !pending_unlock_request_) {
36 pending_unlock_request_ = true; 34 pending_unlock_request_ = true;
37 35
38 // When a target application voluntarily unlocks the mouse we permit
39 // relocking the mouse silently and with no user gesture requirement.
40 // Check that the lock request is not currently pending and not yet
41 // accepted by the browser process before setting |unlocked_by_target_|.
42 if (!pending_lock_request_)
43 unlocked_by_target_ = true;
44
45 SendUnlockMouseRequest(); 36 SendUnlockMouseRequest();
46 } 37 }
47 } 38 }
48 39
49 void MouseLockDispatcher::OnLockTargetDestroyed(LockTarget* target) { 40 void MouseLockDispatcher::OnLockTargetDestroyed(LockTarget* target) {
50 if (target == target_) { 41 if (target == target_) {
51 UnlockMouse(target); 42 UnlockMouse(target);
52 target_ = NULL; 43 target_ = NULL;
53 } 44 }
54 } 45 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 target_ = NULL; 88 target_ = NULL;
98 89
99 // Callbacks made after all state modification to prevent reentrant errors 90 // Callbacks made after all state modification to prevent reentrant errors
100 // such as OnMouseLockLost() synchronously calling LockMouse(). 91 // such as OnMouseLockLost() synchronously calling LockMouse().
101 92
102 if (last_target) 93 if (last_target)
103 last_target->OnMouseLockLost(); 94 last_target->OnMouseLockLost();
104 } 95 }
105 96
106 } // namespace content 97 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/mouse_lock_dispatcher.h ('k') | content/renderer/render_widget_fullscreen_pepper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698