Chromium Code Reviews| 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_widget_host_delegate.h" | 13 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 14 #include "content/browser/renderer_host/render_widget_host_impl.h" | 14 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" | 15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" |
| 16 #include "content/browser/renderer_host/text_input_manager.h" | 16 #include "content/browser/renderer_host/text_input_manager.h" |
| 17 #include "content/common/content_switches_internal.h" | 17 #include "content/common/content_switches_internal.h" |
| 18 #include "content/common/view_messages.h" | |
| 18 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 19 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 20 #include "content/public/common/form_field_data.h" | |
| 19 #include "ui/display/display.h" | 21 #include "ui/display/display.h" |
| 20 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
| 21 #include "ui/gfx/geometry/point_conversions.h" | 23 #include "ui/gfx/geometry/point_conversions.h" |
| 22 #include "ui/gfx/geometry/size_conversions.h" | 24 #include "ui/gfx/geometry/size_conversions.h" |
| 23 #include "ui/gfx/geometry/size_f.h" | 25 #include "ui/gfx/geometry/size_f.h" |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 // How many microseconds apart input events should be flushed. | 31 // How many microseconds apart input events should be flushed. |
| 30 const int kFlushInputRateInUs = 16666; | 32 const int kFlushInputRateInUs = 16666; |
| 31 | 33 |
| 34 // For tracking requests for form field data. | |
| 35 int next_request_id_ = 0; | |
| 32 } | 36 } |
| 33 | 37 |
| 34 RenderWidgetHostViewBase::RenderWidgetHostViewBase() | 38 RenderWidgetHostViewBase::RenderWidgetHostViewBase() |
| 35 : is_fullscreen_(false), | 39 : is_fullscreen_(false), |
| 36 popup_type_(blink::WebPopupTypeNone), | 40 popup_type_(blink::WebPopupTypeNone), |
| 37 background_color_(SK_ColorWHITE), | 41 background_color_(SK_ColorWHITE), |
| 38 mouse_locked_(false), | 42 mouse_locked_(false), |
| 39 showing_context_menu_(false), | 43 showing_context_menu_(false), |
| 40 #if !defined(USE_AURA) | 44 #if !defined(USE_AURA) |
| 41 selection_text_offset_(0), | 45 selection_text_offset_(0), |
| 42 selection_range_(gfx::Range::InvalidRange()), | 46 selection_range_(gfx::Range::InvalidRange()), |
| 43 #endif | 47 #endif |
| 44 current_device_scale_factor_(0), | 48 current_device_scale_factor_(0), |
| 45 current_display_rotation_(display::Display::ROTATE_0), | 49 current_display_rotation_(display::Display::ROTATE_0), |
| 46 text_input_manager_(nullptr), | 50 text_input_manager_(nullptr), |
| 47 renderer_frame_number_(0), | 51 renderer_frame_number_(0), |
| 48 weak_factory_(this) { | 52 weak_factory_(this) { |
| 49 } | 53 } |
| 50 | 54 |
| 51 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { | 55 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { |
| 52 DCHECK(!mouse_locked_); | 56 DCHECK(!mouse_locked_); |
| 57 | |
| 58 // Run callbacks for the outstanding text input info requests, if any. | |
| 59 for (auto iter = extract_form_field_data_callbacks_.begin(); | |
| 60 iter != extract_form_field_data_callbacks_.end(); ++iter) { | |
| 61 ExtractFormFieldDataCallback callback = iter->second; | |
| 62 callback.Run(FormFieldData()); | |
|
Charlie Reis
2016/11/04 20:59:46
This is a bit surprising to me-- it seems like we
David Trainor- moved to gerrit
2016/11/04 21:14:07
Yeah I had suggested this to make sure we properly
shaktisahu
2016/11/11 01:15:03
I see some more examples of callbacks getting call
Charlie Reis
2016/11/11 22:20:46
Hmm, those aren't reasons it's safe. :) It depen
David Trainor- moved to gerrit
2016/11/12 00:17:35
Posting the task guarantees you run after the clas
shaktisahu
2016/11/15 05:44:54
Very good point. I thought a bit about how to make
Charlie Reis
2016/11/16 00:18:00
Hmm. If the callback is just going to return earl
shaktisahu
2016/11/16 20:26:58
Ok. I am removing this from the destructor and cle
| |
| 63 } | |
| 64 | |
| 53 // We call this here to guarantee that observers are notified before we go | 65 // We call this here to guarantee that observers are notified before we go |
| 54 // away. However, some subclasses may wish to call this earlier in their | 66 // away. However, some subclasses may wish to call this earlier in their |
| 55 // shutdown process, e.g. to force removal from | 67 // shutdown process, e.g. to force removal from |
| 56 // RenderWidgetHostInputEventRouter's surface map before relinquishing a | 68 // RenderWidgetHostInputEventRouter's surface map before relinquishing a |
| 57 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling | 69 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling |
| 58 // NotifyObserversAboutShutdown() twice, as the observers are required to | 70 // NotifyObserversAboutShutdown() twice, as the observers are required to |
| 59 // de-register on the first call, and so the second call does nothing. | 71 // de-register on the first call, and so the second call does nothing. |
| 60 NotifyObserversAboutShutdown(); | 72 NotifyObserversAboutShutdown(); |
| 61 // If we have a live reference to |text_input_manager_|, we should unregister | 73 // If we have a live reference to |text_input_manager_|, we should unregister |
| 62 // so that the |text_input_manager_| will free its state. | 74 // so that the |text_input_manager_| will free its state. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 | 162 |
| 151 gfx::Size RenderWidgetHostViewBase::GetRequestedRendererSize() const { | 163 gfx::Size RenderWidgetHostViewBase::GetRequestedRendererSize() const { |
| 152 return GetViewBounds().size(); | 164 return GetViewBounds().size(); |
| 153 } | 165 } |
| 154 | 166 |
| 155 ui::TextInputClient* RenderWidgetHostViewBase::GetTextInputClient() { | 167 ui::TextInputClient* RenderWidgetHostViewBase::GetTextInputClient() { |
| 156 NOTREACHED(); | 168 NOTREACHED(); |
| 157 return NULL; | 169 return NULL; |
| 158 } | 170 } |
| 159 | 171 |
| 172 void RenderWidgetHostViewBase::OnFocusedFormFieldDataReply( | |
| 173 int request_id, | |
| 174 const FormFieldData& field_data) { | |
| 175 DCHECK(extract_form_field_data_callbacks_.find(request_id) != | |
| 176 extract_form_field_data_callbacks_.end()); | |
| 177 extract_form_field_data_callbacks_[request_id].Run(field_data); | |
| 178 extract_form_field_data_callbacks_.erase(request_id); | |
| 179 } | |
| 180 | |
| 181 void RenderWidgetHostViewBase::GetFocusedFormFieldData( | |
| 182 ExtractFormFieldDataCallback& reply) { | |
| 183 if (!GetRenderWidgetHost()) { | |
| 184 reply.Run(FormFieldData()); | |
| 185 return; | |
| 186 } | |
| 187 | |
| 188 int request_id = ++next_request_id_; | |
| 189 extract_form_field_data_callbacks_[request_id] = reply; | |
| 190 GetRenderWidgetHost()->Send(new ViewMsg_GetFocusedFormFieldData( | |
| 191 GetRenderWidgetHost()->GetRoutingID(), request_id)); | |
| 192 } | |
| 193 | |
| 160 bool RenderWidgetHostViewBase::IsShowingContextMenu() const { | 194 bool RenderWidgetHostViewBase::IsShowingContextMenu() const { |
| 161 return showing_context_menu_; | 195 return showing_context_menu_; |
| 162 } | 196 } |
| 163 | 197 |
| 164 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { | 198 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { |
| 165 DCHECK_NE(showing_context_menu_, showing); | 199 DCHECK_NE(showing_context_menu_, showing); |
| 166 showing_context_menu_ = showing; | 200 showing_context_menu_ = showing; |
| 167 } | 201 } |
| 168 | 202 |
| 169 base::string16 RenderWidgetHostViewBase::GetSelectedText() { | 203 base::string16 RenderWidgetHostViewBase::GetSelectedText() { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 | 556 |
| 523 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { | 557 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { |
| 524 return false; | 558 return false; |
| 525 } | 559 } |
| 526 | 560 |
| 527 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { | 561 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { |
| 528 return cc::SurfaceId(); | 562 return cc::SurfaceId(); |
| 529 } | 563 } |
| 530 | 564 |
| 531 } // namespace content | 565 } // namespace content |
| OLD | NEW |