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 UI_BASE_IME_CHROMEOS_COMPONENT_EXTENSION_IME_MANAGER_H_ | 5 #ifndef UI_BASE_IME_CHROMEOS_COMPONENT_EXTENSION_IME_MANAGER_H_ |
6 #define UI_BASE_IME_CHROMEOS_COMPONENT_EXTENSION_IME_MANAGER_H_ | 6 #define UI_BASE_IME_CHROMEOS_COMPONENT_EXTENSION_IME_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <set> | 10 #include <set> |
10 | 11 |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "ui/base/ime/chromeos/input_method_descriptor.h" | 15 #include "ui/base/ime/chromeos/input_method_descriptor.h" |
16 #include "ui/base/ime/ui_base_ime_export.h" | 16 #include "ui/base/ime/ui_base_ime_export.h" |
17 | 17 |
18 class Profile; | 18 class Profile; |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 | 21 |
22 // Represents an engine in component extension IME. | 22 // Represents an engine in component extension IME. |
23 struct UI_BASE_IME_EXPORT ComponentExtensionEngine { | 23 struct UI_BASE_IME_EXPORT ComponentExtensionEngine { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 // This class manages component extension input method. | 72 // This class manages component extension input method. |
73 class UI_BASE_IME_EXPORT ComponentExtensionIMEManager { | 73 class UI_BASE_IME_EXPORT ComponentExtensionIMEManager { |
74 public: | 74 public: |
75 ComponentExtensionIMEManager(); | 75 ComponentExtensionIMEManager(); |
76 virtual ~ComponentExtensionIMEManager(); | 76 virtual ~ComponentExtensionIMEManager(); |
77 | 77 |
78 // Initializes component extension manager. This function create internal | 78 // Initializes component extension manager. This function create internal |
79 // mapping between input method id and engine components. This function must | 79 // mapping between input method id and engine components. This function must |
80 // be called before using any other function. | 80 // be called before using any other function. |
81 void Initialize(scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); | 81 void Initialize( |
| 82 std::unique_ptr<ComponentExtensionIMEManagerDelegate> delegate); |
82 | 83 |
83 // Loads |input_method_id| component extension IME. This function returns true | 84 // Loads |input_method_id| component extension IME. This function returns true |
84 // on success. This function is safe to call multiple times. Returns false if | 85 // on success. This function is safe to call multiple times. Returns false if |
85 // already corresponding component extension is loaded. | 86 // already corresponding component extension is loaded. |
86 bool LoadComponentExtensionIME(Profile* profile, | 87 bool LoadComponentExtensionIME(Profile* profile, |
87 const std::string& input_method_id); | 88 const std::string& input_method_id); |
88 | 89 |
89 // Unloads |input_method_id| component extension IME. This function returns | 90 // Unloads |input_method_id| component extension IME. This function returns |
90 // true on success. This function is safe to call multiple times. Returns | 91 // true on success. This function is safe to call multiple times. Returns |
91 // false if already corresponding component extension is unloaded. | 92 // false if already corresponding component extension is unloaded. |
(...skipping 15 matching lines...) Expand all Loading... |
107 | 108 |
108 private: | 109 private: |
109 // Finds ComponentExtensionIME and EngineDescription associated with | 110 // Finds ComponentExtensionIME and EngineDescription associated with |
110 // |input_method_id|. This function retruns true if it is found, otherwise | 111 // |input_method_id|. This function retruns true if it is found, otherwise |
111 // returns false. |out_extension| and |out_engine| can be NULL. | 112 // returns false. |out_extension| and |out_engine| can be NULL. |
112 bool FindEngineEntry(const std::string& input_method_id, | 113 bool FindEngineEntry(const std::string& input_method_id, |
113 ComponentExtensionIME* out_extension); | 114 ComponentExtensionIME* out_extension); |
114 | 115 |
115 bool IsInLoginLayoutWhitelist(const std::vector<std::string>& layouts); | 116 bool IsInLoginLayoutWhitelist(const std::vector<std::string>& layouts); |
116 | 117 |
117 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate_; | 118 std::unique_ptr<ComponentExtensionIMEManagerDelegate> delegate_; |
118 | 119 |
119 // The map of extension_id to ComponentExtensionIME instance. | 120 // The map of extension_id to ComponentExtensionIME instance. |
120 // It's filled by Initialize() method and never changed during runtime. | 121 // It's filled by Initialize() method and never changed during runtime. |
121 std::map<std::string, ComponentExtensionIME> component_extension_imes_; | 122 std::map<std::string, ComponentExtensionIME> component_extension_imes_; |
122 | 123 |
123 // For quick check the validity of a given input method id. | 124 // For quick check the validity of a given input method id. |
124 // It's filled by Initialize() method and never changed during runtime. | 125 // It's filled by Initialize() method and never changed during runtime. |
125 std::set<std::string> input_method_id_set_; | 126 std::set<std::string> input_method_id_set_; |
126 | 127 |
127 std::set<std::string> login_layout_set_; | 128 std::set<std::string> login_layout_set_; |
128 | 129 |
129 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManager); | 130 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManager); |
130 }; | 131 }; |
131 | 132 |
132 } // namespace chromeos | 133 } // namespace chromeos |
133 | 134 |
134 #endif // UI_BASE_IME_CHROMEOS_COMPONENT_EXTENSION_IME_MANAGER_H_ | 135 #endif // UI_BASE_IME_CHROMEOS_COMPONENT_EXTENSION_IME_MANAGER_H_ |
OLD | NEW |