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_view_base.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "content/browser/accessibility/browser_accessibility_manager.h" | 9 #include "content/browser/accessibility/browser_accessibility_manager.h" |
10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 10 #include "content/browser/gpu/gpu_data_manager_impl.h" |
11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" | 11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" |
12 #include "content/browser/renderer_host/render_process_host_impl.h" | 12 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
13 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 15 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
14 #include "content/browser/renderer_host/render_widget_host_impl.h" | 16 #include "content/browser/renderer_host/render_widget_host_impl.h" |
15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" | 17 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" |
16 #include "content/common/content_switches_internal.h" | 18 #include "content/common/content_switches_internal.h" |
| 19 #include "content/common/input_messages.h" |
| 20 #include "content/common/site_isolation_policy.h" |
| 21 #include "content/common/text_input_state.h" |
| 22 #include "content/common/view_messages.h" |
17 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 23 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 24 #include "content/public/common/browser_plugin_guest_mode.h" |
18 #include "ui/gfx/display.h" | 25 #include "ui/gfx/display.h" |
19 #include "ui/gfx/geometry/point_conversions.h" | 26 #include "ui/gfx/geometry/point_conversions.h" |
20 #include "ui/gfx/geometry/size_conversions.h" | 27 #include "ui/gfx/geometry/size_conversions.h" |
21 #include "ui/gfx/geometry/size_f.h" | 28 #include "ui/gfx/geometry/size_f.h" |
22 #include "ui/gfx/screen.h" | 29 #include "ui/gfx/screen.h" |
23 | 30 |
24 namespace content { | 31 namespace content { |
25 | 32 |
26 namespace { | 33 namespace { |
27 | 34 |
28 // How many microseconds apart input events should be flushed. | 35 // How many microseconds apart input events should be flushed. |
29 const int kFlushInputRateInUs = 16666; | 36 const int kFlushInputRateInUs = 16666; |
30 | 37 |
31 } | 38 } |
32 | 39 |
33 RenderWidgetHostViewBase::RenderWidgetHostViewBase() | 40 RenderWidgetHostViewBase::RenderWidgetHostViewBase() |
34 : popup_type_(blink::WebPopupTypeNone), | 41 : popup_type_(blink::WebPopupTypeNone), |
35 background_color_(SK_ColorWHITE), | 42 background_color_(SK_ColorWHITE), |
36 mouse_locked_(false), | 43 mouse_locked_(false), |
37 showing_context_menu_(false), | 44 showing_context_menu_(false), |
38 selection_text_offset_(0), | 45 selection_text_offset_(0), |
39 selection_range_(gfx::Range::InvalidRange()), | 46 selection_range_(gfx::Range::InvalidRange()), |
40 current_device_scale_factor_(0), | 47 current_device_scale_factor_(0), |
41 current_display_rotation_(gfx::Display::ROTATE_0), | 48 current_display_rotation_(gfx::Display::ROTATE_0), |
42 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), | 49 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), |
43 renderer_frame_number_(0), | 50 renderer_frame_number_(0), |
| 51 text_input_state_(new TextInputState()), |
44 weak_factory_(this) {} | 52 weak_factory_(this) {} |
45 | 53 |
46 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { | 54 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { |
47 DCHECK(!mouse_locked_); | 55 DCHECK(!mouse_locked_); |
48 // We call this here to guarantee that observers are notified before we go | 56 // We call this here to guarantee that observers are notified before we go |
49 // away. However, some subclasses may wish to call this earlier in their | 57 // away. However, some subclasses may wish to call this earlier in their |
50 // shutdown process, e.g. to force removal from | 58 // shutdown process, e.g. to force removal from |
51 // RenderWidgetHostInputEventRouter's surface map before relinquishing a | 59 // RenderWidgetHostInputEventRouter's surface map before relinquishing a |
52 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling | 60 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling |
53 // NotifyObserversAboutShutdown() twice, as the observers are required to | 61 // NotifyObserversAboutShutdown() twice, as the observers are required to |
54 // de-register on the first call, and so the second call does nothing. | 62 // de-register on the first call, and so the second call does nothing. |
55 NotifyObserversAboutShutdown(); | 63 NotifyObserversAboutShutdown(); |
56 } | 64 } |
57 | 65 |
58 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() { | 66 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() { |
59 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the | 67 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the |
60 // following notification to remove this view from its surface owners map. | 68 // following notification to remove this view from its surface owners map. |
61 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver, | 69 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver, |
62 observers_, | 70 observers_, |
63 OnRenderWidgetHostViewBaseDestroyed(this)); | 71 OnRenderWidgetHostViewBaseDestroyed(this)); |
64 // All observers are required to disconnect after they are notified. | 72 // All observers are required to disconnect after they are notified. |
65 DCHECK(!observers_.might_have_observers()); | 73 DCHECK(!observers_.might_have_observers()); |
66 } | 74 } |
67 | 75 |
| 76 void RenderWidgetHostViewBase::NotifyHostDelegateAboutShutdown() { |
| 77 RenderWidgetHostImpl* host = |
| 78 RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
| 79 |
| 80 if (!host || !host->delegate()) |
| 81 return; |
| 82 |
| 83 bool has_active_text = text_input_state()->type != ui::TEXT_INPUT_TYPE_NONE; |
| 84 text_input_state_.reset(new TextInputState()); |
| 85 |
| 86 host->delegate()->UpdateTextInputState(this, has_active_text); |
| 87 } |
| 88 |
68 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){ | 89 bool RenderWidgetHostViewBase::OnMessageReceived(const IPC::Message& msg){ |
69 return false; | 90 return false; |
70 } | 91 } |
71 | 92 |
72 void RenderWidgetHostViewBase::SetBackgroundColor(SkColor color) { | 93 void RenderWidgetHostViewBase::SetBackgroundColor(SkColor color) { |
73 background_color_ = color; | 94 background_color_ = color; |
74 } | 95 } |
75 | 96 |
76 void RenderWidgetHostViewBase::SetBackgroundColorToDefault() { | 97 void RenderWidgetHostViewBase::SetBackgroundColorToDefault() { |
77 SetBackgroundColor(SK_ColorWHITE); | 98 SetBackgroundColor(SK_ColorWHITE); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 current_display_rotation_ == display.rotation()) { | 242 current_display_rotation_ == display.rotation()) { |
222 return false; | 243 return false; |
223 } | 244 } |
224 | 245 |
225 current_display_area_ = display.work_area(); | 246 current_display_area_ = display.work_area(); |
226 current_device_scale_factor_ = display.device_scale_factor(); | 247 current_device_scale_factor_ = display.device_scale_factor(); |
227 current_display_rotation_ = display.rotation(); | 248 current_display_rotation_ = display.rotation(); |
228 return true; | 249 return true; |
229 } | 250 } |
230 | 251 |
| 252 void RenderWidgetHostViewBase::TextInputStateChanged( |
| 253 const TextInputState& params) { |
| 254 bool text_input_state_changed = true; |
| 255 #if !defined(OS_ANDROID) |
| 256 if (params.type == text_input_state_->type && |
| 257 params.can_compose_inline == text_input_state_->can_compose_inline |
| 258 #if !defined(OS_MACOSX) |
| 259 && params.mode == text_input_state_->mode && |
| 260 params.flags == text_input_state_->flags |
| 261 #endif |
| 262 ) |
| 263 text_input_state_changed = false; |
| 264 #else |
| 265 if (params.is_non_ime_change) { |
| 266 // Sends an acknowledgement to the renderer of a processed IME event. |
| 267 GetRenderWidgetHost()->Send( |
| 268 new InputMsg_ImeEventAck(GetRenderWidgetHost()->GetRoutingID())); |
| 269 } |
| 270 #endif |
| 271 |
| 272 if (text_input_state_changed) { |
| 273 *text_input_state_ = params; |
| 274 RenderWidgetHostImpl* host = |
| 275 RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
| 276 if (host && host->delegate()) |
| 277 host->delegate()->UpdateTextInputState(this, text_input_state_changed); |
| 278 } |
| 279 } |
| 280 |
231 base::WeakPtr<RenderWidgetHostViewBase> RenderWidgetHostViewBase::GetWeakPtr() { | 281 base::WeakPtr<RenderWidgetHostViewBase> RenderWidgetHostViewBase::GetWeakPtr() { |
232 return weak_factory_.GetWeakPtr(); | 282 return weak_factory_.GetWeakPtr(); |
233 } | 283 } |
234 | 284 |
235 scoped_ptr<SyntheticGestureTarget> | 285 scoped_ptr<SyntheticGestureTarget> |
236 RenderWidgetHostViewBase::CreateSyntheticGestureTarget() { | 286 RenderWidgetHostViewBase::CreateSyntheticGestureTarget() { |
237 RenderWidgetHostImpl* host = | 287 RenderWidgetHostImpl* host = |
238 RenderWidgetHostImpl::From(GetRenderWidgetHost()); | 288 RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
239 return scoped_ptr<SyntheticGestureTarget>( | 289 return scoped_ptr<SyntheticGestureTarget>( |
240 new SyntheticGestureTargetBase(host)); | 290 new SyntheticGestureTargetBase(host)); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 444 |
395 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { | 445 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { |
396 return false; | 446 return false; |
397 } | 447 } |
398 | 448 |
399 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { | 449 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { |
400 return cc::SurfaceId(); | 450 return cc::SurfaceId(); |
401 } | 451 } |
402 | 452 |
403 } // namespace content | 453 } // namespace content |
OLD | NEW |