| 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/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 "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" | 15 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" |
| 16 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 16 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 17 #include "chromeos/ime/input_method_manager.h" | 17 #include "chromeos/ime/input_method_manager.h" |
| 18 #include "chromeos/ime/input_method_whitelist.h" | 18 #include "chromeos/ime/input_method_whitelist.h" |
| 19 | 19 |
| 20 namespace chromeos { | 20 namespace chromeos { |
| 21 class ComponentExtensionIMEManager; | 21 class ComponentExtensionIMEManager; |
| 22 class ComponentExtensionIMEManagerDelegate; | 22 class ComponentExtensionIMEManagerDelegate; |
| 23 class InputMethodEngine; | 23 class InputMethodEngine; |
| 24 namespace input_method { | 24 namespace input_method { |
| 25 class InputMethodDelegate; | 25 class InputMethodDelegate; |
| 26 class XKeyboard; | 26 class ImeKeyboard; |
| 27 | 27 |
| 28 // The implementation of InputMethodManager. | 28 // The implementation of InputMethodManager. |
| 29 class InputMethodManagerImpl : public InputMethodManager, | 29 class InputMethodManagerImpl : public InputMethodManager, |
| 30 public CandidateWindowController::Observer { | 30 public CandidateWindowController::Observer { |
| 31 public: | 31 public: |
| 32 // Constructs an InputMethodManager instance. The client is responsible for | 32 // Constructs an InputMethodManager instance. The client is responsible for |
| 33 // calling |SetState| in response to relevant changes in browser state. | 33 // calling |SetState| in response to relevant changes in browser state. |
| 34 explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate); | 34 explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate); |
| 35 virtual ~InputMethodManagerImpl(); | 35 virtual ~InputMethodManagerImpl(); |
| 36 | 36 |
| 37 // Attach CandidateWindowController, and XKeyboard objects to the | 37 // Attach CandidateWindowController, and ImeKeyboard objects to the |
| 38 // InputMethodManagerImpl object. You don't have to call this | 38 // InputMethodManagerImpl object. You don't have to call this |
| 39 // function if you attach them yourself (e.g. in unit tests) using | 39 // function if you attach them yourself (e.g. in unit tests) using |
| 40 // the protected setters. | 40 // the protected setters. |
| 41 void Init(base::SequencedTaskRunner* ui_task_runner); | 41 void Init(base::SequencedTaskRunner* ui_task_runner); |
| 42 | 42 |
| 43 // Receives notification of an InputMethodManager::State transition. | 43 // Receives notification of an InputMethodManager::State transition. |
| 44 void SetState(State new_state); | 44 void SetState(State new_state); |
| 45 | 45 |
| 46 // InputMethodManager override: | 46 // InputMethodManager override: |
| 47 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE; | 47 virtual void AddObserver(InputMethodManager::Observer* observer) OVERRIDE; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 77 virtual void SetEnabledExtensionImes(std::vector<std::string>* ids) OVERRIDE; | 77 virtual void SetEnabledExtensionImes(std::vector<std::string>* ids) OVERRIDE; |
| 78 virtual void SetInputMethodLoginDefault() OVERRIDE; | 78 virtual void SetInputMethodLoginDefault() OVERRIDE; |
| 79 virtual bool SwitchToNextInputMethod() OVERRIDE; | 79 virtual bool SwitchToNextInputMethod() OVERRIDE; |
| 80 virtual bool SwitchToPreviousInputMethod( | 80 virtual bool SwitchToPreviousInputMethod( |
| 81 const ui::Accelerator& accelerator) OVERRIDE; | 81 const ui::Accelerator& accelerator) OVERRIDE; |
| 82 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE; | 82 virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE; |
| 83 virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE; | 83 virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE; |
| 84 virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const OVERRIDE; | 84 virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const OVERRIDE; |
| 85 virtual bool IsAltGrUsedByCurrentInputMethod() const OVERRIDE; | 85 virtual bool IsAltGrUsedByCurrentInputMethod() const OVERRIDE; |
| 86 | 86 |
| 87 virtual XKeyboard* GetXKeyboard() OVERRIDE; | 87 virtual ImeKeyboard* GetImeKeyboard() OVERRIDE; |
| 88 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; | 88 virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; |
| 89 virtual ComponentExtensionIMEManager* | 89 virtual ComponentExtensionIMEManager* |
| 90 GetComponentExtensionIMEManager() OVERRIDE; | 90 GetComponentExtensionIMEManager() OVERRIDE; |
| 91 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE; | 91 virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE; |
| 92 | 92 |
| 93 virtual bool MigrateXkbInputMethods( | 93 virtual bool MigrateXkbInputMethods( |
| 94 std::vector<std::string>* input_method_ids) OVERRIDE; | 94 std::vector<std::string>* input_method_ids) OVERRIDE; |
| 95 | 95 |
| 96 // Sets |candidate_window_controller_|. | 96 // Sets |candidate_window_controller_|. |
| 97 void SetCandidateWindowControllerForTesting( | 97 void SetCandidateWindowControllerForTesting( |
| 98 CandidateWindowController* candidate_window_controller); | 98 CandidateWindowController* candidate_window_controller); |
| 99 // Sets |xkeyboard_|. | 99 // Sets |keyboard_|. |
| 100 void SetXKeyboardForTesting(XKeyboard* xkeyboard); | 100 void SetImeKeyboardForTesting(ImeKeyboard* keyboard); |
| 101 // Initialize |component_extension_manager_|. | 101 // Initialize |component_extension_manager_|. |
| 102 void InitializeComponentExtensionForTesting( | 102 void InitializeComponentExtensionForTesting( |
| 103 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); | 103 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 // CandidateWindowController::Observer overrides: | 106 // CandidateWindowController::Observer overrides: |
| 107 virtual void CandidateClicked(int index) OVERRIDE; | 107 virtual void CandidateClicked(int index) OVERRIDE; |
| 108 virtual void CandidateWindowOpened() OVERRIDE; | 108 virtual void CandidateWindowOpened() OVERRIDE; |
| 109 virtual void CandidateWindowClosed() OVERRIDE; | 109 virtual void CandidateWindowClosed() OVERRIDE; |
| 110 | 110 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 std::map<std::string, InputMethodDescriptor> extra_input_methods_; | 189 std::map<std::string, InputMethodDescriptor> extra_input_methods_; |
| 190 | 190 |
| 191 // The candidate window. This will be deleted when the APP_TERMINATING | 191 // The candidate window. This will be deleted when the APP_TERMINATING |
| 192 // message is sent. | 192 // message is sent. |
| 193 scoped_ptr<CandidateWindowController> candidate_window_controller_; | 193 scoped_ptr<CandidateWindowController> candidate_window_controller_; |
| 194 | 194 |
| 195 // The object which can create an InputMethodDescriptor object. | 195 // The object which can create an InputMethodDescriptor object. |
| 196 InputMethodWhitelist whitelist_; | 196 InputMethodWhitelist whitelist_; |
| 197 | 197 |
| 198 // An object which provides miscellaneous input method utility functions. Note | 198 // An object which provides miscellaneous input method utility functions. Note |
| 199 // that |util_| is required to initialize |xkeyboard_|. | 199 // that |util_| is required to initialize |keyboard_|. |
| 200 InputMethodUtil util_; | 200 InputMethodUtil util_; |
| 201 | 201 |
| 202 // An object which provides component extension ime management functions. | 202 // An object which provides component extension ime management functions. |
| 203 scoped_ptr<ComponentExtensionIMEManager> component_extension_ime_manager_; | 203 scoped_ptr<ComponentExtensionIMEManager> component_extension_ime_manager_; |
| 204 | 204 |
| 205 // An object for switching XKB layouts and keyboard status like caps lock and | 205 // An object for switching XKB layouts and keyboard status like caps lock and |
| 206 // auto-repeat interval. | 206 // auto-repeat interval. |
| 207 scoped_ptr<XKeyboard> xkeyboard_; | 207 scoped_ptr<ImeKeyboard> keyboard_; |
| 208 | 208 |
| 209 std::string pending_input_method_; | 209 std::string pending_input_method_; |
| 210 | 210 |
| 211 base::ThreadChecker thread_checker_; | 211 base::ThreadChecker thread_checker_; |
| 212 | 212 |
| 213 base::WeakPtrFactory<InputMethodManagerImpl> weak_ptr_factory_; | 213 base::WeakPtrFactory<InputMethodManagerImpl> weak_ptr_factory_; |
| 214 | 214 |
| 215 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); | 215 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 } // namespace input_method | 218 } // namespace input_method |
| 219 } // namespace chromeos | 219 } // namespace chromeos |
| 220 | 220 |
| 221 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ | 221 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_ |
| OLD | NEW |