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); |
| 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 // are not owned by this class. |
| 64 // If they are non-NULL it doesn't indicate that the |
| 65 // mouse has been locked. It is possible that a request to lock the mouse has |
| 66 // been sent, but the response hasn't arrived yet. |
| 67 WebKit::WebWidget* mouse_lock_webwidget_owner_; |
| 68 webkit::ppapi::PluginInstance* mouse_lock_plugin_owner_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(MouseLockDispatcher); |
| 71 }; |
| 72 |
| 73 #endif // CONTENT_RENDERER_MOUSE_LOCK_DISPATCHER_H_ |
OLD | NEW |