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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_IMP L_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_IMP L_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_IMP L_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_IMP L_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 virtual ~ComponentExtensionIMEManagerImpl(); | 25 virtual ~ComponentExtensionIMEManagerImpl(); |
26 | 26 |
27 // ComponentExtensionIMEManagerDelegate overrides: | 27 // ComponentExtensionIMEManagerDelegate overrides: |
28 virtual std::vector<ComponentExtensionIME> ListIME() OVERRIDE; | 28 virtual std::vector<ComponentExtensionIME> ListIME() OVERRIDE; |
29 virtual bool Load(const std::string& extension_id, | 29 virtual bool Load(const std::string& extension_id, |
30 const std::string& manifest, | 30 const std::string& manifest, |
31 const base::FilePath& file_path) OVERRIDE; | 31 const base::FilePath& file_path) OVERRIDE; |
32 virtual void Unload(const std::string& extension_id, | 32 virtual void Unload(const std::string& extension_id, |
33 const base::FilePath& file_path) OVERRIDE; | 33 const base::FilePath& file_path) OVERRIDE; |
34 | 34 |
35 // Loads extension list and reads their manifest file. After finished | |
36 // initialization, |callback| will be called on original thread. | |
37 void InitializeAsync(const base::Closure& callback); | |
38 | |
39 // Returns true if this class is initialized and ready to use, otherwise | |
40 // returns false. | |
41 bool IsInitialized(); | |
42 | |
43 private: | 35 private: |
44 // Reads component extensions and extract their localized information: name, | 36 // Reads component extensions and extract their localized information: name, |
45 // description and ime id. This function fills them into |out_imes|. This | 37 // description and ime id. This function fills them into |out_imes|. This |
46 // function must be called on file thread. | 38 // function must be called on file thread. |
47 static void ReadComponentExtensionsInfo( | 39 static void ReadComponentExtensionsInfo( |
48 std::vector<ComponentExtensionIME>* out_imes); | 40 std::vector<ComponentExtensionIME>* out_imes); |
49 | 41 |
50 // This function is called on UI thread after ReadComponentExtensionsInfo | |
51 // function is finished. No need to release |result|. | |
52 void OnReadComponentExtensionsInfo(std::vector<ComponentExtensionIME>* result, | |
53 const base::Closure& callback); | |
54 | |
55 // Reads manifest.json file in |file_path|. This function must be called on | 42 // Reads manifest.json file in |file_path|. This function must be called on |
56 // file thread. | 43 // file thread. |
Alexander Alekseev
2014/07/14 14:07:29
Is this comment still valid: "must be called on fi
Shu Chen
2014/07/14 15:07:21
Done.
| |
57 static scoped_ptr<base::DictionaryValue> GetManifest( | 44 static scoped_ptr<base::DictionaryValue> GetManifest( |
58 const base::FilePath& file_path); | 45 const std::string& manifest_string); |
59 | 46 |
60 // Reads extension information: description, option page. This function | 47 // Reads extension information: description, option page. This function |
61 // returns true on success, otherwise returns false. This function must be | 48 // returns true on success, otherwise returns false. This function must be |
62 // called on file thread. | 49 // called on file thread. |
63 static bool ReadExtensionInfo(const base::DictionaryValue& manifest, | 50 static bool ReadExtensionInfo(const base::DictionaryValue& manifest, |
64 const std::string& extension_id, | 51 const std::string& extension_id, |
65 ComponentExtensionIME* out); | 52 ComponentExtensionIME* out); |
66 | 53 |
67 // Reads each engine component in |dict|. |dict| is given by GetList with | 54 // Reads each engine component in |dict|. |dict| is given by GetList with |
68 // kInputComponents key from manifest. This function returns true on success, | 55 // kInputComponents key from manifest. This function returns true on success, |
69 // otherwise retrun false. This function must be called on FILE thread. | 56 // otherwise retrun false. This function must be called on FILE thread. |
70 static bool ReadEngineComponent( | 57 static bool ReadEngineComponent( |
71 const ComponentExtensionIME& component_extension, | 58 const ComponentExtensionIME& component_extension, |
72 const base::DictionaryValue& dict, | 59 const base::DictionaryValue& dict, |
73 ComponentExtensionEngine* out); | 60 ComponentExtensionEngine* out); |
74 | 61 |
75 // True if initialized. | |
76 bool is_initialized_; | |
77 | |
78 // The list of component extension IME. | 62 // The list of component extension IME. |
79 std::vector<ComponentExtensionIME> component_extension_list_; | 63 std::vector<ComponentExtensionIME> component_extension_list_; |
80 | 64 |
81 // For checking the function should be called on UI thread. | 65 // For checking the function should be called on UI thread. |
82 base::ThreadChecker thread_checker_; | 66 base::ThreadChecker thread_checker_; |
83 base::WeakPtrFactory<ComponentExtensionIMEManagerImpl> weak_ptr_factory_; | 67 base::WeakPtrFactory<ComponentExtensionIMEManagerImpl> weak_ptr_factory_; |
84 | 68 |
85 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManagerImpl); | 69 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManagerImpl); |
86 }; | 70 }; |
87 | 71 |
88 } // namespace chromeos | 72 } // namespace chromeos |
89 | 73 |
90 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_ IMPL_H_ | 74 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_ IMPL_H_ |
91 | 75 |
OLD | NEW |