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

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

Issue 11466010: Decompose BrowserStateMonitor into two parts, simplifying unit tests and APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix gypi ordering. Created 8 years 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 | Annotate | Revision Log
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>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h"
15 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" 14 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
16 #include "chrome/browser/chromeos/input_method/ibus_controller.h" 15 #include "chrome/browser/chromeos/input_method/ibus_controller.h"
17 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 16 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
18 #include "chrome/browser/chromeos/input_method/input_method_util.h" 17 #include "chrome/browser/chromeos/input_method/input_method_util.h"
19 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" 18 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h"
20 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
21 19
22 namespace chromeos { 20 namespace chromeos {
23 class InputMethodEngineIBus; 21 class InputMethodEngineIBus;
24 namespace input_method { 22 namespace input_method {
25 class InputMethodDelegate; 23 class InputMethodDelegate;
24 class XKeyboard;
26 25
27 // The implementation of InputMethodManager. 26 // The implementation of InputMethodManager.
28 class InputMethodManagerImpl : public InputMethodManager, 27 class InputMethodManagerImpl : public InputMethodManager,
29 public CandidateWindowController::Observer, 28 public CandidateWindowController::Observer,
30 public IBusController::Observer { 29 public IBusController::Observer {
31 public: 30 public:
31 // Constructs an InputMethodManager instance. The client is responsible for
32 // calling |SetState| in response to relevant changes in browser state.
32 explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate); 33 explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate);
33 virtual ~InputMethodManagerImpl(); 34 virtual ~InputMethodManagerImpl();
34 35
35 // Attach IBusController, CandidateWindowController, and XKeyboard objects 36 // Attach IBusController, CandidateWindowController, and XKeyboard objects
36 // to the InputMethodManagerImpl object. You don't have to call this function 37 // to the InputMethodManagerImpl object. You don't have to call this function
37 // if you attach them yourself (e.g. in unit tests) using the protected 38 // if you attach them yourself (e.g. in unit tests) using the protected
38 // setters. 39 // setters.
39 void Init(); 40 void Init();
40 41
42 // Receives notification of an InputMethodManager::State transition.
43 void SetState(State new_state);
44
41 // InputMethodManager override: 45 // InputMethodManager override:
42 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE; 46 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE;
43 virtual void AddCandidateWindowObserver( 47 virtual void AddCandidateWindowObserver(
44 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 48 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
45 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE; 49 virtual void RemoveObserver(InputMethodManager::Observer* observer) OVERRIDE;
46 virtual void RemoveCandidateWindowObserver( 50 virtual void RemoveCandidateWindowObserver(
47 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE; 51 InputMethodManager::CandidateWindowObserver* observer) OVERRIDE;
48 virtual void SetState(State new_state) OVERRIDE;
49 virtual scoped_ptr<InputMethodDescriptors> 52 virtual scoped_ptr<InputMethodDescriptors>
50 GetSupportedInputMethods() const OVERRIDE; 53 GetSupportedInputMethods() const OVERRIDE;
51 virtual scoped_ptr<InputMethodDescriptors> 54 virtual scoped_ptr<InputMethodDescriptors>
52 GetActiveInputMethods() const OVERRIDE; 55 GetActiveInputMethods() const OVERRIDE;
53 virtual size_t GetNumActiveInputMethods() const OVERRIDE; 56 virtual size_t GetNumActiveInputMethods() const OVERRIDE;
54 virtual void EnableLayouts(const std::string& language_code, 57 virtual void EnableLayouts(const std::string& language_code,
55 const std::string& initial_layout) OVERRIDE; 58 const std::string& initial_layout) OVERRIDE;
56 virtual bool EnableInputMethods( 59 virtual bool EnableInputMethods(
57 const std::vector<std::string>& new_active_input_method_ids) OVERRIDE; 60 const std::vector<std::string>& new_active_input_method_ids) OVERRIDE;
58 virtual bool SetInputMethodConfig( 61 virtual bool SetInputMethodConfig(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // to these "saved" variables. 156 // to these "saved" variables.
154 InputMethodDescriptor saved_previous_input_method_; 157 InputMethodDescriptor saved_previous_input_method_;
155 InputMethodDescriptor saved_current_input_method_; 158 InputMethodDescriptor saved_current_input_method_;
156 std::vector<std::string> saved_active_input_method_ids_; 159 std::vector<std::string> saved_active_input_method_ids_;
157 160
158 // Extra input methods that have been explicitly added to the menu, such as 161 // Extra input methods that have been explicitly added to the menu, such as
159 // those created by extension. 162 // those created by extension.
160 std::map<std::string, InputMethodDescriptor> extra_input_methods_; 163 std::map<std::string, InputMethodDescriptor> extra_input_methods_;
161 std::map<std::string, InputMethodEngineIBus*> extra_input_method_instances_; 164 std::map<std::string, InputMethodEngineIBus*> extra_input_method_instances_;
162 165
163 // The browser state monitor is used to receive notifications from the browser
164 // and call SetState() method of |this| class.
165 scoped_ptr<BrowserStateMonitor> browser_state_monitor_;
166
167 // The IBus controller is used to control the input method status and 166 // The IBus controller is used to control the input method status and
168 // allow callbacks when the input method status changes. 167 // allow callbacks when the input method status changes.
169 scoped_ptr<IBusController> ibus_controller_; 168 scoped_ptr<IBusController> ibus_controller_;
170 169
171 // The candidate window. This will be deleted when the APP_TERMINATING 170 // The candidate window. This will be deleted when the APP_TERMINATING
172 // message is sent. 171 // message is sent.
173 scoped_ptr<CandidateWindowController> candidate_window_controller_; 172 scoped_ptr<CandidateWindowController> candidate_window_controller_;
174 173
175 // The object which can create an InputMethodDescriptor object. 174 // The object which can create an InputMethodDescriptor object.
176 InputMethodWhitelist whitelist_; 175 InputMethodWhitelist whitelist_;
177 176
178 // An object which provides miscellaneous input method utility functions. Note 177 // An object which provides miscellaneous input method utility functions. Note
179 // that |util_| is required to initialize |xkeyboard_|. 178 // that |util_| is required to initialize |xkeyboard_|.
180 InputMethodUtil util_; 179 InputMethodUtil util_;
181 180
182 // An object for switching XKB layouts and keyboard status like caps lock and 181 // An object for switching XKB layouts and keyboard status like caps lock and
183 // auto-repeat interval. 182 // auto-repeat interval.
184 scoped_ptr<XKeyboard> xkeyboard_; 183 scoped_ptr<XKeyboard> xkeyboard_;
185 184
186 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); 185 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl);
187 }; 186 };
188 187
189 } // namespace input_method 188 } // namespace input_method
190 } // namespace chromeos 189 } // namespace chromeos
191 190
192 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ 191 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698