Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1009)

Unified Diff: chrome/browser/extensions/component_loader.h

Issue 8477005: Add policies to specify an enterprise web store. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasse. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698