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 23 matching lines...) Expand all Loading... |
40 views.push_back(pair.first); | 41 views.push_back(pair.first); |
41 | 42 |
42 for (auto view : views) | 43 for (auto view : views) |
43 Unregister(view); | 44 Unregister(view); |
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 RenderWidgetHostImpl* TextInputManager::GetActiveWidget() const { |
51 return active_view_; | 52 return !!active_view_ ? static_cast<RenderWidgetHostImpl*>( |
| 53 active_view_->GetRenderWidgetHost()) |
| 54 : nullptr; |
52 } | 55 } |
53 | 56 |
54 void TextInputManager::UpdateTextInputState( | 57 void TextInputManager::UpdateTextInputState( |
55 RenderWidgetHostViewBase* view, | 58 RenderWidgetHostViewBase* view, |
56 const TextInputState& text_input_state) { | 59 const TextInputState& text_input_state) { |
57 DCHECK(IsRegistered(view)); | 60 DCHECK(IsRegistered(view)); |
58 | 61 |
59 // Since |view| is registgered, we already have a previous value for its | 62 // Since |view| is registgered, we already have a previous value for its |
60 // TextInputState. | 63 // TextInputState. |
61 bool changed = AreDifferentTextInputStates(text_input_state_map_[view], | 64 bool changed = AreDifferentTextInputStates(text_input_state_map_[view], |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 109 |
107 void TextInputManager::NotifyObserversAboutInputStateUpdate( | 110 void TextInputManager::NotifyObserversAboutInputStateUpdate( |
108 RenderWidgetHostViewBase* updated_view, | 111 RenderWidgetHostViewBase* updated_view, |
109 bool did_update_state) { | 112 bool did_update_state) { |
110 FOR_EACH_OBSERVER( | 113 FOR_EACH_OBSERVER( |
111 Observer, observer_list_, | 114 Observer, observer_list_, |
112 OnUpdateTextInputStateCalled(this, updated_view, did_update_state)); | 115 OnUpdateTextInputStateCalled(this, updated_view, did_update_state)); |
113 } | 116 } |
114 | 117 |
115 } // namespace content | 118 } // namespace content |
OLD | NEW |