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

Side by Side Diff: content/renderer/render_view_mouse_lock_dispatcher.cc

Issue 1980133002: Implement pointer lock API for out-of-process iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
« no previous file with comments | « content/renderer/render_view_mouse_lock_dispatcher.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/renderer/render_view_mouse_lock_dispatcher.h"
6
7 #include "content/common/view_messages.h"
8 #include "content/renderer/render_view_impl.h"
9 #include "third_party/WebKit/public/web/WebFrame.h"
10 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
11 #include "third_party/WebKit/public/web/WebView.h"
12 #include "third_party/WebKit/public/web/WebWidget.h"
13
14 using blink::WebUserGestureIndicator;
15
16 namespace content {
17
18 RenderViewMouseLockDispatcher::RenderViewMouseLockDispatcher(
19 RenderViewImpl* render_view_impl)
20 : RenderViewObserver(render_view_impl),
21 render_view_impl_(render_view_impl) {
22 }
23
24 RenderViewMouseLockDispatcher::~RenderViewMouseLockDispatcher() {
25 }
26
27 void RenderViewMouseLockDispatcher::SendLockMouseRequest(
28 bool unlocked_by_target) {
29 bool user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
30
31 Send(new ViewHostMsg_LockMouse(routing_id(), user_gesture, unlocked_by_target,
32 false));
33 }
34
35 void RenderViewMouseLockDispatcher::SendUnlockMouseRequest() {
36 Send(new ViewHostMsg_UnlockMouse(routing_id()));
37 }
38
39 bool RenderViewMouseLockDispatcher::OnMessageReceived(
40 const IPC::Message& message) {
41 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(RenderViewMouseLockDispatcher, message)
43 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK)
44 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost,
45 static_cast<MouseLockDispatcher*>(this),
46 MouseLockDispatcher::OnMouseLockLost)
47 IPC_MESSAGE_UNHANDLED(handled = false)
48 IPC_END_MESSAGE_MAP()
49 return handled;
50 }
51
52 void RenderViewMouseLockDispatcher::OnDestruct() {
53 delete this;
54 }
55
56 void RenderViewMouseLockDispatcher::OnLockMouseACK(bool succeeded) {
57 // Notify the base class.
58 MouseLockDispatcher::OnLockMouseACK(succeeded);
59
60 // Mouse Lock removes the system cursor and provides all mouse motion as
61 // .movementX/Y values on events all sent to a fixed target. This requires
62 // content to specifically request the mode to be entered.
63 // Mouse Capture is implicitly given for the duration of a drag event, and
64 // sends all mouse events to the initial target of the drag.
65 // If Lock is entered it supercedes any in progress Capture.
66 if (succeeded && render_view_impl_->GetWidget()->webwidget())
67 render_view_impl_->GetWidget()->webwidget()->mouseCaptureLost();
68 }
69
70 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_mouse_lock_dispatcher.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698