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 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // { "mozc-hangul", "xkb:kr:kr104:kor" } is returned for | 63 // { "mozc-hangul", "xkb:kr:kr104:kor" } is returned for |
64 // ui::VKEY_DBE_SBCSCHAR if the two input methods are active. | 64 // ui::VKEY_DBE_SBCSCHAR if the two input methods are active. |
65 void GetCandidateInputMethodsForAccelerator( | 65 void GetCandidateInputMethodsForAccelerator( |
66 const ui::Accelerator& accelerator, | 66 const ui::Accelerator& accelerator, |
67 std::vector<std::string>* out_candidate_ids); | 67 std::vector<std::string>* out_candidate_ids); |
68 | 68 |
69 // Returns true if given input method requires pending extension. | 69 // Returns true if given input method requires pending extension. |
70 bool MethodAwaitsExtensionLoad(const std::string& input_method_id) const; | 70 bool MethodAwaitsExtensionLoad(const std::string& input_method_id) const; |
71 | 71 |
72 // InputMethodManager::State overrides. | 72 // InputMethodManager::State overrides. |
73 virtual scoped_refptr<InputMethodManager::State> Clone() const override; | 73 scoped_refptr<InputMethodManager::State> Clone() const override; |
74 virtual void AddInputMethodExtension( | 74 void AddInputMethodExtension(const std::string& extension_id, |
75 const std::string& extension_id, | 75 const InputMethodDescriptors& descriptors, |
76 const InputMethodDescriptors& descriptors, | 76 InputMethodEngineInterface* instance) override; |
77 InputMethodEngineInterface* instance) override; | 77 void RemoveInputMethodExtension(const std::string& extension_id) override; |
78 virtual void RemoveInputMethodExtension( | 78 void ChangeInputMethod(const std::string& input_method_id, |
79 const std::string& extension_id) override; | 79 bool show_message) override; |
80 virtual void ChangeInputMethod(const std::string& input_method_id, | 80 bool EnableInputMethod( |
81 bool show_message) override; | |
82 virtual bool EnableInputMethod( | |
83 const std::string& new_active_input_method_id) override; | 81 const std::string& new_active_input_method_id) override; |
84 virtual void EnableLoginLayouts( | 82 void EnableLoginLayouts( |
85 const std::string& language_code, | 83 const std::string& language_code, |
86 const std::vector<std::string>& initial_layouts) override; | 84 const std::vector<std::string>& initial_layouts) override; |
87 virtual void EnableLockScreenLayouts() override; | 85 void EnableLockScreenLayouts() override; |
88 virtual void GetInputMethodExtensions( | 86 void GetInputMethodExtensions(InputMethodDescriptors* result) override; |
89 InputMethodDescriptors* result) override; | 87 scoped_ptr<InputMethodDescriptors> GetActiveInputMethods() const override; |
90 virtual scoped_ptr<InputMethodDescriptors> GetActiveInputMethods() | 88 const std::vector<std::string>& GetActiveInputMethodIds() const override; |
91 const override; | 89 const InputMethodDescriptor* GetInputMethodFromId( |
92 virtual const std::vector<std::string>& GetActiveInputMethodIds() | |
93 const override; | |
94 virtual const InputMethodDescriptor* GetInputMethodFromId( | |
95 const std::string& input_method_id) const override; | 90 const std::string& input_method_id) const override; |
96 virtual size_t GetNumActiveInputMethods() const override; | 91 size_t GetNumActiveInputMethods() const override; |
97 virtual void SetEnabledExtensionImes( | 92 void SetEnabledExtensionImes(std::vector<std::string>* ids) override; |
98 std::vector<std::string>* ids) override; | 93 void SetInputMethodLoginDefault() override; |
99 virtual void SetInputMethodLoginDefault() override; | 94 void SetInputMethodLoginDefaultFromVPD(const std::string& locale, |
100 virtual void SetInputMethodLoginDefaultFromVPD( | 95 const std::string& layout) override; |
101 const std::string& locale, | 96 bool CanCycleInputMethod() override; |
102 const std::string& layout) override; | 97 void SwitchToNextInputMethod() override; |
103 virtual bool CanCycleInputMethod() override; | 98 void SwitchToPreviousInputMethod() override; |
104 virtual void SwitchToNextInputMethod() override; | 99 bool CanSwitchInputMethod(const ui::Accelerator& accelerator) override; |
105 virtual void SwitchToPreviousInputMethod() override; | 100 void SwitchInputMethod(const ui::Accelerator& accelerator) override; |
106 virtual bool CanSwitchInputMethod( | 101 InputMethodDescriptor GetCurrentInputMethod() const override; |
107 const ui::Accelerator& accelerator) override; | 102 bool ReplaceEnabledInputMethods( |
108 virtual void SwitchInputMethod(const ui::Accelerator& accelerator) override; | |
109 virtual InputMethodDescriptor GetCurrentInputMethod() const override; | |
110 virtual bool ReplaceEnabledInputMethods( | |
111 const std::vector<std::string>& new_active_input_method_ids) override; | 103 const std::vector<std::string>& new_active_input_method_ids) override; |
112 | 104 |
113 // ------------------------- Data members. | 105 // ------------------------- Data members. |
114 Profile* const profile; | 106 Profile* const profile; |
115 | 107 |
116 // The input method which was/is selected. | 108 // The input method which was/is selected. |
117 InputMethodDescriptor previous_input_method; | 109 InputMethodDescriptor previous_input_method; |
118 InputMethodDescriptor current_input_method; | 110 InputMethodDescriptor current_input_method; |
119 | 111 |
120 // The active input method ids cache. | 112 // The active input method ids cache. |
121 std::vector<std::string> active_input_method_ids; | 113 std::vector<std::string> active_input_method_ids; |
122 | 114 |
123 // The pending input method id for delayed 3rd party IME enabling. | 115 // The pending input method id for delayed 3rd party IME enabling. |
124 std::string pending_input_method_id; | 116 std::string pending_input_method_id; |
125 | 117 |
126 // The list of enabled extension IMEs. | 118 // The list of enabled extension IMEs. |
127 std::vector<std::string> enabled_extension_imes; | 119 std::vector<std::string> enabled_extension_imes; |
128 | 120 |
129 // Extra input methods that have been explicitly added to the menu, such as | 121 // Extra input methods that have been explicitly added to the menu, such as |
130 // those created by extension. | 122 // those created by extension. |
131 std::map<std::string, InputMethodDescriptor> extra_input_methods; | 123 std::map<std::string, InputMethodDescriptor> extra_input_methods; |
132 | 124 |
133 InputMethodManagerImpl* const manager_; | 125 InputMethodManagerImpl* const manager_; |
134 | 126 |
135 protected: | 127 protected: |
136 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>; | 128 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>; |
137 virtual ~StateImpl(); | 129 ~StateImpl() override; |
138 }; | 130 }; |
139 | 131 |
140 // Constructs an InputMethodManager instance. The client is responsible for | 132 // Constructs an InputMethodManager instance. The client is responsible for |
141 // calling |SetUISessionState| in response to relevant changes in browser | 133 // calling |SetUISessionState| in response to relevant changes in browser |
142 // state. | 134 // state. |
143 InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate, | 135 InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate, |
144 bool enable_extension_loading); | 136 bool enable_extension_loading); |
145 virtual ~InputMethodManagerImpl(); | 137 ~InputMethodManagerImpl() override; |
146 | 138 |
147 // Receives notification of an InputMethodManager::UISessionState transition. | 139 // Receives notification of an InputMethodManager::UISessionState transition. |
148 void SetUISessionState(UISessionState new_ui_session); | 140 void SetUISessionState(UISessionState new_ui_session); |
149 | 141 |
150 // InputMethodManager override: | 142 // InputMethodManager override: |
151 virtual UISessionState GetUISessionState() override; | 143 UISessionState GetUISessionState() override; |
152 virtual void AddObserver(InputMethodManager::Observer* observer) override; | 144 void AddObserver(InputMethodManager::Observer* observer) override; |
153 virtual void AddCandidateWindowObserver( | 145 void AddCandidateWindowObserver( |
154 InputMethodManager::CandidateWindowObserver* observer) override; | 146 InputMethodManager::CandidateWindowObserver* observer) override; |
155 virtual void RemoveObserver(InputMethodManager::Observer* observer) override; | 147 void RemoveObserver(InputMethodManager::Observer* observer) override; |
156 virtual void RemoveCandidateWindowObserver( | 148 void RemoveCandidateWindowObserver( |
157 InputMethodManager::CandidateWindowObserver* observer) override; | 149 InputMethodManager::CandidateWindowObserver* observer) override; |
158 virtual scoped_ptr<InputMethodDescriptors> | 150 scoped_ptr<InputMethodDescriptors> GetSupportedInputMethods() const override; |
159 GetSupportedInputMethods() const override; | 151 void ActivateInputMethodMenuItem(const std::string& key) override; |
160 virtual void ActivateInputMethodMenuItem(const std::string& key) override; | 152 bool IsISOLevel5ShiftUsedByCurrentInputMethod() const override; |
161 virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const override; | 153 bool IsAltGrUsedByCurrentInputMethod() const override; |
162 virtual bool IsAltGrUsedByCurrentInputMethod() const override; | |
163 | 154 |
164 virtual ImeKeyboard* GetImeKeyboard() override; | 155 ImeKeyboard* GetImeKeyboard() override; |
165 virtual InputMethodUtil* GetInputMethodUtil() override; | 156 InputMethodUtil* GetInputMethodUtil() override; |
166 virtual ComponentExtensionIMEManager* | 157 ComponentExtensionIMEManager* GetComponentExtensionIMEManager() override; |
167 GetComponentExtensionIMEManager() override; | 158 bool IsLoginKeyboard(const std::string& layout) const override; |
168 virtual bool IsLoginKeyboard(const std::string& layout) const override; | |
169 | 159 |
170 virtual bool MigrateInputMethods( | 160 bool MigrateInputMethods(std::vector<std::string>* input_method_ids) override; |
171 std::vector<std::string>* input_method_ids) override; | |
172 | 161 |
173 virtual scoped_refptr<InputMethodManager::State> CreateNewState( | 162 scoped_refptr<InputMethodManager::State> CreateNewState( |
174 Profile* profile) override; | 163 Profile* profile) override; |
175 | 164 |
176 virtual scoped_refptr<InputMethodManager::State> GetActiveIMEState() override; | 165 scoped_refptr<InputMethodManager::State> GetActiveIMEState() override; |
177 virtual void SetState( | 166 void SetState(scoped_refptr<InputMethodManager::State> state) override; |
178 scoped_refptr<InputMethodManager::State> state) override; | |
179 | 167 |
180 // Sets |candidate_window_controller_|. | 168 // Sets |candidate_window_controller_|. |
181 void SetCandidateWindowControllerForTesting( | 169 void SetCandidateWindowControllerForTesting( |
182 CandidateWindowController* candidate_window_controller); | 170 CandidateWindowController* candidate_window_controller); |
183 // Sets |keyboard_|. | 171 // Sets |keyboard_|. |
184 void SetImeKeyboardForTesting(ImeKeyboard* keyboard); | 172 void SetImeKeyboardForTesting(ImeKeyboard* keyboard); |
185 // Initialize |component_extension_manager_|. | 173 // Initialize |component_extension_manager_|. |
186 void InitializeComponentExtensionForTesting( | 174 void InitializeComponentExtensionForTesting( |
187 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); | 175 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); |
188 | 176 |
189 private: | 177 private: |
190 friend class InputMethodManagerImplTest; | 178 friend class InputMethodManagerImplTest; |
191 | 179 |
192 // CandidateWindowController::Observer overrides: | 180 // CandidateWindowController::Observer overrides: |
193 virtual void CandidateClicked(int index) override; | 181 void CandidateClicked(int index) override; |
194 virtual void CandidateWindowOpened() override; | 182 void CandidateWindowOpened() override; |
195 virtual void CandidateWindowClosed() override; | 183 void CandidateWindowClosed() override; |
196 | 184 |
197 // Temporarily deactivates all input methods (e.g. Chinese, Japanese, Arabic) | 185 // Temporarily deactivates all input methods (e.g. Chinese, Japanese, Arabic) |
198 // since they are not necessary to input a login password. Users are still | 186 // since they are not necessary to input a login password. Users are still |
199 // able to use/switch active keyboard layouts (e.g. US qwerty, US dvorak, | 187 // able to use/switch active keyboard layouts (e.g. US qwerty, US dvorak, |
200 // French). | 188 // French). |
201 void OnScreenLocked(); | 189 void OnScreenLocked(); |
202 | 190 |
203 // Resumes the original state by activating input methods and/or changing the | 191 // Resumes the original state by activating input methods and/or changing the |
204 // current input method as needed. | 192 // current input method as needed. |
205 void OnScreenUnlocked(); | 193 void OnScreenUnlocked(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // Chinese Pinyin IME. Note "zh-hant-t-i0-pinyin" < "zh-t-i0-pinyin". | 266 // Chinese Pinyin IME. Note "zh-hant-t-i0-pinyin" < "zh-t-i0-pinyin". |
279 std::map<std::string, int> stat_id_map_; | 267 std::map<std::string, int> stat_id_map_; |
280 | 268 |
281 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); | 269 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); |
282 }; | 270 }; |
283 | 271 |
284 } // namespace input_method | 272 } // namespace input_method |
285 } // namespace chromeos | 273 } // namespace chromeos |
286 | 274 |
287 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ | 275 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ |
OLD | NEW |