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

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

Issue 10458008: Support mouse lock in Flash fullscreen mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 #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 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "content/public/renderer/render_view_observer.h"
11
12 class RenderViewImpl;
13 10
14 namespace WebKit { 11 namespace WebKit {
15 class WebMouseEvent; 12 class WebMouseEvent;
16 class WebWidget;
17 } // namespace WebKit 13 } // namespace WebKit
18 14
19 namespace webkit{ 15 class MouseLockDispatcher {
20 namespace ppapi {
21 class PluginInstance;
22 } // namespace ppapi
23 } // namespace webkit
24
25 // MouseLockDispatcher is owned by RenderViewImpl.
26 class CONTENT_EXPORT MouseLockDispatcher : public content::RenderViewObserver {
27 public: 16 public:
28 explicit MouseLockDispatcher(RenderViewImpl* render_view_impl); 17 MouseLockDispatcher();
29 virtual ~MouseLockDispatcher(); 18 virtual ~MouseLockDispatcher();
30 19
31 class LockTarget { 20 class LockTarget {
32 public: 21 public:
33 virtual ~LockTarget() {} 22 virtual ~LockTarget() {}
34 // A mouse lock request was pending and this reports success or failure. 23 // A mouse lock request was pending and this reports success or failure.
35 virtual void OnLockMouseACK(bool succeeded) = 0; 24 virtual void OnLockMouseACK(bool succeeded) = 0;
36 // A mouse lock was in place, but has been lost. 25 // A mouse lock was in place, but has been lost.
37 virtual void OnMouseLockLost() = 0; 26 virtual void OnMouseLockLost() = 0;
38 // A mouse lock is enabled and mouse events are being delievered. 27 // A mouse lock is enabled and mouse events are being delievered.
39 virtual bool HandleMouseLockedInputEvent( 28 virtual bool HandleMouseLockedInputEvent(
40 const WebKit::WebMouseEvent& event) = 0; 29 const WebKit::WebMouseEvent& event) = 0;
41 }; 30 };
42 31
43 // Locks the mouse to the |target|. If true is returned, an asynchronous 32 // Locks the mouse to the |target|. If true is returned, an asynchronous
44 // response to target->OnLockMouseACK() will follow. 33 // response to target->OnLockMouseACK() will follow.
45 bool LockMouse(LockTarget* target); 34 bool LockMouse(LockTarget* target);
46 // Request to unlock the mouse. An asynchronous response to 35 // Request to unlock the mouse. An asynchronous response to
47 // target->OnMouseLockLost() will follow. 36 // target->OnMouseLockLost() will follow.
48 void UnlockMouse(LockTarget* target); 37 void UnlockMouse(LockTarget* target);
49 // Clears out the reference to the |target| because it has or is being 38 // Clears out the reference to the |target| because it has or is being
50 // destroyed. Unlocks if locked. The pointer will not be accessed. 39 // destroyed. Unlocks if locked. The pointer will not be accessed.
51 void OnLockTargetDestroyed(LockTarget* target); 40 void OnLockTargetDestroyed(LockTarget* target);
52 bool IsMouseLockedTo(LockTarget* target); 41 bool IsMouseLockedTo(LockTarget* target);
53 42
54 // Allow lock target to consumed a mouse event, if it does return true. 43 // Allow lock target to consumed a mouse event, if it does return true.
55 bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event); 44 bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event);
56 45
57 private: 46 // Subclasses or users have to call these methods to report mouse lock events
58 // RenderView::Observer implementation. 47 // from the browser.
59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
60
61 // IPC handlers.
62 void OnLockMouseACK(bool succeeded); 48 void OnLockMouseACK(bool succeeded);
63 void OnMouseLockLost(); 49 void OnMouseLockLost();
64 50
51 protected:
52 // Subclasses must implement these methods to send mouse lock requests to the
53 // browser.
54 virtual void SendLockMouseRequest() = 0;
55 virtual void SendUnlockMouseRequest() = 0;
56
57 private:
65 bool MouseLockedOrPendingAction() const { 58 bool MouseLockedOrPendingAction() const {
66 return mouse_locked_ || pending_lock_request_ || pending_unlock_request_; 59 return mouse_locked_ || pending_lock_request_ || pending_unlock_request_;
67 } 60 }
68 61
69 RenderViewImpl* render_view_impl_;
70
71 bool mouse_locked_; 62 bool mouse_locked_;
72 // If both |pending_lock_request_| and |pending_unlock_request_| are true, 63 // If both |pending_lock_request_| and |pending_unlock_request_| are true,
73 // it means a lock request was sent before an unlock request and we haven't 64 // it means a lock request was sent before an unlock request and we haven't
74 // received responses for them. The logic in LockMouse() makes sure that a 65 // received responses for them. The logic in LockMouse() makes sure that a
75 // lock request won't be sent when there is a pending unlock request. 66 // lock request won't be sent when there is a pending unlock request.
76 bool pending_lock_request_; 67 bool pending_lock_request_;
77 bool pending_unlock_request_; 68 bool pending_unlock_request_;
78 69
79 // |target_| is the pending or current owner of mouse lock. We retain a non 70 // |target_| is the pending or current owner of mouse lock. We retain a non
80 // owning reference here that must be cleared by |OnLockTargetDestroyed| 71 // owning reference here that must be cleared by |OnLockTargetDestroyed|
81 // when it is destroyed. 72 // when it is destroyed.
82 LockTarget* target_; 73 LockTarget* target_;
83 74
84 DISALLOW_COPY_AND_ASSIGN(MouseLockDispatcher); 75 DISALLOW_COPY_AND_ASSIGN(MouseLockDispatcher);
85 }; 76 };
86 77
87 #endif // CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_ 78 #endif // CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698