Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 bool LockMouse(WebKit::WebWidget* webwidget, | |
| 32 webkit::ppapi::PluginInstance* plugin); | |
| 33 void UnlockMouse(WebKit::WebWidget* webwidget, | |
| 34 webkit::ppapi::PluginInstance* plugin); | |
| 35 bool IsPointerLockedTo(WebKit::WebWidget* webwidget); | |
| 36 bool IsMouseLockedTo(webkit::ppapi::PluginInstance* plugin); | |
|
piman
2012/01/18 19:00:59
On these 2 functions, they seem identical except f
scheib
2012/01/24 01:51:42
Refactoring has resulted in only one set of functi
| |
| 37 bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event); | |
| 38 | |
| 39 private: | |
| 40 // RenderView::Observer implementation. | |
| 41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 42 | |
| 43 // IPC handlers. | |
| 44 void OnLockMouseACK(bool succeeded); | |
| 45 void OnMouseLockLost(); | |
| 46 | |
| 47 bool MouseLockedOrPendingAction() const { | |
| 48 return mouse_locked_ || pending_lock_request_ || pending_unlock_request_; | |
| 49 } | |
| 50 | |
| 51 RenderViewImpl* render_view_impl_; | |
| 52 | |
| 53 bool mouse_locked_; | |
| 54 // If both |pending_lock_request_| and |pending_unlock_request_| are true, | |
| 55 // it means a lock request was sent before an unlock request and we haven't | |
| 56 // received responses for them. | |
| 57 // The logic in LockMouse() makes sure that a lock request won't be sent when | |
| 58 // there is a pending unlock request. | |
| 59 bool pending_lock_request_; | |
| 60 bool pending_unlock_request_; | |
| 61 | |
| 62 // |mouse_lock_webwidget_owner_| and |mouse_lock_plugin_owner_| | |
| 63 // store one (and only one) of the possible current owners of mouse lock. | |
| 64 // If they are non-NULL it doesn't indicate that the mouse has been locked, | |
| 65 // a pending request to lock the mouse can be outstanding. | |
| 66 // The objects are not owned by this class. | |
| 67 // | |
| 68 // Direct reference to two different possible owners is a trade off compared | |
| 69 // to adding a common interface both can inherit. The WebWidget would also | |
| 70 // require a wrapper to avoid adding the interface to the WebKit API. In | |
| 71 // total the abstraction would require more code than directly managing the | |
| 72 // two types of lock owner, and we have decided against adding that | |
| 73 // complexity. | |
| 74 WebKit::WebWidget* mouse_lock_webwidget_owner_; | |
|
piman
2012/01/18 19:00:59
Looking at the code, it seems that the only possib
scheib
2012/01/24 01:51:42
Refactoring has removed this issue, there is only
| |
| 75 webkit::ppapi::PluginInstance* mouse_lock_plugin_owner_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(MouseLockDispatcher); | |
| 78 }; | |
| 79 | |
| 80 #endif // CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_ | |
| OLD | NEW |