Index: chrome/browser/extensions/component_loader.h |
diff --git a/chrome/browser/extensions/component_loader.h b/chrome/browser/extensions/component_loader.h |
index 6961098a73174cb5ae09c17f04d470b4fc9df541..8dca8a12e745afd681e4f5dc7bdeea283c797f9e 100644 |
--- a/chrome/browser/extensions/component_loader.h |
+++ b/chrome/browser/extensions/component_loader.h |
@@ -9,30 +9,41 @@ |
#include <string> |
#include "base/file_path.h" |
+#include "base/values.h" |
+#include "chrome/browser/prefs/pref_change_registrar.h" |
+#include "content/public/browser/notification_observer.h" |
+#include "testing/gtest/include/gtest/gtest_prod.h" |
class Extension; |
-class ExtensionService; |
+class ExtensionServiceInterface; |
+class PrefService; |
namespace extensions { |
// For registering, loading, and unloading component extensions. |
-class ComponentLoader { |
+class ComponentLoader : public content::NotificationObserver { |
public: |
- explicit ComponentLoader(ExtensionService* extension_service); |
+ ComponentLoader(ExtensionServiceInterface* extension_service, |
+ PrefService* prefs, |
+ PrefService* local_state); |
virtual ~ComponentLoader(); |
// Loads any registered component extensions. |
void LoadAll(); |
- // Loads and registers a component extension. If ExtensionService has been |
- // initialized, the extension is loaded; otherwise, the load is deferred |
- // until LoadAll is called. |
- const Extension* Add(const std::string& manifest, |
+ // Registers and possibly loads a component extension. If ExtensionService |
+ // has been initialized, the extension is loaded; otherwise, the load is |
+ // deferred until LoadAll is called. |
+ const Extension* Add(std::string& manifest_contents, |
+ const FilePath& root_directory); |
+ |
+ // Convenience method for registering a component extension by resource id. |
+ const Extension* Add(int manifest_resource_id, |
const FilePath& root_directory); |
// Unloads a component extension and removes it from the list of component |
// extensions to be loaded. |
- void Remove(const std::string& manifest_str); |
+ void Remove(const FilePath& root_directory); |
// Adds the default component extensions. |
// |
@@ -44,38 +55,59 @@ class ComponentLoader { |
// openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0 |
void AddDefaultComponentExtensions(); |
+ // content::NotificationObserver implementation |
+ virtual void Observe(int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) OVERRIDE; |
+ |
+ static void RegisterUserPrefs(PrefService* prefs); |
+ |
+ // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if |
+ // if the result is not a DictionaryValue. |
+ DictionaryValue* ParseManifest(const std::string& manifest_contents) const; |
+ |
+ // Clear the list of registered extensions. |
+ void ClearAllRegistered() { |
+ component_extensions_.clear(); |
+ } |
+ |
private: |
// Information about a registered component extension. |
struct ComponentExtensionInfo { |
- ComponentExtensionInfo(const std::string& manifest, |
+ ComponentExtensionInfo(const DictionaryValue* manifest, |
const FilePath& root_directory) |
: manifest(manifest), |
root_directory(root_directory) { |
} |
- bool Equals(const ComponentExtensionInfo& other) const; |
- |
- // The extension's manifest. This is required for component extensions so |
- // that ExtensionService doesn't need to go to disk to load them. |
- std::string manifest; |
+ // The parsed contents of the extensions's manifest file. |
+ const DictionaryValue* manifest; |
// Directory where the extension is stored. |
FilePath root_directory; |
}; |
+ const Extension* Add(const DictionaryValue* parsed_manifest, |
+ const FilePath& root_directory); |
+ |
// Loads a registered component extension. |
const Extension* Load(const ComponentExtensionInfo& info); |
- // Registers an extension to be loaded as a component extension. |
- void Register(const ComponentExtensionInfo& info) { |
- component_extensions_.push_back(info); |
- } |
+ void AddFileManagerExtension(); |
+ |
+ // Add the enterprise webstore extension, or reload it if already loaded. |
+ void AddOrReloadEnterpriseWebStore(); |
+ |
+ PrefService* prefs_; |
+ PrefService* local_state_; |
+ |
+ ExtensionServiceInterface* extension_service_; |
// List of registered component extensions (see Extension::Location). |
typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; |
RegisteredComponentExtensions component_extensions_; |
- ExtensionService* extension_service_; |
+ PrefChangeRegistrar pref_change_registrar_; |
}; |
} // namespace extensions |