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> |
11 | 11 |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" | 14 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" |
15 #include "chrome/browser/chromeos/input_method/candidate_window.h" | 15 #include "chrome/browser/chromeos/input_method/candidate_window.h" |
16 #include "chrome/browser/chromeos/input_method/ibus_controller.h" | 16 #include "chrome/browser/chromeos/input_method/ibus_controller.h" |
17 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 17 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
18 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 18 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
19 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" | 19 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" |
20 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 20 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
21 | 21 |
22 namespace chromeos { | 22 namespace chromeos { |
| 23 class InputMethodEngineIBus; |
23 namespace input_method { | 24 namespace input_method { |
24 | 25 |
25 // The implementation of InputMethodManager. | 26 // The implementation of InputMethodManager. |
26 class InputMethodManagerImpl : public InputMethodManager, | 27 class InputMethodManagerImpl : public InputMethodManager, |
27 public CandidateWindowController::Observer, | 28 public CandidateWindowController::Observer, |
28 public IBusController::Observer { | 29 public IBusController::Observer { |
29 public: | 30 public: |
30 virtual ~InputMethodManagerImpl(); | 31 virtual ~InputMethodManagerImpl(); |
31 | 32 |
32 // InputMethodManager override: | 33 // InputMethodManager override: |
(...skipping 14 matching lines...) Expand all Loading... |
47 virtual bool SetInputMethodConfig( | 48 virtual bool SetInputMethodConfig( |
48 const std::string& section, | 49 const std::string& section, |
49 const std::string& config_name, | 50 const std::string& config_name, |
50 const InputMethodConfigValue& value) OVERRIDE; | 51 const InputMethodConfigValue& value) OVERRIDE; |
51 virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE; | 52 virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE; |
52 virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE; | 53 virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE; |
53 virtual void AddInputMethodExtension( | 54 virtual void AddInputMethodExtension( |
54 const std::string& id, | 55 const std::string& id, |
55 const std::string& name, | 56 const std::string& name, |
56 const std::vector<std::string>& layouts, | 57 const std::vector<std::string>& layouts, |
57 const std::string& language) OVERRIDE; | 58 const std::string& language, |
| 59 InputMethodEngine* instance) OVERRIDE; |
58 virtual void RemoveInputMethodExtension(const std::string& id) OVERRIDE; | 60 virtual void RemoveInputMethodExtension(const std::string& id) OVERRIDE; |
59 virtual bool SwitchToNextInputMethod() OVERRIDE; | 61 virtual bool SwitchToNextInputMethod() OVERRIDE; |
60 virtual bool SwitchToPreviousInputMethod() OVERRIDE; | 62 virtual bool SwitchToPreviousInputMethod() OVERRIDE; |
61 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE; | 63 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE; |
62 virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE; | 64 virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE; |
63 virtual InputMethodPropertyList | 65 virtual InputMethodPropertyList |
64 GetCurrentInputMethodProperties() const OVERRIDE; | 66 GetCurrentInputMethodProperties() const OVERRIDE; |
65 virtual XKeyboard* GetXKeyboard() OVERRIDE; | 67 virtual XKeyboard* GetXKeyboard() OVERRIDE; |
66 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; | 68 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; |
67 | 69 |
68 // Sets |ibus_controller_|. | 70 // Sets |ibus_controller_|. |
69 void SetIBusControllerForTesting(IBusController* ibus_controller); | 71 void SetIBusControllerForTesting(IBusController* ibus_controller); |
70 // Sets |candidate_window_controller_|. | 72 // Sets |candidate_window_controller_|. |
71 void SetCandidateWindowControllerForTesting( | 73 void SetCandidateWindowControllerForTesting( |
72 CandidateWindowController* candidate_window_controller); | 74 CandidateWindowController* candidate_window_controller); |
73 // Sets |xkeyboard_|. | 75 // Sets |xkeyboard_|. |
74 void SetXKeyboardForTesting(XKeyboard* xkeyboard); | 76 void SetXKeyboardForTesting(XKeyboard* xkeyboard); |
75 | 77 |
76 // Creates a new instance of this class. The caller has to delete the returned | 78 // Creates a new instance of this class. The caller has to delete the returned |
77 // object. The caller also have to set a mock CandidateWindowController, | 79 // object. The caller also have to set a mock CandidateWindowController, |
78 // IBusController, and XKeyboard. See the setters above. | 80 // IBusController, and XKeyboard. See the setters above. |
79 static InputMethodManagerImpl* GetInstanceForTesting(); | 81 static InputMethodManagerImpl* GetInstanceForTesting(); |
80 | 82 |
81 private: | 83 private: |
82 friend class InputMethodManager; | 84 friend class InputMethodManager; |
83 InputMethodManagerImpl(); | 85 InputMethodManagerImpl(); |
84 | 86 |
85 // IBusController overrides: | 87 // IBusController overrides: |
86 virtual void PropertyChanged() OVERRIDE; | 88 virtual void PropertyChanged() OVERRIDE; |
| 89 virtual void OnConnected() OVERRIDE; |
| 90 virtual void OnDisconnected() OVERRIDE; |
| 91 |
87 | 92 |
88 // CandidateWindowController::Observer overrides: | 93 // CandidateWindowController::Observer overrides: |
89 virtual void CandidateWindowOpened() OVERRIDE; | 94 virtual void CandidateWindowOpened() OVERRIDE; |
90 virtual void CandidateWindowClosed() OVERRIDE; | 95 virtual void CandidateWindowClosed() OVERRIDE; |
91 | 96 |
92 // Attach IBusController, CandidateWindowController, and XKeyboard objects | 97 // Attach IBusController, CandidateWindowController, and XKeyboard objects |
93 // to the InputMethodManagerImpl object. You don't have to call this function | 98 // to the InputMethodManagerImpl object. You don't have to call this function |
94 // if you attach them yourself (e.g. in unit tests) using the setters above. | 99 // if you attach them yourself (e.g. in unit tests) using the setters above. |
95 void Init(); | 100 void Init(); |
96 | 101 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // For screen locker. When the screen is locked, |previous_input_method_|, | 146 // For screen locker. When the screen is locked, |previous_input_method_|, |
142 // |current_input_method_|, and |active_input_method_ids_| above are copied | 147 // |current_input_method_|, and |active_input_method_ids_| above are copied |
143 // to these "saved" variables. | 148 // to these "saved" variables. |
144 InputMethodDescriptor saved_previous_input_method_; | 149 InputMethodDescriptor saved_previous_input_method_; |
145 InputMethodDescriptor saved_current_input_method_; | 150 InputMethodDescriptor saved_current_input_method_; |
146 std::vector<std::string> saved_active_input_method_ids_; | 151 std::vector<std::string> saved_active_input_method_ids_; |
147 | 152 |
148 // Extra input methods that have been explicitly added to the menu, such as | 153 // Extra input methods that have been explicitly added to the menu, such as |
149 // those created by extension. | 154 // those created by extension. |
150 std::map<std::string, InputMethodDescriptor> extra_input_methods_; | 155 std::map<std::string, InputMethodDescriptor> extra_input_methods_; |
| 156 std::map<std::string, InputMethodEngineIBus*> extra_input_method_instances_; |
151 | 157 |
152 // The browser state monitor is used to receive notifications from the browser | 158 // The browser state monitor is used to receive notifications from the browser |
153 // and call SetState() method of |this| class. | 159 // and call SetState() method of |this| class. |
154 scoped_ptr<BrowserStateMonitor> browser_state_monitor_; | 160 scoped_ptr<BrowserStateMonitor> browser_state_monitor_; |
155 | 161 |
156 // The IBus controller is used to control the input method status and | 162 // The IBus controller is used to control the input method status and |
157 // allow callbacks when the input method status changes. | 163 // allow callbacks when the input method status changes. |
158 scoped_ptr<IBusController> ibus_controller_; | 164 scoped_ptr<IBusController> ibus_controller_; |
159 | 165 |
160 // The candidate window. This will be deleted when the APP_TERMINATING | 166 // The candidate window. This will be deleted when the APP_TERMINATING |
(...skipping 11 matching lines...) Expand all Loading... |
172 // auto-repeat interval. | 178 // auto-repeat interval. |
173 scoped_ptr<XKeyboard> xkeyboard_; | 179 scoped_ptr<XKeyboard> xkeyboard_; |
174 | 180 |
175 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); | 181 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); |
176 }; | 182 }; |
177 | 183 |
178 } // namespace input_method | 184 } // namespace input_method |
179 } // namespace chromeos | 185 } // namespace chromeos |
180 | 186 |
181 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ | 187 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ |
OLD | NEW |