| 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 "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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |