| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_ | 5 #ifndef CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_ |
| 6 #define CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_ | 6 #define CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 const base::FilePath& path) = 0; | 56 const base::FilePath& path) = 0; |
| 57 | 57 |
| 58 // Unloads component extension IME associated with |extension_id|. | 58 // Unloads component extension IME associated with |extension_id|. |
| 59 virtual void Unload(const std::string& extension_id, | 59 virtual void Unload(const std::string& extension_id, |
| 60 const base::FilePath& path) = 0; | 60 const base::FilePath& path) = 0; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // This class manages component extension input method. | 63 // This class manages component extension input method. |
| 64 class CHROMEOS_EXPORT ComponentExtensionIMEManager { | 64 class CHROMEOS_EXPORT ComponentExtensionIMEManager { |
| 65 public: | 65 public: |
| 66 class Observer { | |
| 67 public: | |
| 68 // Called when the initialization is done. | |
| 69 virtual void OnImeComponentExtensionInitialized() = 0; | |
| 70 }; | |
| 71 | |
| 72 ComponentExtensionIMEManager(); | 66 ComponentExtensionIMEManager(); |
| 73 virtual ~ComponentExtensionIMEManager(); | 67 virtual ~ComponentExtensionIMEManager(); |
| 74 | 68 |
| 75 // Initializes component extension manager. This function create internal | 69 // Initializes component extension manager. This function create internal |
| 76 // mapping between input method id and engine components. This function must | 70 // mapping between input method id and engine components. This function must |
| 77 // be called before using any other function. | 71 // be called before using any other function. |
| 78 void Initialize(scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); | 72 void Initialize(scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); |
| 79 | 73 |
| 80 // Notifies the observers for the component extension IMEs are initialized. | |
| 81 void NotifyInitialized(); | |
| 82 | |
| 83 // Returns true if the initialization is done, otherwise returns false. | |
| 84 bool IsInitialized(); | |
| 85 | |
| 86 // Loads |input_method_id| component extension IME. This function returns true | 74 // Loads |input_method_id| component extension IME. This function returns true |
| 87 // on success. This function is safe to call multiple times. Returns false if | 75 // on success. This function is safe to call multiple times. Returns false if |
| 88 // already corresponding component extension is loaded. | 76 // already corresponding component extension is loaded. |
| 89 bool LoadComponentExtensionIME(const std::string& input_method_id); | 77 bool LoadComponentExtensionIME(const std::string& input_method_id); |
| 90 | 78 |
| 91 // Unloads |input_method_id| component extension IME. This function returns | 79 // Unloads |input_method_id| component extension IME. This function returns |
| 92 // true on success. This function is safe to call multiple times. Returns | 80 // true on success. This function is safe to call multiple times. Returns |
| 93 // false if already corresponding component extension is unloaded. | 81 // false if already corresponding component extension is unloaded. |
| 94 bool UnloadComponentExtensionIME(const std::string& input_method_id); | 82 bool UnloadComponentExtensionIME(const std::string& input_method_id); |
| 95 | 83 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 113 | 101 |
| 114 // Returns list of input method id associated with |language|. | 102 // Returns list of input method id associated with |language|. |
| 115 std::vector<std::string> ListIMEByLanguage(const std::string& language); | 103 std::vector<std::string> ListIMEByLanguage(const std::string& language); |
| 116 | 104 |
| 117 // Returns all IME as InputMethodDescriptors. | 105 // Returns all IME as InputMethodDescriptors. |
| 118 input_method::InputMethodDescriptors GetAllIMEAsInputMethodDescriptor(); | 106 input_method::InputMethodDescriptors GetAllIMEAsInputMethodDescriptor(); |
| 119 | 107 |
| 120 // Returns all XKB keyboard IME as InputMethodDescriptors. | 108 // Returns all XKB keyboard IME as InputMethodDescriptors. |
| 121 input_method::InputMethodDescriptors GetXkbIMEAsInputMethodDescriptor(); | 109 input_method::InputMethodDescriptors GetXkbIMEAsInputMethodDescriptor(); |
| 122 | 110 |
| 123 void AddObserver(Observer* observer); | |
| 124 void RemoveObserver(Observer* observer); | |
| 125 | |
| 126 private: | 111 private: |
| 127 // Finds ComponentExtensionIME and EngineDescription associated with | 112 // Finds ComponentExtensionIME and EngineDescription associated with |
| 128 // |input_method_id|. This function retruns true if it is found, otherwise | 113 // |input_method_id|. This function retruns true if it is found, otherwise |
| 129 // returns false. |out_extension| and |out_engine| can be NULL. | 114 // returns false. |out_extension| and |out_engine| can be NULL. |
| 130 bool FindEngineEntry(const std::string& input_method_id, | 115 bool FindEngineEntry(const std::string& input_method_id, |
| 131 ComponentExtensionIME* out_extension, | 116 ComponentExtensionIME* out_extension, |
| 132 ComponentExtensionEngine* out_engine); | 117 ComponentExtensionEngine* out_engine); |
| 133 | 118 |
| 134 bool IsInLoginLayoutWhitelist(const std::vector<std::string>& layouts); | 119 bool IsInLoginLayoutWhitelist(const std::vector<std::string>& layouts); |
| 135 | 120 |
| 136 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate_; | 121 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate_; |
| 137 | 122 |
| 138 std::vector<ComponentExtensionIME> component_extension_imes_; | 123 std::vector<ComponentExtensionIME> component_extension_imes_; |
| 139 | 124 |
| 140 ObserverList<Observer> observers_; | |
| 141 | |
| 142 bool is_initialized_; | |
| 143 | |
| 144 bool was_initialization_notified_; | |
| 145 | |
| 146 std::set<std::string> login_layout_set_; | 125 std::set<std::string> login_layout_set_; |
| 147 | 126 |
| 148 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManager); | 127 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManager); |
| 149 }; | 128 }; |
| 150 | 129 |
| 151 } // namespace chromeos | 130 } // namespace chromeos |
| 152 | 131 |
| 153 #endif // CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_ | 132 #endif // CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_ |
| OLD | NEW |