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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/prefs/pref_change_registrar.h" | |
| 14 #include "base/values.h" | 13 #include "base/values.h" |
| 15 | 14 |
| 16 class ExtensionServiceInterface; | 15 class ExtensionServiceInterface; |
| 17 class PrefService; | 16 class PrefService; |
| 18 | 17 |
| 19 namespace user_prefs { | 18 namespace user_prefs { |
| 20 class PrefRegistrySyncable; | 19 class PrefRegistrySyncable; |
|
Joao da Silva
2013/05/16 08:27:35
nit: not used
Mattias Nissler (ping if slow)
2013/05/16 12:08:21
Done.
| |
| 21 } | 20 } |
| 22 | 21 |
| 23 namespace extensions { | 22 namespace extensions { |
| 24 | 23 |
| 25 class Extension; | 24 class Extension; |
| 26 | 25 |
| 27 // For registering, loading, and unloading component extensions. | 26 // For registering, loading, and unloading component extensions. |
| 28 class ComponentLoader { | 27 class ComponentLoader { |
| 29 public: | 28 public: |
| 30 ComponentLoader(ExtensionServiceInterface* extension_service, | 29 ComponentLoader(ExtensionServiceInterface* extension_service, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 // Call this during test setup to load component extensions that have | 75 // Call this during test setup to load component extensions that have |
| 77 // background pages for testing, which could otherwise interfere with tests. | 76 // background pages for testing, which could otherwise interfere with tests. |
| 78 static void EnableBackgroundExtensionsForTesting(); | 77 static void EnableBackgroundExtensionsForTesting(); |
| 79 | 78 |
| 80 // Adds the default component extensions. If |skip_session_components| | 79 // Adds the default component extensions. If |skip_session_components| |
| 81 // the loader will skip loading component extensions that weren't supposed to | 80 // the loader will skip loading component extensions that weren't supposed to |
| 82 // be loaded unless we are in signed user session (ChromeOS). For all other | 81 // be loaded unless we are in signed user session (ChromeOS). For all other |
| 83 // platforms this |skip_session_components| is expected to be unset. | 82 // platforms this |skip_session_components| is expected to be unset. |
| 84 void AddDefaultComponentExtensions(bool skip_session_components); | 83 void AddDefaultComponentExtensions(bool skip_session_components); |
| 85 | 84 |
| 86 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); | |
| 87 | |
| 88 // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if | 85 // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if |
| 89 // if the result is not a DictionaryValue. | 86 // if the result is not a DictionaryValue. |
| 90 DictionaryValue* ParseManifest(const std::string& manifest_contents) const; | 87 DictionaryValue* ParseManifest(const std::string& manifest_contents) const; |
| 91 | 88 |
| 92 // Clear the list of registered extensions. | 89 // Clear the list of registered extensions. |
| 93 void ClearAllRegistered(); | 90 void ClearAllRegistered(); |
| 94 | 91 |
| 95 // Reloads a registered component extension. | 92 // Reloads a registered component extension. |
| 96 void Reload(const std::string& extension_id); | 93 void Reload(const std::string& extension_id); |
| 97 | 94 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 115 const base::FilePath& root_directory); | 112 const base::FilePath& root_directory); |
| 116 | 113 |
| 117 // Loads a registered component extension. | 114 // Loads a registered component extension. |
| 118 void Load(const ComponentExtensionInfo& info); | 115 void Load(const ComponentExtensionInfo& info); |
| 119 | 116 |
| 120 void AddDefaultComponentExtensionsWithBackgroundPages( | 117 void AddDefaultComponentExtensionsWithBackgroundPages( |
| 121 bool skip_session_components); | 118 bool skip_session_components); |
| 122 void AddFileManagerExtension(); | 119 void AddFileManagerExtension(); |
| 123 void AddImageLoaderExtension(); | 120 void AddImageLoaderExtension(); |
| 124 | 121 |
| 125 // Add the enterprise webstore extension, or reload it if already loaded. | |
| 126 void AddOrReloadEnterpriseWebStore(); | |
| 127 | |
| 128 void AddChromeApp(); | 122 void AddChromeApp(); |
| 129 void AddKeyboardApp(); | 123 void AddKeyboardApp(); |
| 130 | 124 |
| 131 // Unloads |component| from the memory. | 125 // Unloads |component| from the memory. |
| 132 void UnloadComponent(ComponentExtensionInfo* component); | 126 void UnloadComponent(ComponentExtensionInfo* component); |
| 133 | 127 |
| 134 PrefService* profile_prefs_; | 128 PrefService* profile_prefs_; |
| 135 PrefService* local_state_; | 129 PrefService* local_state_; |
| 136 | 130 |
| 137 ExtensionServiceInterface* extension_service_; | 131 ExtensionServiceInterface* extension_service_; |
| 138 | 132 |
| 139 // List of registered component extensions (see Manifest::Location). | 133 // List of registered component extensions (see Manifest::Location). |
| 140 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; | 134 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; |
| 141 RegisteredComponentExtensions component_extensions_; | 135 RegisteredComponentExtensions component_extensions_; |
| 142 | 136 |
| 143 PrefChangeRegistrar pref_change_registrar_; | |
| 144 | |
| 145 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); | 137 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); |
| 146 }; | 138 }; |
| 147 | 139 |
| 148 } // namespace extensions | 140 } // namespace extensions |
| 149 | 141 |
| 150 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | 142 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
| OLD | NEW |