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 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ |
6 #define CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ | 6 #define CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ |
7 | 7 |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 | 9 |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/common/text_input_state.h" | 12 #include "content/common/text_input_state.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 class RenderWidgetHostImpl; | |
16 class RenderWidgetHostView; | 17 class RenderWidgetHostView; |
17 class RenderWidgetHostViewBase; | 18 class RenderWidgetHostViewBase; |
18 class WebContents; | 19 class WebContents; |
19 | 20 |
20 // A class which receives updates of TextInputState from multiple sources and | 21 // A class which receives updates of TextInputState from multiple sources and |
21 // decides what the new TextInputState is. It also notifies the observers when | 22 // decides what the new TextInputState is. It also notifies the observers when |
22 // text input state is updated. | 23 // text input state is updated. |
23 class CONTENT_EXPORT TextInputManager { | 24 class CONTENT_EXPORT TextInputManager { |
24 public: | 25 public: |
25 // The tab's top-level RWHV should be an observer of TextInputManager to get | 26 // The tab's top-level RWHV should be an observer of TextInputManager to get |
26 // notifications about changes in TextInputState or other IME related state | 27 // notifications about changes in TextInputState or other IME related state |
27 // for child frames. | 28 // for child frames. |
28 class CONTENT_EXPORT Observer { | 29 class CONTENT_EXPORT Observer { |
29 public: | 30 public: |
30 // Called when a view has called UpdateTextInputState on TextInputManager. | 31 // Called when a view has called UpdateTextInputState on TextInputManager. |
31 // If the call has led to a change in TextInputState, |did_update_state| is | 32 // If the call has led to a change in TextInputState, |did_update_state| is |
32 // true. In some plaforms, we need this update even when the state has not | 33 // true. In some plaforms, we need this update even when the state has not |
33 // changed (e.g., Aura for updating IME). | 34 // changed (e.g., Aura for updating IME). |
34 virtual void OnUpdateTextInputStateCalled( | 35 virtual void OnUpdateTextInputStateCalled( |
35 TextInputManager* text_input_manager, | 36 TextInputManager* text_input_manager, |
36 RenderWidgetHostViewBase* updated_view, | 37 RenderWidgetHostViewBase* updated_view, |
37 bool did_update_state) {} | 38 bool did_update_state) {} |
38 }; | 39 }; |
39 | 40 |
40 TextInputManager(); | 41 TextInputManager(); |
41 ~TextInputManager(); | 42 ~TextInputManager(); |
42 | 43 |
44 // --------------------------------------------------------------------------- | |
45 // The following methods give are used to obtain information about IME-related | |
kenrb
2016/06/13 19:37:47
Nit: 'methods give are used'
EhsanK
2016/06/17 22:36:20
Acknowledged.
| |
46 // state for the active RWHV. | |
47 | |
43 // Returns the currently active view (i.e., the RWHV with a focused <input> | 48 // Returns the currently active view (i.e., the RWHV with a focused <input> |
44 // element), or nullptr if none exist. The |active_view_| cannot have a | 49 // element), or nullptr if none exist. The |active_view_| cannot have a |
45 // |TextInputState.type| of ui::TEXT_INPUT_TYPE_NONE. | 50 // |TextInputState.type| of ui::TEXT_INPUT_TYPE_NONE. |
46 RenderWidgetHostViewBase* GetActiveView() const; | 51 RenderWidgetHostViewBase* GetActiveView() const; |
kenrb
2016/06/13 19:37:47
Is GetActiveView() still necessary? Looking at thi
EhsanK
2016/06/17 22:36:20
It is not. I removed it. We store state for each v
| |
47 | 52 |
53 // Returns the currently active widget, i.e., the RWH which is associated with | |
54 // |active_view_|. | |
55 RenderWidgetHostImpl* GetActiveWidget() const; | |
56 | |
48 // Returns the TextInputState corresponding to |active_view_|. | 57 // Returns the TextInputState corresponding to |active_view_|. |
49 // Users of this method should not hold on to the pointer as it might become | 58 // Users of this method should not hold on to the pointer as it might become |
50 // dangling if the TextInputManager or |active_view_| might go away. | 59 // dangling if the TextInputManager or |active_view_| might go away. |
51 const TextInputState* GetTextInputState(); | 60 const TextInputState* GetTextInputState(); |
52 | 61 |
62 // --------------------------------------------------------------------------- | |
63 // The following methods are called by RWHVs on the tab to update their IME- | |
64 // related state. | |
65 | |
53 // Updates the TextInputState for |view|. | 66 // Updates the TextInputState for |view|. |
54 void UpdateTextInputState(RenderWidgetHostViewBase* view, | 67 void UpdateTextInputState(RenderWidgetHostViewBase* view, |
55 const TextInputState& state); | 68 const TextInputState& state); |
56 | 69 |
57 // Registers the given |view| for tracking its TextInputState. This is called | 70 // Registers the given |view| for tracking its TextInputState. This is called |
58 // by any view which has updates in its TextInputState (whether tab's RWHV or | 71 // by any view which has updates in its TextInputState (whether tab's RWHV or |
59 // that of a child frame). The |view| must unregister itself before being | 72 // that of a child frame). The |view| must unregister itself before being |
60 // destroyed (i.e., call TextInputManager::Unregister). | 73 // destroyed (i.e., call TextInputManager::Unregister). |
61 void Register(RenderWidgetHostViewBase* view); | 74 void Register(RenderWidgetHostViewBase* view); |
62 | 75 |
(...skipping 28 matching lines...) Expand all Loading... | |
91 std::unordered_map<RenderWidgetHostViewBase*, TextInputState> | 104 std::unordered_map<RenderWidgetHostViewBase*, TextInputState> |
92 text_input_state_map_; | 105 text_input_state_map_; |
93 | 106 |
94 base::ObserverList<Observer> observer_list_; | 107 base::ObserverList<Observer> observer_list_; |
95 | 108 |
96 DISALLOW_COPY_AND_ASSIGN(TextInputManager); | 109 DISALLOW_COPY_AND_ASSIGN(TextInputManager); |
97 }; | 110 }; |
98 } | 111 } |
99 | 112 |
100 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ | 113 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_MANAGER_H__ |
OLD | NEW |