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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2915613004: [PointerLock] Move "silent mouse lock" logic from renderer to RWHI (Closed)
Patch Set: Created 3 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/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 is_unresponsive_(false), 279 is_unresponsive_(false),
280 in_flight_event_count_(0), 280 in_flight_event_count_(0),
281 in_get_backing_store_(false), 281 in_get_backing_store_(false),
282 ignore_input_events_(false), 282 ignore_input_events_(false),
283 text_direction_updated_(false), 283 text_direction_updated_(false),
284 text_direction_(blink::kWebTextDirectionLeftToRight), 284 text_direction_(blink::kWebTextDirectionLeftToRight),
285 text_direction_canceled_(false), 285 text_direction_canceled_(false),
286 suppress_events_until_keydown_(false), 286 suppress_events_until_keydown_(false),
287 pending_mouse_lock_request_(false), 287 pending_mouse_lock_request_(false),
288 allow_privileged_mouse_lock_(false), 288 allow_privileged_mouse_lock_(false),
289 is_last_unlocked_by_target_(false),
289 has_touch_handler_(false), 290 has_touch_handler_(false),
290 is_in_touchpad_gesture_fling_(false), 291 is_in_touchpad_gesture_fling_(false),
291 latency_tracker_(), 292 latency_tracker_(),
292 next_browser_snapshot_id_(1), 293 next_browser_snapshot_id_(1),
293 owned_by_render_frame_host_(false), 294 owned_by_render_frame_host_(false),
294 is_focused_(false), 295 is_focused_(false),
295 hung_renderer_delay_( 296 hung_renderer_delay_(
296 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), 297 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
297 hang_monitor_event_type_(blink::WebInputEvent::kUndefined), 298 hang_monitor_event_type_(blink::WebInputEvent::kUndefined),
298 last_event_type_(blink::WebInputEvent::kUndefined), 299 last_event_type_(blink::WebInputEvent::kUndefined),
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 void RenderWidgetHostImpl::ImeFinishComposingText(bool keep_selection) { 1741 void RenderWidgetHostImpl::ImeFinishComposingText(bool keep_selection) {
1741 Send(new InputMsg_ImeFinishComposingText(GetRoutingID(), keep_selection)); 1742 Send(new InputMsg_ImeFinishComposingText(GetRoutingID(), keep_selection));
1742 } 1743 }
1743 1744
1744 void RenderWidgetHostImpl::ImeCancelComposition() { 1745 void RenderWidgetHostImpl::ImeCancelComposition() {
1745 Send(new InputMsg_ImeSetComposition(GetRoutingID(), base::string16(), 1746 Send(new InputMsg_ImeSetComposition(GetRoutingID(), base::string16(),
1746 std::vector<blink::WebCompositionUnderline>(), 1747 std::vector<blink::WebCompositionUnderline>(),
1747 gfx::Range::InvalidRange(), 0, 0)); 1748 gfx::Range::InvalidRange(), 0, 0));
1748 } 1749 }
1749 1750
1750 void RenderWidgetHostImpl::RejectMouseLockOrUnlockIfNecessary() { 1751 void RenderWidgetHostImpl::RejectMouseLockOrUnlockIfNecessary(
1752 bool is_unlocked_by_target) {
1751 DCHECK(!pending_mouse_lock_request_ || !IsMouseLocked()); 1753 DCHECK(!pending_mouse_lock_request_ || !IsMouseLocked());
1752 if (pending_mouse_lock_request_) { 1754 if (pending_mouse_lock_request_) {
1753 pending_mouse_lock_request_ = false; 1755 pending_mouse_lock_request_ = false;
1754 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); 1756 Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
1755 } else if (IsMouseLocked()) { 1757 } else if (IsMouseLocked()) {
1758 is_last_unlocked_by_target_ = is_unlocked_by_target;
1756 view_->UnlockMouse(); 1759 view_->UnlockMouse();
1757 } 1760 }
1758 } 1761 }
1759 1762
1760 bool RenderWidgetHostImpl::IsMouseLocked() const { 1763 bool RenderWidgetHostImpl::IsMouseLocked() const {
1761 return view_ ? view_->IsMouseLocked() : false; 1764 return view_ ? view_->IsMouseLocked() : false;
1762 } 1765 }
1763 1766
1764 void RenderWidgetHostImpl::SetAutoResize(bool enable, 1767 void RenderWidgetHostImpl::SetAutoResize(bool enable,
1765 const gfx::Size& min_size, 1768 const gfx::Size& min_size,
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 if (view_) 2064 if (view_)
2062 view_->ImeCompositionRangeChanged(range, character_bounds); 2065 view_->ImeCompositionRangeChanged(range, character_bounds);
2063 } 2066 }
2064 2067
2065 void RenderWidgetHostImpl::OnImeCancelComposition() { 2068 void RenderWidgetHostImpl::OnImeCancelComposition() {
2066 if (view_) 2069 if (view_)
2067 view_->ImeCancelComposition(); 2070 view_->ImeCancelComposition();
2068 } 2071 }
2069 2072
2070 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture, 2073 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture,
2071 bool last_unlocked_by_target,
2072 bool privileged) { 2074 bool privileged) {
2073 if (pending_mouse_lock_request_) { 2075 if (pending_mouse_lock_request_) {
2074 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); 2076 Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
2075 return; 2077 return;
2076 } 2078 }
2077 2079
2078 pending_mouse_lock_request_ = true; 2080 pending_mouse_lock_request_ = true;
2079 if (delegate_) { 2081 if (delegate_) {
2080 delegate_->RequestToLockMouse(this, user_gesture, last_unlocked_by_target, 2082 delegate_->RequestToLockMouse(this, user_gesture,
2083 is_last_unlocked_by_target_,
2081 privileged && allow_privileged_mouse_lock_); 2084 privileged && allow_privileged_mouse_lock_);
2085 is_last_unlocked_by_target_ = false;
2082 return; 2086 return;
2083 } 2087 }
2084 2088
2085 if (privileged && allow_privileged_mouse_lock_) { 2089 if (privileged && allow_privileged_mouse_lock_) {
2086 // Directly approve to lock the mouse. 2090 // Directly approve to lock the mouse.
2087 GotResponseToLockMouseRequest(true); 2091 GotResponseToLockMouseRequest(true);
2088 } else { 2092 } else {
2089 // Otherwise, just reject it. 2093 // Otherwise, just reject it.
2090 GotResponseToLockMouseRequest(false); 2094 GotResponseToLockMouseRequest(false);
2091 } 2095 }
2092 } 2096 }
2093 2097
2094 void RenderWidgetHostImpl::OnUnlockMouse() { 2098 void RenderWidgetHostImpl::OnUnlockMouse() {
2095 RejectMouseLockOrUnlockIfNecessary(); 2099 RejectMouseLockOrUnlockIfNecessary(true);
2096 } 2100 }
2097 2101
2098 void RenderWidgetHostImpl::OnShowDisambiguationPopup( 2102 void RenderWidgetHostImpl::OnShowDisambiguationPopup(
2099 const gfx::Rect& rect_pixels, 2103 const gfx::Rect& rect_pixels,
2100 const gfx::Size& size, 2104 const gfx::Size& size,
2101 const cc::SharedBitmapId& id) { 2105 const cc::SharedBitmapId& id) {
2102 DCHECK(!rect_pixels.IsEmpty()); 2106 DCHECK(!rect_pixels.IsEmpty());
2103 DCHECK(!size.IsEmpty()); 2107 DCHECK(!size.IsEmpty());
2104 2108
2105 std::unique_ptr<cc::SharedBitmap> bitmap = 2109 std::unique_ptr<cc::SharedBitmap> bitmap =
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 device::mojom::WakeLockType::PreventDisplaySleep, 2664 device::mojom::WakeLockType::PreventDisplaySleep,
2661 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", 2665 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot",
2662 std::move(request)); 2666 std::move(request));
2663 } 2667 }
2664 } 2668 }
2665 return wake_lock_.get(); 2669 return wake_lock_.get();
2666 } 2670 }
2667 #endif 2671 #endif
2668 2672
2669 } // namespace content 2673 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698