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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 public: | 25 public: |
26 ComponentLoader(ExtensionServiceInterface* extension_service, | 26 ComponentLoader(ExtensionServiceInterface* extension_service, |
27 PrefService* prefs, | 27 PrefService* prefs, |
28 PrefService* local_state); | 28 PrefService* local_state); |
29 virtual ~ComponentLoader(); | 29 virtual ~ComponentLoader(); |
30 | 30 |
31 size_t registered_extensions_count() const { | 31 size_t registered_extensions_count() const { |
32 return component_extensions_.size(); | 32 return component_extensions_.size(); |
33 } | 33 } |
34 | 34 |
35 // Loads any registered component extensions. | 35 // Creates and loads all registered component extensions, including those with |
36 void LoadAll(); | 36 // background pages. |
| 37 void BulkLoadAll(); |
| 38 |
| 39 // Create all registered component extensions, loading those without |
| 40 // background pages and deferring others until a call to BulkLoadDeferred. |
| 41 void BulkLoadDeferBackgroundPages(); |
| 42 |
| 43 // Load component extensions deferred in the last call to |
| 44 // BulkLoadDeferBackgroundPages. |
| 45 void BulkLoadDeferred(); |
37 | 46 |
38 // Clear the list of all registered extensions and unloads them from the | 47 // Clear the list of all registered extensions and unloads them from the |
39 // extension service. | 48 // extension service. |
40 void RemoveAll(); | 49 void RemoveAll(); |
41 | 50 |
42 // Registers and possibly loads a component extension. If ExtensionService | 51 // Registers and possibly loads a component extension. If ExtensionService |
43 // has been initialized, the extension is loaded; otherwise, the load is | 52 // has been initialized, the extension is loaded; otherwise, the load is |
44 // deferred until LoadAll is called. The ID of the added extension is | 53 // deferred until LoadAll is called. The ID of the added extension is |
45 // returned. | 54 // returned. |
46 // | 55 // |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 FilePath root_directory; | 113 FilePath root_directory; |
105 | 114 |
106 // The component extension's ID. | 115 // The component extension's ID. |
107 std::string extension_id; | 116 std::string extension_id; |
108 }; | 117 }; |
109 | 118 |
110 std::string Add(const DictionaryValue* parsed_manifest, | 119 std::string Add(const DictionaryValue* parsed_manifest, |
111 const FilePath& root_directory); | 120 const FilePath& root_directory); |
112 | 121 |
113 // Loads a registered component extension. | 122 // Loads a registered component extension. |
114 const Extension* Load(const ComponentExtensionInfo& info); | 123 void Load(const ComponentExtensionInfo& info, |
| 124 bool defer_if_has_background_page); |
115 | 125 |
116 void AddDefaultComponentExtensionsWithBackgroundPages( | 126 void AddDefaultComponentExtensionsWithBackgroundPages( |
117 bool skip_session_components); | 127 bool skip_session_components); |
118 void AddFileManagerExtension(); | 128 void AddFileManagerExtension(); |
119 | 129 |
120 #if defined(OS_CHROMEOS) | 130 #if defined(OS_CHROMEOS) |
121 void AddGaiaAuthExtension(); | 131 void AddGaiaAuthExtension(); |
122 #endif | 132 #endif |
123 | 133 |
124 // Add the enterprise webstore extension, or reload it if already loaded. | 134 // Add the enterprise webstore extension, or reload it if already loaded. |
125 void AddOrReloadEnterpriseWebStore(); | 135 void AddOrReloadEnterpriseWebStore(); |
126 | 136 |
127 void AddChromeApp(); | 137 void AddChromeApp(); |
128 | 138 |
129 // Unloads |component| from the memory. | 139 // Unloads |component| from the memory. |
130 void UnloadComponent(ComponentExtensionInfo* component); | 140 void UnloadComponent(ComponentExtensionInfo* component); |
131 | 141 |
132 PrefService* prefs_; | 142 PrefService* prefs_; |
133 PrefService* local_state_; | 143 PrefService* local_state_; |
134 | 144 |
135 ExtensionServiceInterface* extension_service_; | 145 ExtensionServiceInterface* extension_service_; |
136 | 146 |
137 // List of registered component extensions (see Extension::Location). | 147 // List of registered component extensions (see Extension::Location). |
138 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; | 148 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; |
139 RegisteredComponentExtensions component_extensions_; | 149 RegisteredComponentExtensions component_extensions_; |
140 | 150 |
141 PrefChangeRegistrar pref_change_registrar_; | 151 PrefChangeRegistrar pref_change_registrar_; |
142 | 152 |
| 153 // Extensions with background pages deferred by LoadAll(true). |
| 154 typedef std::vector<scoped_refptr<const Extension> > DeferredAtLoadExtensions; |
| 155 DeferredAtLoadExtensions deferred_at_load_extensions; |
| 156 |
143 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); | 157 DISALLOW_COPY_AND_ASSIGN(ComponentLoader); |
144 }; | 158 }; |
145 | 159 |
146 } // namespace extensions | 160 } // namespace extensions |
147 | 161 |
148 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | 162 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
OLD | NEW |