Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(764)

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_manager_impl.h

Issue 419293002: IME refactoring: ChromeOS introduce input methods State. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 class ComponentExtensionIMEManagerDelegate; 23 class ComponentExtensionIMEManagerDelegate;
24 class InputMethodEngine; 24 class InputMethodEngine;
25 namespace input_method { 25 namespace input_method {
26 class InputMethodDelegate; 26 class InputMethodDelegate;
27 class ImeKeyboard; 27 class ImeKeyboard;
28 28
29 // The implementation of InputMethodManager. 29 // The implementation of InputMethodManager.
30 class InputMethodManagerImpl : public InputMethodManager, 30 class InputMethodManagerImpl : public InputMethodManager,
31 public CandidateWindowController::Observer { 31 public CandidateWindowController::Observer {
32 public: 32 public:
33 class State : public InputMethodManager::State {
34 public:
35 State();
36
37 // Init new state as a copy of other.
38 void InitFrom(const State& other);
39
40 std::string Dump() const;
41
42 std::string state_name;
43
44 // The input method which was/is selected.
45 InputMethodDescriptor previous_input_method_;
46 InputMethodDescriptor current_input_method_;
47 // The active input method ids cache.
48 std::vector<std::string> active_input_method_ids_;
49
50 // For screen locker. When the screen is locked, |previous_input_method_|,
51 // |current_input_method_|, and |active_input_method_ids_| above are copied
52 // to these "saved" variables.
53 InputMethodDescriptor saved_previous_input_method_;
54 InputMethodDescriptor saved_current_input_method_;
55 std::vector<std::string> saved_active_input_method_ids_;
56
57 std::string pending_input_method_;
58
59 // The engine map:
60 // { input_method_id : Engine }.
61 typedef std::map<std::string, InputMethodEngineInterface*> EngineMap;
62 EngineMap engine_map_;
63
64 protected:
65 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>;
66 virtual ~State();
67 };
68
33 // Constructs an InputMethodManager instance. The client is responsible for 69 // Constructs an InputMethodManager instance. The client is responsible for
34 // calling |SetState| in response to relevant changes in browser state. 70 // calling |SetUIState| in response to relevant changes in browser state.
35 explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate); 71 explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate);
36 virtual ~InputMethodManagerImpl(); 72 virtual ~InputMethodManagerImpl();
37 73
38 // Attach CandidateWindowController, and ImeKeyboard objects to the 74 // Attach CandidateWindowController, and ImeKeyboard objects to the
39 // InputMethodManagerImpl object. You don't have to call this 75 // InputMethodManagerImpl object. You don't have to call this
40 // function if you attach them yourself (e.g. in unit tests) using 76 // function if you attach them yourself (e.g. in unit tests) using
41 // the protected setters. 77 // the protected setters.
42 void Init(base::SequencedTaskRunner* ui_task_runner); 78 void Init(base::SequencedTaskRunner* ui_task_runner);
43 79
44 // Receives notification of an InputMethodManager::State transition. 80 // Receives notification of an InputMethodManager::UIState transition.
45 void SetState(State new_state); 81 void SetUIState(UIState new_ui_state);
46 82
47 // InputMethodManager override: 83 // InputMethodManager override:
48 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE; 84 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE;
49 virtual void AddCandidateWindowObserver( 85 virtual void AddCandidateWindowObserver(
50 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 86 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
51 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE; 87 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE;
52 virtual void RemoveCandidateWindowObserver( 88 virtual void RemoveCandidateWindowObserver(
53 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 89 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
54 virtual scoped_ptr<InputMethodDescriptors> 90 virtual scoped_ptr<InputMethodDescriptors>
55 GetSupportedInputMethods() const OVERRIDE; 91 GetSupportedInputMethods() const OVERRIDE;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 125
90 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE; 126 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE;
91 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; 127 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
92 virtual ComponentExtensionIMEManager* 128 virtual ComponentExtensionIMEManager*
93 GetComponentExtensionIMEManager() OVERRIDE; 129 GetComponentExtensionIMEManager() OVERRIDE;
94 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE; 130 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE;
95 131
96 virtual bool MigrateInputMethods( 132 virtual bool MigrateInputMethods(
97 std::vector<std::string>* input_method_ids) OVERRIDE; 133 std::vector<std::string>* input_method_ids) OVERRIDE;
98 134
135 virtual scoped_refptr<InputMethodManager::State> CreateNewState(
136 const std::string& debug_name) const OVERRIDE;
137 virtual void SetState(
138 scoped_refptr<InputMethodManager::State> state) OVERRIDE;
139
99 // Sets |candidate_window_controller_|. 140 // Sets |candidate_window_controller_|.
100 void SetCandidateWindowControllerForTesting( 141 void SetCandidateWindowControllerForTesting(
101 CandidateWindowController* candidate_window_controller); 142 CandidateWindowController* candidate_window_controller);
102 // Sets |keyboard_|. 143 // Sets |keyboard_|.
103 void SetImeKeyboardForTesting(ImeKeyboard* keyboard); 144 void SetImeKeyboardForTesting(ImeKeyboard* keyboard);
104 // Initialize |component_extension_manager_|. 145 // Initialize |component_extension_manager_|.
105 void InitializeComponentExtensionForTesting( 146 void InitializeComponentExtensionForTesting(
106 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); 147 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate);
107 148
108 private: 149 private:
(...skipping 23 matching lines...) Expand all
132 // done. 173 // done.
133 void MaybeInitializeCandidateWindowController(); 174 void MaybeInitializeCandidateWindowController();
134 175
135 // If |current_input_method_id_| is not in |input_method_ids|, switch to 176 // If |current_input_method_id_| is not in |input_method_ids|, switch to
136 // input_method_ids[0]. If the ID is equal to input_method_ids[N], switch to 177 // input_method_ids[0]. If the ID is equal to input_method_ids[N], switch to
137 // input_method_ids[N+1]. 178 // input_method_ids[N+1].
138 void SwitchToNextInputMethodInternal( 179 void SwitchToNextInputMethodInternal(
139 const std::vector<std::string>& input_method_ids, 180 const std::vector<std::string>& input_method_ids,
140 const std::string& current_input_method_id); 181 const std::string& current_input_method_id);
141 182
183 // Change system input method and inform observers. Doesn't modify state.
184 void ChangeInputMethodInternal(const InputMethodDescriptor& input_method_id,
185 bool show_message);
186
142 // Change system input method. 187 // Change system input method.
143 // Returns true if the system input method is changed. 188 // Returns true if the system input method is changed.
144 bool ChangeInputMethodInternal(const std::string& input_method_id, 189 bool LookupAndChangeInputMethodInternal(const std::string& input_method_id,
145 bool show_message); 190 bool show_message);
146 191
147 // Gets whether the XKB extension is loaded successfully by checking the XKB 192 // Gets whether the XKB extension is loaded successfully by checking the XKB
148 // input methods in input methods in |component_extension_ime_manager_|. 193 // input methods in input methods in |component_extension_ime_manager_|.
149 bool IsXkbComponentExtensionAvailable() const; 194 bool IsXkbComponentExtensionAvailable() const;
150 195
151 // Called when the ComponentExtensionIMEManagerDelegate is initialized. 196 // Called when the ComponentExtensionIMEManagerDelegate is initialized.
152 void OnComponentExtensionInitialized( 197 void OnComponentExtensionInitialized(
153 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); 198 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate);
154 void InitializeComponentExtension(); 199 void InitializeComponentExtension();
155 200
156 // Loads necessary component extensions. 201 // Loads necessary component extensions.
157 // TODO(nona): Support dynamical unloading. 202 // TODO(nona): Support dynamical unloading.
158 void LoadNecessaryComponentExtensions(); 203 void LoadNecessaryComponentExtensions();
159 204
160 // Adds new input method to given list if possible 205 // Adds new input method to given list if possible
161 bool EnableInputMethodImpl( 206 bool EnableInputMethodImpl(
162 const std::string& input_method_id, 207 const std::string& input_method_id,
163 std::vector<std::string>* new_active_input_method_ids) const; 208 std::vector<std::string>* new_active_input_method_ids) const;
164 209
165 // Starts or stops the system input method framework as needed. 210 // Starts or stops the system input method framework as needed.
166 // (after list of enabled input methods has been updated) 211 // (after list of enabled input methods has been updated)
167 void ReconfigureIMFramework(); 212 void ReconfigureIMFramework();
168 213
169 // Gets the current active user profile.
170 Profile* GetProfile() const;
171
172 scoped_ptr<InputMethodDelegate> delegate_; 214 scoped_ptr<InputMethodDelegate> delegate_;
173 215
174 // The current browser status. 216 // The current browser status.
175 State state_; 217 UIState ui_state_;
176 218
177 // A list of objects that monitor the manager. 219 // A list of objects that monitor the manager.
178 ObserverList<InputMethodManager::Observer> observers_; 220 ObserverList<InputMethodManager::Observer> observers_;
179 ObserverList<CandidateWindowObserver> candidate_window_observers_; 221 ObserverList<CandidateWindowObserver> candidate_window_observers_;
180 222
181 // The input method which was/is selected.
182 InputMethodDescriptor previous_input_method_;
183 InputMethodDescriptor current_input_method_;
184 // The active input method ids cache.
185 std::vector<std::string> active_input_method_ids_;
186
187 // The list of enabled extension IMEs. 223 // The list of enabled extension IMEs.
188 std::vector<std::string> enabled_extension_imes_; 224 std::vector<std::string> enabled_extension_imes_;
189 225
190 // For screen locker. When the screen is locked, |previous_input_method_|, 226 scoped_refptr<InputMethodManagerImpl::State> state_;
191 // |current_input_method_|, and |active_input_method_ids_| above are copied
192 // to these "saved" variables.
193 InputMethodDescriptor saved_previous_input_method_;
194 InputMethodDescriptor saved_current_input_method_;
195 std::vector<std::string> saved_active_input_method_ids_;
196 227
197 // Extra input methods that have been explicitly added to the menu, such as 228 // Extra input methods that have been explicitly added to the menu, such as
198 // those created by extension. 229 // those created by extension.
199 std::map<std::string, InputMethodDescriptor> extra_input_methods_; 230 std::map<std::string, InputMethodDescriptor> extra_input_methods_;
200 231
201 // The candidate window. This will be deleted when the APP_TERMINATING 232 // The candidate window. This will be deleted when the APP_TERMINATING
202 // message is sent. 233 // message is sent.
203 scoped_ptr<CandidateWindowController> candidate_window_controller_; 234 scoped_ptr<CandidateWindowController> candidate_window_controller_;
204 235
205 // The object which can create an InputMethodDescriptor object. 236 // The object which can create an InputMethodDescriptor object.
206 InputMethodWhitelist whitelist_; 237 InputMethodWhitelist whitelist_;
207 238
208 // An object which provides miscellaneous input method utility functions. Note 239 // An object which provides miscellaneous input method utility functions. Note
209 // that |util_| is required to initialize |keyboard_|. 240 // that |util_| is required to initialize |keyboard_|.
210 InputMethodUtil util_; 241 InputMethodUtil util_;
211 242
212 // An object which provides component extension ime management functions. 243 // An object which provides component extension ime management functions.
213 scoped_ptr<ComponentExtensionIMEManager> component_extension_ime_manager_; 244 scoped_ptr<ComponentExtensionIMEManager> component_extension_ime_manager_;
214 245
215 // An object for switching XKB layouts and keyboard status like caps lock and 246 // An object for switching XKB layouts and keyboard status like caps lock and
216 // auto-repeat interval. 247 // auto-repeat interval.
217 scoped_ptr<ImeKeyboard> keyboard_; 248 scoped_ptr<ImeKeyboard> keyboard_;
218 249
219 std::string pending_input_method_;
Shu Chen 2014/08/04 14:55:23 this is already gone, please rebase your cl.
Alexander Alekseev 2014/08/06 23:39:45 Done.
220
221 base::ThreadChecker thread_checker_; 250 base::ThreadChecker thread_checker_;
222 251
223 base::WeakPtrFactory<InputMethodManagerImpl> weak_ptr_factory_; 252 base::WeakPtrFactory<InputMethodManagerImpl> weak_ptr_factory_;
224 253
225 // The engine map:
226 // { Profile : { input_method_id : Engine } }.
227 typedef std::map<std::string, InputMethodEngineInterface*>
228 EngineMap;
229 typedef std::map<Profile*, EngineMap, ProfileCompare> ProfileEngineMap;
230 ProfileEngineMap profile_engine_map_;
231
232 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); 254 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl);
233 }; 255 };
234 256
235 } // namespace input_method 257 } // namespace input_method
236 } // namespace chromeos 258 } // namespace chromeos
237 259
238 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ 260 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698