| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/text_input_manager.h" | 5 #include "content/browser/renderer_host/text_input_manager.h" |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 7 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 8 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 8 | 9 |
| 9 namespace content { | 10 namespace content { |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 bool AreDifferentTextInputStates(const content::TextInputState& old_state, | 14 bool AreDifferentTextInputStates(const content::TextInputState& old_state, |
| 14 const content::TextInputState& new_state) { | 15 const content::TextInputState& new_state) { |
| 15 #if defined(USE_AURA) | 16 #if defined(USE_AURA) |
| 16 return old_state.type != new_state.type || old_state.mode != new_state.mode || | 17 return old_state.type != new_state.type || old_state.mode != new_state.mode || |
| (...skipping 27 matching lines...) Expand all Loading... |
| 44 } | 45 } |
| 45 | 46 |
| 46 const TextInputState* TextInputManager::GetTextInputState() { | 47 const TextInputState* TextInputManager::GetTextInputState() { |
| 47 return !!active_view_ ? &text_input_state_map_[active_view_] : nullptr; | 48 return !!active_view_ ? &text_input_state_map_[active_view_] : nullptr; |
| 48 } | 49 } |
| 49 | 50 |
| 50 RenderWidgetHostViewBase* TextInputManager::GetActiveView() const { | 51 RenderWidgetHostViewBase* TextInputManager::GetActiveView() const { |
| 51 return active_view_; | 52 return active_view_; |
| 52 } | 53 } |
| 53 | 54 |
| 55 RenderWidgetHostImpl* TextInputManager::GetActiveWidget() const { |
| 56 return !!active_view_ ? static_cast<RenderWidgetHostImpl*>( |
| 57 active_view_->GetRenderWidgetHost()) |
| 58 : nullptr; |
| 59 } |
| 60 |
| 54 void TextInputManager::UpdateTextInputState( | 61 void TextInputManager::UpdateTextInputState( |
| 55 RenderWidgetHostViewBase* view, | 62 RenderWidgetHostViewBase* view, |
| 56 const TextInputState& text_input_state) { | 63 const TextInputState& text_input_state) { |
| 57 DCHECK(IsRegistered(view)); | 64 DCHECK(IsRegistered(view)); |
| 58 | 65 |
| 59 // Since |view| is registgered, we already have a previous value for its | 66 // Since |view| is registgered, we already have a previous value for its |
| 60 // TextInputState. | 67 // TextInputState. |
| 61 bool changed = AreDifferentTextInputStates(text_input_state_map_[view], | 68 bool changed = AreDifferentTextInputStates(text_input_state_map_[view], |
| 62 text_input_state); | 69 text_input_state); |
| 63 | 70 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 113 |
| 107 void TextInputManager::NotifyObserversAboutInputStateUpdate( | 114 void TextInputManager::NotifyObserversAboutInputStateUpdate( |
| 108 RenderWidgetHostViewBase* updated_view, | 115 RenderWidgetHostViewBase* updated_view, |
| 109 bool did_update_state) { | 116 bool did_update_state) { |
| 110 FOR_EACH_OBSERVER( | 117 FOR_EACH_OBSERVER( |
| 111 Observer, observer_list_, | 118 Observer, observer_list_, |
| 112 OnUpdateTextInputStateCalled(this, updated_view, did_update_state)); | 119 OnUpdateTextInputStateCalled(this, updated_view, did_update_state)); |
| 113 } | 120 } |
| 114 | 121 |
| 115 } // namespace content | 122 } // namespace content |
| OLD | NEW |