| 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_EXTENSIONS_COMPONENT_LOADER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 const base::FilePath& root_directory); | 59 const base::FilePath& root_directory); |
| 60 | 60 |
| 61 // Convenience method for registering a component extension by resource id. | 61 // Convenience method for registering a component extension by resource id. |
| 62 std::string Add(int manifest_resource_id, | 62 std::string Add(int manifest_resource_id, |
| 63 const base::FilePath& root_directory); | 63 const base::FilePath& root_directory); |
| 64 | 64 |
| 65 // Loads a component extension from file system. Replaces previously added | 65 // Loads a component extension from file system. Replaces previously added |
| 66 // extension with the same ID. | 66 // extension with the same ID. |
| 67 std::string AddOrReplace(const base::FilePath& path); | 67 std::string AddOrReplace(const base::FilePath& path); |
| 68 | 68 |
| 69 // Returns the extension ID of a component extension specified by resource | |
| 70 // id of its manifest file. | |
| 71 std::string GetExtensionID(int manifest_resource_id, | |
| 72 const base::FilePath& root_directory); | |
| 73 | |
| 74 // Returns true if an extension with the specified id has been added. | 69 // Returns true if an extension with the specified id has been added. |
| 75 bool Exists(const std::string& id) const; | 70 bool Exists(const std::string& id) const; |
| 76 | 71 |
| 77 // Unloads a component extension and removes it from the list of component | 72 // Unloads a component extension and removes it from the list of component |
| 78 // extensions to be loaded. | 73 // extensions to be loaded. |
| 79 void Remove(const base::FilePath& root_directory); | 74 void Remove(const base::FilePath& root_directory); |
| 80 void Remove(const std::string& id); | 75 void Remove(const std::string& id); |
| 81 | 76 |
| 82 // Call this during test setup to load component extensions that have | 77 // Call this during test setup to load component extensions that have |
| 83 // background pages for testing, which could otherwise interfere with tests. | 78 // background pages for testing, which could otherwise interfere with tests. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 113 | 108 |
| 114 void set_ignore_whitelist_for_testing(bool value) { | 109 void set_ignore_whitelist_for_testing(bool value) { |
| 115 ignore_whitelist_for_testing_ = value; | 110 ignore_whitelist_for_testing_ = value; |
| 116 } | 111 } |
| 117 | 112 |
| 118 private: | 113 private: |
| 119 FRIEND_TEST_ALL_PREFIXES(ComponentLoaderTest, ParseManifest); | 114 FRIEND_TEST_ALL_PREFIXES(ComponentLoaderTest, ParseManifest); |
| 120 | 115 |
| 121 // Information about a registered component extension. | 116 // Information about a registered component extension. |
| 122 struct ComponentExtensionInfo { | 117 struct ComponentExtensionInfo { |
| 123 ComponentExtensionInfo(const base::DictionaryValue* manifest, | 118 ComponentExtensionInfo( |
| 124 const base::FilePath& root_directory); | 119 std::unique_ptr<base::DictionaryValue> manifest_param, |
| 120 const base::FilePath& root_directory); |
| 121 ~ComponentExtensionInfo(); |
| 122 |
| 123 ComponentExtensionInfo(ComponentExtensionInfo&& other); |
| 124 ComponentExtensionInfo& operator=(ComponentExtensionInfo&& other); |
| 125 | 125 |
| 126 // The parsed contents of the extensions's manifest file. | 126 // The parsed contents of the extensions's manifest file. |
| 127 const base::DictionaryValue* manifest; | 127 std::unique_ptr<base::DictionaryValue> manifest; |
| 128 | 128 |
| 129 // Directory where the extension is stored. | 129 // Directory where the extension is stored. |
| 130 base::FilePath root_directory; | 130 base::FilePath root_directory; |
| 131 | 131 |
| 132 // The component extension's ID. | 132 // The component extension's ID. |
| 133 std::string extension_id; | 133 std::string extension_id; |
| 134 |
| 135 private: |
| 136 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionInfo); |
| 134 }; | 137 }; |
| 135 | 138 |
| 136 // Parses the given JSON manifest. Returns nullptr if it cannot be parsed or | 139 // Parses the given JSON manifest. Returns nullptr if it cannot be parsed or |
| 137 // if the result is not a DictionaryValue. | 140 // if the result is not a DictionaryValue. |
| 138 base::DictionaryValue* ParseManifest( | 141 std::unique_ptr<base::DictionaryValue> ParseManifest( |
| 139 base::StringPiece manifest_contents) const; | 142 base::StringPiece manifest_contents) const; |
| 140 | 143 |
| 141 std::string Add(const base::StringPiece& manifest_contents, | 144 std::string Add(const base::StringPiece& manifest_contents, |
| 142 const base::FilePath& root_directory, | 145 const base::FilePath& root_directory, |
| 143 bool skip_whitelist); | 146 bool skip_whitelist); |
| 144 std::string Add(const base::DictionaryValue* parsed_manifest, | 147 std::string Add(std::unique_ptr<base::DictionaryValue> parsed_manifest, |
| 145 const base::FilePath& root_directory, | 148 const base::FilePath& root_directory, |
| 146 bool skip_whitelist); | 149 bool skip_whitelist); |
| 147 | 150 |
| 148 // Loads a registered component extension. | 151 // Loads a registered component extension. |
| 149 void Load(const ComponentExtensionInfo& info); | 152 void Load(const ComponentExtensionInfo& info); |
| 150 | 153 |
| 151 void AddDefaultComponentExtensionsWithBackgroundPages( | 154 void AddDefaultComponentExtensionsWithBackgroundPages( |
| 152 bool skip_session_components); | 155 bool skip_session_components); |
| 153 void AddDefaultComponentExtensionsWithBackgroundPagesForKioskMode(); | 156 void AddDefaultComponentExtensionsWithBackgroundPagesForKioskMode(); |
| 154 void AddFileManagerExtension(); | 157 void AddFileManagerExtension(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 base::WeakPtrFactory<ComponentLoader> weak_factory_; | 208 base::WeakPtrFactory<ComponentLoader> weak_factory_; |
| 206 | 209 |
| 207 friend class TtsApiTest; | 210 friend class TtsApiTest; |
| 208 | 211 |
| 209 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); | 212 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); |
| 210 }; | 213 }; |
| 211 | 214 |
| 212 } // namespace extensions | 215 } // namespace extensions |
| 213 | 216 |
| 214 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | 217 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
| OLD | NEW |