| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/render_view_mouse_lock_dispatcher.h" | 5 #include "content/renderer/render_widget_mouse_lock_dispatcher.h" |
| 6 | 6 |
| 7 #include "content/common/view_messages.h" | 7 #include "content/common/view_messages.h" |
| 8 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
| 9 #include "ipc/ipc_message.h" |
| 9 #include "third_party/WebKit/public/web/WebFrame.h" | 10 #include "third_party/WebKit/public/web/WebFrame.h" |
| 10 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 11 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 11 #include "third_party/WebKit/public/web/WebView.h" | 12 #include "third_party/WebKit/public/web/WebView.h" |
| 12 #include "third_party/WebKit/public/web/WebWidget.h" | 13 #include "third_party/WebKit/public/web/WebWidget.h" |
| 13 | 14 |
| 14 using blink::WebUserGestureIndicator; | 15 using blink::WebUserGestureIndicator; |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 RenderViewMouseLockDispatcher::RenderViewMouseLockDispatcher( | 19 RenderWidgetMouseLockDispatcher::RenderWidgetMouseLockDispatcher( |
| 19 RenderViewImpl* render_view_impl) | 20 RenderWidget* render_widget) |
| 20 : RenderViewObserver(render_view_impl), | 21 : render_widget_(render_widget) {} |
| 21 render_view_impl_(render_view_impl) { | |
| 22 } | |
| 23 | 22 |
| 24 RenderViewMouseLockDispatcher::~RenderViewMouseLockDispatcher() { | 23 RenderWidgetMouseLockDispatcher::~RenderWidgetMouseLockDispatcher() {} |
| 25 } | |
| 26 | 24 |
| 27 void RenderViewMouseLockDispatcher::SendLockMouseRequest( | 25 void RenderWidgetMouseLockDispatcher::SendLockMouseRequest( |
| 28 bool unlocked_by_target) { | 26 bool unlocked_by_target) { |
| 29 bool user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); | 27 bool user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
| 30 | 28 |
| 31 Send(new ViewHostMsg_LockMouse(routing_id(), user_gesture, unlocked_by_target, | 29 render_widget_->Send(new ViewHostMsg_LockMouse( |
| 32 false)); | 30 render_widget_->routing_id(), user_gesture, unlocked_by_target, false)); |
| 33 } | 31 } |
| 34 | 32 |
| 35 void RenderViewMouseLockDispatcher::SendUnlockMouseRequest() { | 33 void RenderWidgetMouseLockDispatcher::SendUnlockMouseRequest() { |
| 36 Send(new ViewHostMsg_UnlockMouse(routing_id())); | 34 render_widget_->Send( |
| 35 new ViewHostMsg_UnlockMouse(render_widget_->routing_id())); |
| 37 } | 36 } |
| 38 | 37 |
| 39 bool RenderViewMouseLockDispatcher::OnMessageReceived( | 38 bool RenderWidgetMouseLockDispatcher::OnMessageReceived( |
| 40 const IPC::Message& message) { | 39 const IPC::Message& message) { |
| 41 bool handled = true; | 40 bool handled = true; |
| 42 IPC_BEGIN_MESSAGE_MAP(RenderViewMouseLockDispatcher, message) | 41 IPC_BEGIN_MESSAGE_MAP(RenderWidgetMouseLockDispatcher, message) |
| 43 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) | 42 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) |
| 44 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, | 43 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, |
| 45 static_cast<MouseLockDispatcher*>(this), | 44 static_cast<MouseLockDispatcher*>(this), |
| 46 MouseLockDispatcher::OnMouseLockLost) | 45 MouseLockDispatcher::OnMouseLockLost) |
| 47 IPC_MESSAGE_UNHANDLED(handled = false) | 46 IPC_MESSAGE_UNHANDLED(handled = false) |
| 48 IPC_END_MESSAGE_MAP() | 47 IPC_END_MESSAGE_MAP() |
| 49 return handled; | 48 return handled; |
| 50 } | 49 } |
| 51 | 50 |
| 52 void RenderViewMouseLockDispatcher::OnLockMouseACK(bool succeeded) { | 51 void RenderWidgetMouseLockDispatcher::OnLockMouseACK(bool succeeded) { |
| 53 // Notify the base class. | 52 // Notify the base class. |
| 54 MouseLockDispatcher::OnLockMouseACK(succeeded); | 53 MouseLockDispatcher::OnLockMouseACK(succeeded); |
| 55 | 54 |
| 56 // Mouse Lock removes the system cursor and provides all mouse motion as | 55 // Mouse Lock removes the system cursor and provides all mouse motion as |
| 57 // .movementX/Y values on events all sent to a fixed target. This requires | 56 // .movementX/Y values on events all sent to a fixed target. This requires |
| 58 // content to specifically request the mode to be entered. | 57 // content to specifically request the mode to be entered. |
| 59 // Mouse Capture is implicitly given for the duration of a drag event, and | 58 // Mouse Capture is implicitly given for the duration of a drag event, and |
| 60 // sends all mouse events to the initial target of the drag. | 59 // sends all mouse events to the initial target of the drag. |
| 61 // If Lock is entered it supercedes any in progress Capture. | 60 // If Lock is entered it supercedes any in progress Capture. |
| 62 if (succeeded && render_view_impl_->GetWidget()->webwidget()) | 61 if (succeeded && render_widget_->webwidget()) |
| 63 render_view_impl_->GetWidget()->webwidget()->mouseCaptureLost(); | 62 render_widget_->webwidget()->mouseCaptureLost(); |
| 64 } | 63 } |
| 65 | 64 |
| 66 } // namespace content | 65 } // namespace content |
| OLD | NEW |