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

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: Update after review. 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 // The engine map:
58 // { input_method_id : Engine }.
Shu Chen 2014/08/07 15:40:19 s/input_method_id/extension_id
Alexander Alekseev 2014/08/13 10:14:15 Done.
59 typedef std::map<std::string, InputMethodEngineInterface*> EngineMap;
60 EngineMap engine_map_;
Shu Chen 2014/08/07 15:40:19 The engine_map_ is not profile based now, and it's
Alexander Alekseev 2014/08/13 10:14:15 Done.
61
62 protected:
63 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>;
64 virtual ~State();
65 };
66
33 // Constructs an InputMethodManager instance. The client is responsible for 67 // Constructs an InputMethodManager instance. The client is responsible for
34 // calling |SetState| in response to relevant changes in browser state. 68 // calling |SetUISessionState| in response to relevant changes in browser
69 // state.
35 explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate); 70 explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate);
36 virtual ~InputMethodManagerImpl(); 71 virtual ~InputMethodManagerImpl();
37 72
38 // Receives notification of an InputMethodManager::State transition. 73 // Receives notification of an InputMethodManager::UISessionState transition.
39 void SetState(State new_state); 74 void SetUISessionState(UISessionState new_ui_session);
40 75
41 // InputMethodManager override: 76 // InputMethodManager override:
42 virtual void InitializeComponentExtension() OVERRIDE; 77 virtual void InitializeComponentExtension() OVERRIDE;
43 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE; 78 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE;
44 virtual void AddCandidateWindowObserver( 79 virtual void AddCandidateWindowObserver(
45 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 80 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
46 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE; 81 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE;
47 virtual void RemoveCandidateWindowObserver( 82 virtual void RemoveCandidateWindowObserver(
48 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 83 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
49 virtual scoped_ptr<InputMethodDescriptors> 84 virtual scoped_ptr<InputMethodDescriptors>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 121
87 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE; 122 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE;
88 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; 123 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
89 virtual ComponentExtensionIMEManager* 124 virtual ComponentExtensionIMEManager*
90 GetComponentExtensionIMEManager() OVERRIDE; 125 GetComponentExtensionIMEManager() OVERRIDE;
91 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE; 126 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE;
92 127
93 virtual bool MigrateInputMethods( 128 virtual bool MigrateInputMethods(
94 std::vector<std::string>* input_method_ids) OVERRIDE; 129 std::vector<std::string>* input_method_ids) OVERRIDE;
95 130
131 virtual scoped_refptr<InputMethodManager::State> CreateNewState(
132 const std::string& debug_name) const OVERRIDE;
133 virtual void SetState(
134 scoped_refptr<InputMethodManager::State> state) OVERRIDE;
135
96 // Sets |candidate_window_controller_|. 136 // Sets |candidate_window_controller_|.
97 void SetCandidateWindowControllerForTesting( 137 void SetCandidateWindowControllerForTesting(
98 CandidateWindowController* candidate_window_controller); 138 CandidateWindowController* candidate_window_controller);
99 // Sets |keyboard_|. 139 // Sets |keyboard_|.
100 void SetImeKeyboardForTesting(ImeKeyboard* keyboard); 140 void SetImeKeyboardForTesting(ImeKeyboard* keyboard);
101 // Initialize |component_extension_manager_|. 141 // Initialize |component_extension_manager_|.
102 void InitializeComponentExtensionForTesting( 142 void InitializeComponentExtensionForTesting(
103 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); 143 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate);
104 144
105 private: 145 private:
(...skipping 25 matching lines...) Expand all
131 // done. 171 // done.
132 void MaybeInitializeCandidateWindowController(); 172 void MaybeInitializeCandidateWindowController();
133 173
134 // If |current_input_method_id_| is not in |input_method_ids|, switch to 174 // If |current_input_method_id_| is not in |input_method_ids|, switch to
135 // input_method_ids[0]. If the ID is equal to input_method_ids[N], switch to 175 // input_method_ids[0]. If the ID is equal to input_method_ids[N], switch to
136 // input_method_ids[N+1]. 176 // input_method_ids[N+1].
137 void SwitchToNextInputMethodInternal( 177 void SwitchToNextInputMethodInternal(
138 const std::vector<std::string>& input_method_ids, 178 const std::vector<std::string>& input_method_ids,
139 const std::string& current_input_method_id); 179 const std::string& current_input_method_id);
140 180
181 // Change system input method and inform observers. Doesn't modify state.
182 void ChangeInputMethodInternal(const InputMethodDescriptor& input_method_id,
183 bool show_message);
184
141 // Change system input method. 185 // Change system input method.
142 // Returns true if the system input method is changed. 186 void LookupAndChangeInputMethodInternal(const std::string& input_method_id,
143 bool ChangeInputMethodInternal(const std::string& input_method_id, 187 bool show_message);
144 bool show_message);
145 188
146 // Loads necessary component extensions. 189 // Loads necessary component extensions.
147 // TODO(nona): Support dynamical unloading. 190 // TODO(nona): Support dynamical unloading.
148 void LoadNecessaryComponentExtensions(); 191 void LoadNecessaryComponentExtensions();
149 192
150 // Adds new input method to given list if possible 193 // Adds new input method to given list if possible
151 bool EnableInputMethodImpl( 194 bool EnableInputMethodImpl(
152 const std::string& input_method_id, 195 const std::string& input_method_id,
153 std::vector<std::string>* new_active_input_method_ids) const; 196 std::vector<std::string>* new_active_input_method_ids) const;
154 197
155 // Starts or stops the system input method framework as needed. 198 // Starts or stops the system input method framework as needed.
156 // (after list of enabled input methods has been updated) 199 // (after list of enabled input methods has been updated)
157 void ReconfigureIMFramework(); 200 void ReconfigureIMFramework();
158 201
159 scoped_ptr<InputMethodDelegate> delegate_; 202 scoped_ptr<InputMethodDelegate> delegate_;
160 203
161 // The current browser status. 204 // The current browser status.
162 State state_; 205 UISessionState ui_session_;
163 206
164 // A list of objects that monitor the manager. 207 // A list of objects that monitor the manager.
165 ObserverList<InputMethodManager::Observer> observers_; 208 ObserverList<InputMethodManager::Observer> observers_;
166 ObserverList<CandidateWindowObserver> candidate_window_observers_; 209 ObserverList<CandidateWindowObserver> candidate_window_observers_;
167 210
168 // The input method which was/is selected.
169 InputMethodDescriptor previous_input_method_;
170 InputMethodDescriptor current_input_method_;
171 // The active input method ids cache.
172 std::vector<std::string> active_input_method_ids_;
173
174 // The list of enabled extension IMEs. 211 // The list of enabled extension IMEs.
175 std::vector<std::string> enabled_extension_imes_; 212 std::vector<std::string> enabled_extension_imes_;
176 213
177 // For screen locker. When the screen is locked, |previous_input_method_|, 214 scoped_refptr<InputMethodManagerImpl::State> state_;
178 // |current_input_method_|, and |active_input_method_ids_| above are copied
179 // to these "saved" variables.
180 InputMethodDescriptor saved_previous_input_method_;
181 InputMethodDescriptor saved_current_input_method_;
182 std::vector<std::string> saved_active_input_method_ids_;
183 215
184 // Extra input methods that have been explicitly added to the menu, such as 216 // Extra input methods that have been explicitly added to the menu, such as
185 // those created by extension. 217 // those created by extension.
186 std::map<std::string, InputMethodDescriptor> extra_input_methods_; 218 std::map<std::string, InputMethodDescriptor> extra_input_methods_;
187 219
188 // The candidate window. This will be deleted when the APP_TERMINATING 220 // The candidate window. This will be deleted when the APP_TERMINATING
189 // message is sent. 221 // message is sent.
190 scoped_ptr<CandidateWindowController> candidate_window_controller_; 222 scoped_ptr<CandidateWindowController> candidate_window_controller_;
191 223
192 // An object which provides miscellaneous input method utility functions. Note 224 // An object which provides miscellaneous input method utility functions. Note
193 // that |util_| is required to initialize |keyboard_|. 225 // that |util_| is required to initialize |keyboard_|.
194 InputMethodUtil util_; 226 InputMethodUtil util_;
195 227
196 // An object which provides component extension ime management functions. 228 // An object which provides component extension ime management functions.
197 scoped_ptr<ComponentExtensionIMEManager> component_extension_ime_manager_; 229 scoped_ptr<ComponentExtensionIMEManager> component_extension_ime_manager_;
198 230
199 // An object for switching XKB layouts and keyboard status like caps lock and 231 // An object for switching XKB layouts and keyboard status like caps lock and
200 // auto-repeat interval. 232 // auto-repeat interval.
201 scoped_ptr<ImeKeyboard> keyboard_; 233 scoped_ptr<ImeKeyboard> keyboard_;
202 234
203 base::ThreadChecker thread_checker_; 235 base::ThreadChecker thread_checker_;
204 236
205 base::WeakPtrFactory<InputMethodManagerImpl> weak_ptr_factory_; 237 base::WeakPtrFactory<InputMethodManagerImpl> weak_ptr_factory_;
206 238
207 // The engine map from extension_id to an engine.
208 std::map<std::string, InputMethodEngineInterface*> engine_map_;
209
210 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); 239 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl);
211 }; 240 };
212 241
213 } // namespace input_method 242 } // namespace input_method
214 } // namespace chromeos 243 } // namespace chromeos
215 244
216 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ 245 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698