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

Unified 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: Updated webkit API names. 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/mouse_lock_dispatcher.h
diff --git a/content/renderer/mouse_lock_dispatcher.h b/content/renderer/mouse_lock_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..61285cc93bc0fda07fb99dfabe3f7a72326bedbd
--- /dev/null
+++ b/content/renderer/mouse_lock_dispatcher.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
yzshen1 2012/01/16 07:50:35 2012. (Yes, apocalypse is very close now. :))
scheib 2012/01/17 22:05:36 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOUSE_LOCK_DISPATCHER_H_
yzshen1 2012/01/16 07:50:35 You should list the full path.
scheib 2012/01/17 22:05:36 Done.
+#define MOUSE_LOCK_DISPATCHER_H_
+#pragma once
+
+#include "content/public/renderer/render_view_observer.h"
+
+class RenderViewImpl;
+class WebMouseEvent;
yzshen1 2012/01/16 07:50:35 It is in WebKit namespace.
scheib 2012/01/17 22:05:36 Done.
+
+namespace WebKit {
+class WebWidget;
+} // namespace WebKit
+
+namespace webkit{
+namespace ppapi {
+class PluginInstance;
+} // namespace ppapi
+} // namespace webkit
+
+// MouseLockDispatcherDispatcher is owned by RenderViewImpl.
yzshen1 2012/01/16 07:50:35 One redundant Dispatcher.
scheib 2012/01/17 22:05:36 Done.
+class MouseLockDispatcher : public content::RenderViewObserver {
+ public:
+ explicit MouseLockDispatcher(RenderViewImpl* render_view_impl);
+ virtual ~MouseLockDispatcher();
+
+ bool LockMouse(WebKit::WebWidget* webwidget,
yzshen1 2012/01/16 07:50:35 It is better to have the same interface for webwid
scheib 2012/01/17 22:05:36 I started that way, and showed darin. He did not l
yzshen1 2012/01/17 23:39:25 Okay, if that has been carefully considered. Plea
scheib 2012/01/18 17:54:58 We did consider an adapter as well, but that would
+ webkit::ppapi::PluginInstance* pinstance);
+ void UnlockMouse(WebKit::WebWidget* webwidget,
+ webkit::ppapi::PluginInstance* pinstance);
+ bool IsPointerLockedTo(WebKit::WebWidget* webwidget);
+ bool IsMouseLockedTo(webkit::ppapi::PluginInstance* pinstance);
+ bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event);
+
+ private:
+ // RenderView::Observer implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ // IPC handlers.
+ void OnLockMouseACK(bool succeeded);
+ void OnMouseLockLost();
+
+
yzshen1 2012/01/16 07:50:35 One empty line is enough.
scheib 2012/01/17 22:05:36 Done.
+ bool MouseLockedOrPendingAction() const {
+ return mouse_locked_ || pending_lock_request_ || pending_unlock_request_;
+ }
+
+ RenderViewImpl* render_view_impl_;
+
+ bool mouse_locked_;
+ // If both |pending_lock_request_| and |pending_unlock_request_| are true,
+ // it means a lock request was sent before an unlock request and we haven't
+ // received responses for them.
+ // The logic in LockMouse() makes sure that a lock request won't be sent when
+ // there is a pending unlock request.
+ bool pending_lock_request_;
+ bool pending_unlock_request_;
+
+ // |mouse_lock_webwidget_owner_| and |mouse_lock_pinstance_owner_|
+ // are not owned by this class.
+ // If they are non-NULL it doesn't indicate that the
+ // mouse has been locked. It is possible that a request to lock the mouse has
+ // been sent, but the response hasn't arrived yet.
+ WebKit::WebWidget* mouse_lock_webwidget_owner_;
+ webkit::ppapi::PluginInstance* mouse_lock_pinstance_owner_;
+
+ DISALLOW_COPY_AND_ASSIGN(MouseLockDispatcher);
yzshen1 2012/01/16 07:50:35 You should include .h for DISALLOW_COPY_AND_ASSIGN
scheib 2012/01/17 22:05:36 Done.
+};
+
+#endif // MOUSE_LOCK_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698