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

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

Issue 10443045: Silent mouse lock after unlock by target (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: forgot to fix some syntax Created 8 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
OLDNEW
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/mouse_lock_dispatcher.h" 5 #include "content/renderer/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 "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
12 12
13 MouseLockDispatcher::MouseLockDispatcher(RenderViewImpl* render_view_impl) 13 MouseLockDispatcher::MouseLockDispatcher(RenderViewImpl* render_view_impl)
14 : content::RenderViewObserver(render_view_impl), 14 : content::RenderViewObserver(render_view_impl),
15 render_view_impl_(render_view_impl), 15 render_view_impl_(render_view_impl),
16 mouse_locked_(false), 16 mouse_locked_(false),
17 pending_lock_request_(false), 17 pending_lock_request_(false),
18 pending_unlock_request_(false), 18 pending_unlock_request_(false),
19 unlocked_by_target_(false),
19 target_(NULL) { 20 target_(NULL) {
20 } 21 }
21 22
22 MouseLockDispatcher::~MouseLockDispatcher() { 23 MouseLockDispatcher::~MouseLockDispatcher() {
23 } 24 }
24 25
25 bool MouseLockDispatcher::LockMouse(LockTarget* target) { 26 bool MouseLockDispatcher::LockMouse(LockTarget* target) {
26 if (MouseLockedOrPendingAction()) 27 if (MouseLockedOrPendingAction())
27 return false; 28 return false;
28 29
29 pending_lock_request_ = true; 30 pending_lock_request_ = true;
30 target_ = target; 31 target_ = target;
31 32
32 bool user_gesture = 33 bool user_gesture =
33 render_view_impl_->webview() && 34 render_view_impl_->webview() &&
34 render_view_impl_->webview()->mainFrame() && 35 render_view_impl_->webview()->mainFrame() &&
35 render_view_impl_->webview()->mainFrame()->isProcessingUserGesture(); 36 render_view_impl_->webview()->mainFrame()->isProcessingUserGesture();
36 37 Send(new ViewHostMsg_LockMouse(routing_id(),
37 Send(new ViewHostMsg_LockMouse(routing_id(), user_gesture)); 38 user_gesture,
39 unlocked_by_target_));
40 unlocked_by_target_ = false;
38 return true; 41 return true;
39 } 42 }
40 43
41 void MouseLockDispatcher::UnlockMouse(LockTarget* target) { 44 void MouseLockDispatcher::UnlockMouse(LockTarget* target) {
42 if (target && target == target_ && !pending_unlock_request_) { 45 if (target && target == target_ && !pending_unlock_request_) {
43 pending_unlock_request_ = true; 46 pending_unlock_request_ = true;
47 unlocked_by_target_ = true;
44 Send(new ViewHostMsg_UnlockMouse(routing_id())); 48 Send(new ViewHostMsg_UnlockMouse(routing_id()));
45 } 49 }
46 } 50 }
47 51
48 void MouseLockDispatcher::OnLockTargetDestroyed(LockTarget* target) { 52 void MouseLockDispatcher::OnLockTargetDestroyed(LockTarget* target) {
49 if (target == target_) { 53 if (target == target_) {
50 UnlockMouse(target); 54 UnlockMouse(target);
51 target_ = NULL; 55 target_ = NULL;
52 } 56 }
53 } 57 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 117
114 LockTarget* last_target = target_; 118 LockTarget* last_target = target_;
115 target_ = NULL; 119 target_ = NULL;
116 120
117 // Callbacks made after all state modification to prevent reentrant errors 121 // Callbacks made after all state modification to prevent reentrant errors
118 // such as OnMouseLockLost() synchronously calling LockMouse(). 122 // such as OnMouseLockLost() synchronously calling LockMouse().
119 123
120 if (last_target) 124 if (last_target)
121 last_target->OnMouseLockLost(); 125 last_target->OnMouseLockLost();
122 } 126 }
123
OLDNEW
« content/renderer/mouse_lock_dispatcher.h ('K') | « content/renderer/mouse_lock_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698