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