| 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/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 Loading... |
| 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 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2062 if (view_) | 2063 if (view_) |
| 2063 view_->ImeCompositionRangeChanged(range, character_bounds); | 2064 view_->ImeCompositionRangeChanged(range, character_bounds); |
| 2064 } | 2065 } |
| 2065 | 2066 |
| 2066 void RenderWidgetHostImpl::OnImeCancelComposition() { | 2067 void RenderWidgetHostImpl::OnImeCancelComposition() { |
| 2067 if (view_) | 2068 if (view_) |
| 2068 view_->ImeCancelComposition(); | 2069 view_->ImeCancelComposition(); |
| 2069 } | 2070 } |
| 2070 | 2071 |
| 2071 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture, | 2072 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture, |
| 2072 bool last_unlocked_by_target, | |
| 2073 bool privileged) { | 2073 bool privileged) { |
| 2074 if (pending_mouse_lock_request_) { | 2074 if (pending_mouse_lock_request_) { |
| 2075 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); | 2075 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); |
| 2076 return; | 2076 return; |
| 2077 } | 2077 } |
| 2078 | 2078 |
| 2079 pending_mouse_lock_request_ = true; | 2079 pending_mouse_lock_request_ = true; |
| 2080 if (delegate_) { | 2080 if (delegate_) { |
| 2081 delegate_->RequestToLockMouse(this, user_gesture, last_unlocked_by_target, | 2081 delegate_->RequestToLockMouse(this, user_gesture, |
| 2082 is_last_unlocked_by_target_, |
| 2082 privileged && allow_privileged_mouse_lock_); | 2083 privileged && allow_privileged_mouse_lock_); |
| 2084 // We need to reset |is_last_unlocked_by_target_| here as we don't know |
| 2085 // request source in |LostMouseLock()|. |
| 2086 is_last_unlocked_by_target_ = false; |
| 2083 return; | 2087 return; |
| 2084 } | 2088 } |
| 2085 | 2089 |
| 2086 if (privileged && allow_privileged_mouse_lock_) { | 2090 if (privileged && allow_privileged_mouse_lock_) { |
| 2087 // Directly approve to lock the mouse. | 2091 // Directly approve to lock the mouse. |
| 2088 GotResponseToLockMouseRequest(true); | 2092 GotResponseToLockMouseRequest(true); |
| 2089 } else { | 2093 } else { |
| 2090 // Otherwise, just reject it. | 2094 // Otherwise, just reject it. |
| 2091 GotResponseToLockMouseRequest(false); | 2095 GotResponseToLockMouseRequest(false); |
| 2092 } | 2096 } |
| 2093 } | 2097 } |
| 2094 | 2098 |
| 2095 void RenderWidgetHostImpl::OnUnlockMouse() { | 2099 void RenderWidgetHostImpl::OnUnlockMouse() { |
| 2100 // Got unlock request from renderer. Will update |is_last_unlocked_by_target_| |
| 2101 // for silent re-lock. |
| 2102 const bool was_mouse_locked = !pending_mouse_lock_request_ && IsMouseLocked(); |
| 2096 RejectMouseLockOrUnlockIfNecessary(); | 2103 RejectMouseLockOrUnlockIfNecessary(); |
| 2104 if (was_mouse_locked) |
| 2105 is_last_unlocked_by_target_ = true; |
| 2097 } | 2106 } |
| 2098 | 2107 |
| 2099 void RenderWidgetHostImpl::OnShowDisambiguationPopup( | 2108 void RenderWidgetHostImpl::OnShowDisambiguationPopup( |
| 2100 const gfx::Rect& rect_pixels, | 2109 const gfx::Rect& rect_pixels, |
| 2101 const gfx::Size& size, | 2110 const gfx::Size& size, |
| 2102 const cc::SharedBitmapId& id) { | 2111 const cc::SharedBitmapId& id) { |
| 2103 DCHECK(!rect_pixels.IsEmpty()); | 2112 DCHECK(!rect_pixels.IsEmpty()); |
| 2104 DCHECK(!size.IsEmpty()); | 2113 DCHECK(!size.IsEmpty()); |
| 2105 | 2114 |
| 2106 std::unique_ptr<cc::SharedBitmap> bitmap = | 2115 std::unique_ptr<cc::SharedBitmap> bitmap = |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2661 device::mojom::WakeLockType::PreventDisplaySleep, | 2670 device::mojom::WakeLockType::PreventDisplaySleep, |
| 2662 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", | 2671 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", |
| 2663 std::move(request)); | 2672 std::move(request)); |
| 2664 } | 2673 } |
| 2665 } | 2674 } |
| 2666 return wake_lock_.get(); | 2675 return wake_lock_.get(); |
| 2667 } | 2676 } |
| 2668 #endif | 2677 #endif |
| 2669 | 2678 |
| 2670 } // namespace content | 2679 } // namespace content |
| OLD | NEW |