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/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/prefs/public/pref_change_registrar.h" | 13 #include "base/prefs/public/pref_change_registrar.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 | 15 |
| 16 class ExtensionServiceInterface; | 16 class ExtensionServiceInterface; |
| 17 class PrefService; | 17 class PrefServiceSimple; |
| 18 class PrefServiceSyncable; | |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 | 21 |
| 21 class Extension; | 22 class Extension; |
| 22 | 23 |
| 23 // For registering, loading, and unloading component extensions. | 24 // For registering, loading, and unloading component extensions. |
| 24 class ComponentLoader { | 25 class ComponentLoader { |
| 25 public: | 26 public: |
| 26 ComponentLoader(ExtensionServiceInterface* extension_service, | 27 ComponentLoader(ExtensionServiceInterface* extension_service, |
| 27 PrefService* prefs, | 28 PrefServiceSyncable* prefs, |
| 28 PrefService* local_state); | 29 PrefServiceSimple* local_state); |
|
Mattias Nissler (ping if slow)
2012/12/19 19:50:22
Can we use PrefServiceBase* for these two?
Jói
2012/12/20 16:30:31
Done.
| |
| 29 virtual ~ComponentLoader(); | 30 virtual ~ComponentLoader(); |
| 30 | 31 |
| 31 size_t registered_extensions_count() const { | 32 size_t registered_extensions_count() const { |
| 32 return component_extensions_.size(); | 33 return component_extensions_.size(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 // Loads any registered component extensions. | 36 // Loads any registered component extensions. |
| 36 void LoadAll(); | 37 void LoadAll(); |
| 37 | 38 |
| 38 // Clear the list of all registered extensions and unloads them from the | 39 // Clear the list of all registered extensions and unloads them from the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 // Call this during test setup to load component extensions that have | 73 // Call this during test setup to load component extensions that have |
| 73 // background pages for testing, which could otherwise interfere with tests. | 74 // background pages for testing, which could otherwise interfere with tests. |
| 74 static void EnableBackgroundExtensionsForTesting(); | 75 static void EnableBackgroundExtensionsForTesting(); |
| 75 | 76 |
| 76 // Adds the default component extensions. If |skip_session_components| | 77 // Adds the default component extensions. If |skip_session_components| |
| 77 // the loader will skip loading component extensions that weren't supposed to | 78 // the loader will skip loading component extensions that weren't supposed to |
| 78 // be loaded unless we are in signed user session (ChromeOS). For all other | 79 // be loaded unless we are in signed user session (ChromeOS). For all other |
| 79 // platforms this |skip_session_components| is expected to be unset. | 80 // platforms this |skip_session_components| is expected to be unset. |
| 80 void AddDefaultComponentExtensions(bool skip_session_components); | 81 void AddDefaultComponentExtensions(bool skip_session_components); |
| 81 | 82 |
| 82 static void RegisterUserPrefs(PrefService* prefs); | 83 static void RegisterUserPrefs(PrefServiceSyncable* prefs); |
| 83 | 84 |
| 84 // 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 |
| 85 // if the result is not a DictionaryValue. | 86 // if the result is not a DictionaryValue. |
| 86 DictionaryValue* ParseManifest(const std::string& manifest_contents) const; | 87 DictionaryValue* ParseManifest(const std::string& manifest_contents) const; |
| 87 | 88 |
| 88 // Clear the list of registered extensions. | 89 // Clear the list of registered extensions. |
| 89 void ClearAllRegistered(); | 90 void ClearAllRegistered(); |
| 90 | 91 |
| 91 // Reloads a registered component extension. | 92 // Reloads a registered component extension. |
| 92 void Reload(const std::string& extension_id); | 93 void Reload(const std::string& extension_id); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 122 #endif | 123 #endif |
| 123 | 124 |
| 124 // Add the enterprise webstore extension, or reload it if already loaded. | 125 // Add the enterprise webstore extension, or reload it if already loaded. |
| 125 void AddOrReloadEnterpriseWebStore(); | 126 void AddOrReloadEnterpriseWebStore(); |
| 126 | 127 |
| 127 void AddChromeApp(); | 128 void AddChromeApp(); |
| 128 | 129 |
| 129 // Unloads |component| from the memory. | 130 // Unloads |component| from the memory. |
| 130 void UnloadComponent(ComponentExtensionInfo* component); | 131 void UnloadComponent(ComponentExtensionInfo* component); |
| 131 | 132 |
| 132 PrefService* prefs_; | 133 PrefServiceSyncable* prefs_; |
| 133 PrefService* local_state_; | 134 PrefServiceSimple* local_state_; |
| 134 | 135 |
| 135 ExtensionServiceInterface* extension_service_; | 136 ExtensionServiceInterface* extension_service_; |
| 136 | 137 |
| 137 // List of registered component extensions (see Extension::Location). | 138 // List of registered component extensions (see Extension::Location). |
| 138 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; | 139 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; |
| 139 RegisteredComponentExtensions component_extensions_; | 140 RegisteredComponentExtensions component_extensions_; |
| 140 | 141 |
| 141 PrefChangeRegistrar pref_change_registrar_; | 142 PrefChangeRegistrar pref_change_registrar_; |
| 142 | 143 |
| 143 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); | 144 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 } // namespace extensions | 147 } // namespace extensions |
| 147 | 148 |
| 148 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | 149 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
| OLD | NEW |