| 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" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling | 57 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling |
| 58 // NotifyObserversAboutShutdown() twice, as the observers are required to | 58 // NotifyObserversAboutShutdown() twice, as the observers are required to |
| 59 // de-register on the first call, and so the second call does nothing. | 59 // de-register on the first call, and so the second call does nothing. |
| 60 NotifyObserversAboutShutdown(); | 60 NotifyObserversAboutShutdown(); |
| 61 // If we have a live reference to |text_input_manager_|, we should unregister | 61 // If we have a live reference to |text_input_manager_|, we should unregister |
| 62 // so that the |text_input_manager_| will free its state. | 62 // so that the |text_input_manager_| will free its state. |
| 63 if (text_input_manager_) | 63 if (text_input_manager_) |
| 64 text_input_manager_->Unregister(this); | 64 text_input_manager_->Unregister(this); |
| 65 } | 65 } |
| 66 | 66 |
| 67 RenderWidgetHostImpl* RenderWidgetHostViewBase::GetFocusedWidget() const { |
| 68 RenderWidgetHostImpl* host = |
| 69 RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
| 70 |
| 71 return host && host->delegate() |
| 72 ? host->delegate()->GetFocusedRenderWidgetHost(host) |
| 73 : nullptr; |
| 74 } |
| 75 |
| 76 RenderWidgetHost* RenderWidgetHostViewBase::GetRenderWidgetHost() const { |
| 77 return nullptr; |
| 78 } |
| 79 |
| 67 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() { | 80 void RenderWidgetHostViewBase::NotifyObserversAboutShutdown() { |
| 68 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the | 81 // Note: RenderWidgetHostInputEventRouter is an observer, and uses the |
| 69 // following notification to remove this view from its surface owners map. | 82 // following notification to remove this view from its surface owners map. |
| 70 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver, | 83 FOR_EACH_OBSERVER(RenderWidgetHostViewBaseObserver, |
| 71 observers_, | 84 observers_, |
| 72 OnRenderWidgetHostViewBaseDestroyed(this)); | 85 OnRenderWidgetHostViewBaseDestroyed(this)); |
| 73 // All observers are required to disconnect after they are notified. | 86 // All observers are required to disconnect after they are notified. |
| 74 DCHECK(!observers_.might_have_observers()); | 87 DCHECK(!observers_.might_have_observers()); |
| 75 } | 88 } |
| 76 | 89 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (GetTextInputManager()) | 123 if (GetTextInputManager()) |
| 111 GetTextInputManager()->SelectionBoundsChanged(this, params); | 124 GetTextInputManager()->SelectionBoundsChanged(this, params); |
| 112 } | 125 } |
| 113 | 126 |
| 114 void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text, | 127 void RenderWidgetHostViewBase::SelectionChanged(const base::string16& text, |
| 115 size_t offset, | 128 size_t offset, |
| 116 const gfx::Range& range) { | 129 const gfx::Range& range) { |
| 117 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms. | 130 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms. |
| 118 // Also, remove the following local variables when that happens | 131 // Also, remove the following local variables when that happens |
| 119 // (https://crbug.com/578168 and https://crbug.com/602427). | 132 // (https://crbug.com/578168 and https://crbug.com/602427). |
| 120 #if defined(USE_AURA) | 133 #if !defined(OS_ANDROID) |
| 121 if (GetTextInputManager()) | 134 if (GetTextInputManager()) |
| 122 GetTextInputManager()->SelectionChanged(this, text, offset, range); | 135 GetTextInputManager()->SelectionChanged(this, text, offset, range); |
| 123 #else | 136 #else |
| 124 selection_text_ = text; | 137 selection_text_ = text; |
| 125 selection_text_offset_ = offset; | 138 selection_text_offset_ = offset; |
| 126 selection_range_.set_start(range.start()); | 139 selection_range_.set_start(range.start()); |
| 127 selection_range_.set_end(range.end()); | 140 selection_range_.set_end(range.end()); |
| 128 #endif | 141 #endif |
| 129 } | 142 } |
| 130 | 143 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 143 | 156 |
| 144 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { | 157 void RenderWidgetHostViewBase::SetShowingContextMenu(bool showing) { |
| 145 DCHECK_NE(showing_context_menu_, showing); | 158 DCHECK_NE(showing_context_menu_, showing); |
| 146 showing_context_menu_ = showing; | 159 showing_context_menu_ = showing; |
| 147 } | 160 } |
| 148 | 161 |
| 149 base::string16 RenderWidgetHostViewBase::GetSelectedText() { | 162 base::string16 RenderWidgetHostViewBase::GetSelectedText() { |
| 150 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms. | 163 // TODO(ekaramad): Use TextInputManager code paths for IME on other platforms. |
| 151 // Also, remove the following local variables when that happens | 164 // Also, remove the following local variables when that happens |
| 152 // (https://crbug.com/578168 and https://crbug.com/602427). | 165 // (https://crbug.com/578168 and https://crbug.com/602427). |
| 153 #if defined(USE_AURA) | 166 #if !defined(OS_ANDROID) |
| 154 if (!GetTextInputManager()) | 167 if (!GetTextInputManager()) |
| 155 return base::string16(); | 168 return base::string16(); |
| 156 | 169 |
| 157 const TextInputManager::TextSelection* selection = | 170 const TextInputManager::TextSelection* selection = |
| 158 GetTextInputManager()->GetTextSelection(this); | 171 GetTextInputManager()->GetTextSelection(this); |
| 159 | 172 |
| 160 if (!selection || !selection->range.IsValid()) | 173 if (!selection || !selection->range.IsValid()) |
| 161 return base::string16(); | 174 return base::string16(); |
| 162 | 175 |
| 163 return selection->text.substr(selection->range.GetMin() - selection->offset, | 176 return selection->text.substr(selection->range.GetMin() - selection->offset, |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 506 |
| 494 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { | 507 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { |
| 495 return false; | 508 return false; |
| 496 } | 509 } |
| 497 | 510 |
| 498 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { | 511 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { |
| 499 return cc::SurfaceId(); | 512 return cc::SurfaceId(); |
| 500 } | 513 } |
| 501 | 514 |
| 502 } // namespace content | 515 } // namespace content |
| OLD | NEW |