Chromium Code Reviews| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/gtest_prod_util.h" | |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 19 #include "base/values.h" | 20 #include "base/values.h" |
| 20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 21 | 22 |
| 22 class ExtensionServiceInterface; | 23 class ExtensionServiceInterface; |
| 23 class PrefService; | 24 class PrefService; |
| 24 class Profile; | 25 class Profile; |
| 25 | 26 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 | 85 |
| 85 // Adds the default component extensions. If |skip_session_components| | 86 // Adds the default component extensions. If |skip_session_components| |
| 86 // the loader will skip loading component extensions that weren't supposed to | 87 // the loader will skip loading component extensions that weren't supposed to |
| 87 // be loaded unless we are in signed user session (ChromeOS). For all other | 88 // be loaded unless we are in signed user session (ChromeOS). For all other |
| 88 // platforms this |skip_session_components| is expected to be unset. | 89 // platforms this |skip_session_components| is expected to be unset. |
| 89 void AddDefaultComponentExtensions(bool skip_session_components); | 90 void AddDefaultComponentExtensions(bool skip_session_components); |
| 90 | 91 |
| 91 // Similar to above but adds the default component extensions for kiosk mode. | 92 // Similar to above but adds the default component extensions for kiosk mode. |
| 92 void AddDefaultComponentExtensionsForKioskMode(bool skip_session_components); | 93 void AddDefaultComponentExtensionsForKioskMode(bool skip_session_components); |
| 93 | 94 |
| 94 // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if | |
| 95 // if the result is not a DictionaryValue. | |
| 96 base::DictionaryValue* ParseManifest( | |
| 97 const std::string& manifest_contents) const; | |
| 98 | |
| 99 // Clear the list of registered extensions. | 95 // Clear the list of registered extensions. |
| 100 void ClearAllRegistered(); | 96 void ClearAllRegistered(); |
| 101 | 97 |
| 102 // Reloads a registered component extension. | 98 // Reloads a registered component extension. |
| 103 void Reload(const std::string& extension_id); | 99 void Reload(const std::string& extension_id); |
| 104 | 100 |
| 105 #if defined(OS_CHROMEOS) | 101 #if defined(OS_CHROMEOS) |
| 106 // Calls |done_cb|, if not a null callback, on success. | 102 // Calls |done_cb|, if not a null callback, on success. |
| 107 // NOTE: |done_cb| is not called if the component loader is shut down | 103 // NOTE: |done_cb| is not called if the component loader is shut down |
| 108 // during loading. | 104 // during loading. |
| 109 void AddChromeVoxExtension(const base::Closure& done_cb); | 105 void AddChromeVoxExtension(const base::Closure& done_cb); |
| 110 void AddChromeOsSpeechSynthesisExtension(); | 106 void AddChromeOsSpeechSynthesisExtension(); |
| 111 #endif | 107 #endif |
| 112 | 108 |
| 113 void set_ignore_whitelist_for_testing(bool value) { | 109 void set_ignore_whitelist_for_testing(bool value) { |
| 114 ignore_whitelist_for_testing_ = value; | 110 ignore_whitelist_for_testing_ = value; |
| 115 } | 111 } |
| 116 | 112 |
| 117 private: | 113 private: |
| 114 FRIEND_TEST_ALL_PREFIXES(ComponentLoaderTest, ParseManifest); | |
| 115 | |
| 118 // Information about a registered component extension. | 116 // Information about a registered component extension. |
| 119 struct ComponentExtensionInfo { | 117 struct ComponentExtensionInfo { |
| 120 ComponentExtensionInfo(const base::DictionaryValue* manifest, | 118 ComponentExtensionInfo(const base::DictionaryValue* manifest, |
| 121 const base::FilePath& root_directory); | 119 const base::FilePath& root_directory); |
| 122 | 120 |
| 123 // The parsed contents of the extensions's manifest file. | 121 // The parsed contents of the extensions's manifest file. |
| 124 const base::DictionaryValue* manifest; | 122 const base::DictionaryValue* manifest; |
| 125 | 123 |
| 126 // Directory where the extension is stored. | 124 // Directory where the extension is stored. |
| 127 base::FilePath root_directory; | 125 base::FilePath root_directory; |
| 128 | 126 |
| 129 // The component extension's ID. | 127 // The component extension's ID. |
| 130 std::string extension_id; | 128 std::string extension_id; |
| 131 }; | 129 }; |
| 132 | 130 |
| 131 // Parses the given JSON manifest. Returns NULL if it cannot be parsed, or if | |
|
Devlin
2016/07/30 01:00:23
s/NULL/null (or nullptr, if you prefer)
nitty nit
lazyboy
2016/07/30 01:45:35
Done.
| |
| 132 // if the result is not a DictionaryValue. | |
| 133 base::DictionaryValue* ParseManifest( | |
| 134 base::StringPiece manifest_contents) const; | |
| 135 | |
| 133 std::string Add(const std::string& manifest_contents, | 136 std::string Add(const std::string& manifest_contents, |
| 134 const base::FilePath& root_directory, | 137 const base::FilePath& root_directory, |
| 135 bool skip_whitelist); | 138 bool skip_whitelist); |
| 136 std::string Add(const base::DictionaryValue* parsed_manifest, | 139 std::string Add(const base::DictionaryValue* parsed_manifest, |
| 137 const base::FilePath& root_directory, | 140 const base::FilePath& root_directory, |
| 138 bool skip_whitelist); | 141 bool skip_whitelist); |
| 139 | 142 |
| 140 // Loads a registered component extension. | 143 // Loads a registered component extension. |
| 141 void Load(const ComponentExtensionInfo& info); | 144 void Load(const ComponentExtensionInfo& info); |
| 142 | 145 |
| (...skipping 62 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 |