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

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

Issue 8970016: refactoring mouse lock to support pepper and WebKit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes & WebKit APIs are bound now. Created 8 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_
6 #define CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "content/public/renderer/render_view_observer.h"
11
12 class RenderViewImpl;
13
14 namespace WebKit {
15 class WebMouseEvent;
16 class WebWidget;
17 } // namespace WebKit
18
19 namespace webkit{
20 namespace ppapi {
21 class PluginInstance;
22 } // namespace ppapi
23 } // namespace webkit
24
25 // MouseLockDispatcher is owned by RenderViewImpl.
26 class MouseLockDispatcher : public content::RenderViewObserver {
27 public:
28 explicit MouseLockDispatcher(RenderViewImpl* render_view_impl);
29 virtual ~MouseLockDispatcher();
30
31 class LockTarget {
32 public:
33 virtual ~LockTarget() {}
34 // A mouse lock request was pending and this reports success or failure.
35 virtual void OnLockMouseACK(bool succeeded) = 0;
36 // A mouse lock was in place, but has been lost.
37 virtual void OnMouseLockLost() = 0;
38 // A mouse lock is enabled and mouse events are being delievered.
39 virtual bool HandleMouseLockedInputEvent(
40 const WebKit::WebMouseEvent& event) = 0;
41 };
42
43 // Locks the mouse to the |target|. If true is returned, an asynchronous
44 // response to target->OnLockMouseACK() will follow.
45 bool LockMouse(LockTarget* target);
46 // Request to unlock the mouse. An asynchronous response to
47 // target->OnMouseLockLost() will follow.
48 void UnlockMouse(LockTarget* target);
49 // Clears out the reference to the |target| because it has or is being
50 // destroyed. Unlocks if locked. The pointer will not be accessed.
51 void OnLockTargetDestroyed(LockTarget* target);
52 bool IsMouseLockedTo(LockTarget* target);
53
54 // Allow lock target to consumed a mouse event, if it does return true.
55 bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event);
56
57 private:
58 // RenderView::Observer implementation.
59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
60
61 // IPC handlers.
62 void OnLockMouseACK(bool succeeded);
63 void OnMouseLockLost();
64
65 bool MouseLockedOrPendingAction() const {
66 return mouse_locked_ || pending_lock_request_ || pending_unlock_request_;
67 }
68
69 RenderViewImpl* render_view_impl_;
70
71 bool mouse_locked_;
72 // 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
74 // 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.
76 bool pending_lock_request_;
77 bool pending_unlock_request_;
78
79 // |target_| is the pending or current owner of mouse lock. We retain a non
80 // owning reference here that must be cleared by |UnlockMouseAndClearTarget|
piman 2012/01/26 01:31:27 nit: s/UnlockMouseAndClearTarget/OnLockTargetDestr
scheib 2012/01/26 01:37:59 Done.
81 // when it is destroyed.
82 LockTarget* target_;
83
84 DISALLOW_COPY_AND_ASSIGN(MouseLockDispatcher);
85 };
86
87 #endif // CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698