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

Side by Side Diff: chrome/browser/extensions/component_loader.h

Issue 11014009: Beginnings of the script bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More minor cleanup Created 8 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 15 matching lines...) Expand all
26 public: 26 public:
27 ComponentLoader(ExtensionServiceInterface* extension_service, 27 ComponentLoader(ExtensionServiceInterface* extension_service,
28 PrefService* prefs, 28 PrefService* prefs,
29 PrefService* local_state); 29 PrefService* local_state);
30 virtual ~ComponentLoader(); 30 virtual ~ComponentLoader();
31 31
32 size_t registered_extensions_count() const { 32 size_t registered_extensions_count() const {
33 return component_extensions_.size(); 33 return component_extensions_.size();
34 } 34 }
35 35
36 const Extension* GetScriptBubble() const;
37
36 // Loads any registered component extensions. 38 // Loads any registered component extensions.
37 void LoadAll(); 39 void LoadAll();
38 40
39 // Registers and possibly loads a component extension. If ExtensionService 41 // Registers and possibly loads a component extension. If ExtensionService
40 // has been initialized, the extension is loaded; otherwise, the load is 42 // has been initialized, the extension is loaded; otherwise, the load is
41 // deferred until LoadAll is called. 43 // deferred until LoadAll is called.
Yoyo Zhou 2012/10/02 01:21:01 Should have a note about what it's returning.
Aaron Boodman 2012/10/02 01:42:22 Done with last patchset.
42 const Extension* Add(const std::string& manifest_contents, 44 std::string Add(const std::string& manifest_contents,
Jeffrey Yasskin 2012/10/02 00:26:31 Comment the meaning of the returned string, please
Aaron Boodman 2012/10/02 01:28:52 Done.
Aaron Boodman 2012/10/02 01:28:52 Done.
43 const FilePath& root_directory); 45 const FilePath& root_directory);
44 46
45 // Convenience method for registering a component extension by resource id. 47 // Convenience method for registering a component extension by resource id.
46 const Extension* Add(int manifest_resource_id, 48 std::string Add(int manifest_resource_id,
47 const FilePath& root_directory); 49 const FilePath& root_directory);
48 50
49 // Loads a component extension from file system. Replaces previously added 51 // Loads a component extension from file system. Replaces previously added
50 // extension with the same ID. 52 // extension with the same ID.
51 const Extension* AddOrReplace(const FilePath& path); 53 std::string AddOrReplace(const FilePath& path);
52 54
53 // Returns true if an extension with the specified id has been added. 55 // Returns true if an extension with the specified id has been added.
54 bool Exists(const std::string& id) const; 56 bool Exists(const std::string& id) const;
55 57
56 // Unloads a component extension and removes it from the list of component 58 // Unloads a component extension and removes it from the list of component
57 // extensions to be loaded. 59 // extensions to be loaded.
58 void Remove(const FilePath& root_directory); 60 void Remove(const FilePath& root_directory);
59 void Remove(const std::string& id); 61 void Remove(const std::string& id);
60 62
61 // Adds the default component extensions. 63 // Adds the default component extensions.
(...skipping 16 matching lines...) Expand all
78 // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if 80 // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if
79 // if the result is not a DictionaryValue. 81 // if the result is not a DictionaryValue.
80 DictionaryValue* ParseManifest(const std::string& manifest_contents) const; 82 DictionaryValue* ParseManifest(const std::string& manifest_contents) const;
81 83
82 // Clear the list of registered extensions. 84 // Clear the list of registered extensions.
83 void ClearAllRegistered(); 85 void ClearAllRegistered();
84 86
85 // Reloads a registered component extension. 87 // Reloads a registered component extension.
86 void Reload(const std::string& extension_id); 88 void Reload(const std::string& extension_id);
87 89
90 void AddScriptBubble();
Jeffrey Yasskin 2012/10/02 00:26:31 Comment what this function does, and possibly how
Yoyo Zhou 2012/10/02 01:21:01 This should be private.
Aaron Boodman 2012/10/02 01:28:52 Done.
Aaron Boodman 2012/10/02 01:42:22 It's called by the unit tests. This is necessary b
91
88 private: 92 private:
89 // Information about a registered component extension. 93 // Information about a registered component extension.
90 struct ComponentExtensionInfo { 94 struct ComponentExtensionInfo {
91 ComponentExtensionInfo(const DictionaryValue* manifest, 95 ComponentExtensionInfo(const DictionaryValue* manifest,
92 const FilePath& root_directory) 96 const FilePath& root_directory);
93 : manifest(manifest),
94 root_directory(root_directory) {
95 }
96 97
97 // The parsed contents of the extensions's manifest file. 98 // The parsed contents of the extensions's manifest file.
98 const DictionaryValue* manifest; 99 const DictionaryValue* manifest;
99 100
100 // Directory where the extension is stored. 101 // Directory where the extension is stored.
101 FilePath root_directory; 102 FilePath root_directory;
103
104 // The component extension's ID.
105 std::string id;
Jeffrey Yasskin 2012/10/02 00:26:31 optional: I'd prefer "extension_id" here since it'
Aaron Boodman 2012/10/02 01:28:52 Done.
102 }; 106 };
103 107
104 const Extension* Add(const DictionaryValue* parsed_manifest, 108 std::string Add(const DictionaryValue* parsed_manifest,
105 const FilePath& root_directory); 109 const FilePath& root_directory);
106 110
107 // Loads a registered component extension. 111 // Loads a registered component extension.
108 const Extension* Load(const ComponentExtensionInfo& info); 112 const Extension* Load(const ComponentExtensionInfo& info);
109 113
110 void AddFileManagerExtension(); 114 void AddFileManagerExtension();
111 115
112 #if defined(OS_CHROMEOS) 116 #if defined(OS_CHROMEOS)
113 void AddGaiaAuthExtension(); 117 void AddGaiaAuthExtension();
114 #endif 118 #endif
115 119
116 // Add the enterprise webstore extension, or reload it if already loaded. 120 // Add the enterprise webstore extension, or reload it if already loaded.
117 void AddOrReloadEnterpriseWebStore(); 121 void AddOrReloadEnterpriseWebStore();
118 122
119 void AddChromeApp(); 123 void AddChromeApp();
120 124
121 // Determine the extension id.
122 static std::string GenerateId(const base::DictionaryValue* manifest);
123
124 PrefService* prefs_; 125 PrefService* prefs_;
125 PrefService* local_state_; 126 PrefService* local_state_;
126 127
127 ExtensionServiceInterface* extension_service_; 128 ExtensionServiceInterface* extension_service_;
128 129
129 // List of registered component extensions (see Extension::Location). 130 // List of registered component extensions (see Extension::Location).
130 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; 131 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions;
131 RegisteredComponentExtensions component_extensions_; 132 RegisteredComponentExtensions component_extensions_;
132 133
133 PrefChangeRegistrar pref_change_registrar_; 134 PrefChangeRegistrar pref_change_registrar_;
134 135
136 std::string script_bubble_id_;
137
135 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); 138 DISALLOW_COPY_AND_ASSIGN(ComponentLoader);
136 }; 139 };
137 140
138 } // namespace extensions 141 } // namespace extensions
139 142
140 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ 143 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698