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 #ifndef CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_ |
6 #define CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
10 | 10 |
11 namespace WebKit { | 11 namespace blink { |
12 class WebMouseEvent; | 12 class WebMouseEvent; |
13 } // namespace WebKit | 13 } // namespace blink |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class CONTENT_EXPORT MouseLockDispatcher { | 17 class CONTENT_EXPORT MouseLockDispatcher { |
18 public: | 18 public: |
19 MouseLockDispatcher(); | 19 MouseLockDispatcher(); |
20 virtual ~MouseLockDispatcher(); | 20 virtual ~MouseLockDispatcher(); |
21 | 21 |
22 class LockTarget { | 22 class LockTarget { |
23 public: | 23 public: |
24 virtual ~LockTarget() {} | 24 virtual ~LockTarget() {} |
25 // A mouse lock request was pending and this reports success or failure. | 25 // A mouse lock request was pending and this reports success or failure. |
26 virtual void OnLockMouseACK(bool succeeded) = 0; | 26 virtual void OnLockMouseACK(bool succeeded) = 0; |
27 // A mouse lock was in place, but has been lost. | 27 // A mouse lock was in place, but has been lost. |
28 virtual void OnMouseLockLost() = 0; | 28 virtual void OnMouseLockLost() = 0; |
29 // A mouse lock is enabled and mouse events are being delievered. | 29 // A mouse lock is enabled and mouse events are being delievered. |
30 virtual bool HandleMouseLockedInputEvent( | 30 virtual bool HandleMouseLockedInputEvent( |
31 const WebKit::WebMouseEvent& event) = 0; | 31 const blink::WebMouseEvent& event) = 0; |
32 }; | 32 }; |
33 | 33 |
34 // Locks the mouse to the |target|. If true is returned, an asynchronous | 34 // Locks the mouse to the |target|. If true is returned, an asynchronous |
35 // response to target->OnLockMouseACK() will follow. | 35 // response to target->OnLockMouseACK() will follow. |
36 bool LockMouse(LockTarget* target); | 36 bool LockMouse(LockTarget* target); |
37 // Request to unlock the mouse. An asynchronous response to | 37 // Request to unlock the mouse. An asynchronous response to |
38 // target->OnMouseLockLost() will follow. | 38 // target->OnMouseLockLost() will follow. |
39 void UnlockMouse(LockTarget* target); | 39 void UnlockMouse(LockTarget* target); |
40 // Clears out the reference to the |target| because it has or is being | 40 // Clears out the reference to the |target| because it has or is being |
41 // destroyed. Unlocks if locked. The pointer will not be accessed. | 41 // destroyed. Unlocks if locked. The pointer will not be accessed. |
42 void OnLockTargetDestroyed(LockTarget* target); | 42 void OnLockTargetDestroyed(LockTarget* target); |
43 bool IsMouseLockedTo(LockTarget* target); | 43 bool IsMouseLockedTo(LockTarget* target); |
44 | 44 |
45 // Allow lock target to consumed a mouse event, if it does return true. | 45 // Allow lock target to consumed a mouse event, if it does return true. |
46 bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event); | 46 bool WillHandleMouseEvent(const blink::WebMouseEvent& event); |
47 | 47 |
48 // Subclasses or users have to call these methods to report mouse lock events | 48 // Subclasses or users have to call these methods to report mouse lock events |
49 // from the browser. | 49 // from the browser. |
50 void OnLockMouseACK(bool succeeded); | 50 void OnLockMouseACK(bool succeeded); |
51 void OnMouseLockLost(); | 51 void OnMouseLockLost(); |
52 | 52 |
53 protected: | 53 protected: |
54 // Subclasses must implement these methods to send mouse lock requests to the | 54 // Subclasses must implement these methods to send mouse lock requests to the |
55 // browser. | 55 // browser. |
56 virtual void SendLockMouseRequest(bool unlocked_by_target) = 0; | 56 virtual void SendLockMouseRequest(bool unlocked_by_target) = 0; |
(...skipping 21 matching lines...) Expand all Loading... |
78 // owning reference here that must be cleared by |OnLockTargetDestroyed| | 78 // owning reference here that must be cleared by |OnLockTargetDestroyed| |
79 // when it is destroyed. | 79 // when it is destroyed. |
80 LockTarget* target_; | 80 LockTarget* target_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(MouseLockDispatcher); | 82 DISALLOW_COPY_AND_ASSIGN(MouseLockDispatcher); |
83 }; | 83 }; |
84 | 84 |
85 } // namespace content | 85 } // namespace content |
86 | 86 |
87 #endif // CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_ | 87 #endif // CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_ |
OLD | NEW |