OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_EXTENSIONS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/linked_ptr.h" | 15 #include "base/linked_ptr.h" |
16 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
17 #include "base/task.h" | 17 #include "base/task.h" |
18 #include "base/tuple.h" | 18 #include "base/tuple.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/extensions/extension_prefs.h" | 20 #include "chrome/browser/extensions/extension_prefs.h" |
21 #include "chrome/browser/extensions/extension_process_manager.h" | 21 #include "chrome/browser/extensions/extension_process_manager.h" |
22 #include "chrome/browser/extensions/external_extension_provider.h" | 22 #include "chrome/browser/extensions/external_extension_provider.h" |
23 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" | 23 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" |
| 24 #include "chrome/browser/privacy_blacklist/blacklist_manager.h" |
24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
25 | 26 |
26 class Browser; | 27 class Browser; |
27 class DictionaryValue; | 28 class DictionaryValue; |
28 class Extension; | 29 class Extension; |
29 class ExtensionsServiceBackend; | 30 class ExtensionsServiceBackend; |
30 class ExtensionUpdater; | 31 class ExtensionUpdater; |
31 class GURL; | 32 class GURL; |
32 class PrefService; | 33 class PrefService; |
33 class Profile; | 34 class Profile; |
(...skipping 10 matching lines...) Expand all Loading... |
44 virtual const ExtensionList* extensions() const = 0; | 45 virtual const ExtensionList* extensions() const = 0; |
45 virtual void UpdateExtension(const std::string& id, const FilePath& path) = 0; | 46 virtual void UpdateExtension(const std::string& id, const FilePath& path) = 0; |
46 virtual Extension* GetExtensionById(const std::string& id) = 0; | 47 virtual Extension* GetExtensionById(const std::string& id) = 0; |
47 virtual void UpdateExtensionBlacklist( | 48 virtual void UpdateExtensionBlacklist( |
48 const std::vector<std::string>& blacklist) = 0; | 49 const std::vector<std::string>& blacklist) = 0; |
49 }; | 50 }; |
50 | 51 |
51 // Manages installed and running Chromium extensions. | 52 // Manages installed and running Chromium extensions. |
52 class ExtensionsService | 53 class ExtensionsService |
53 : public ExtensionUpdateService, | 54 : public ExtensionUpdateService, |
| 55 public BlacklistPathProvider, |
54 public base::RefCountedThreadSafe<ExtensionsService> { | 56 public base::RefCountedThreadSafe<ExtensionsService> { |
55 public: | 57 public: |
56 | 58 |
57 // The name of the directory inside the profile where extensions are | 59 // The name of the directory inside the profile where extensions are |
58 // installed to. | 60 // installed to. |
59 static const char* kInstallDirectoryName; | 61 static const char* kInstallDirectoryName; |
60 | 62 |
61 // If auto-updates are turned on, default to running every 5 hours. | 63 // If auto-updates are turned on, default to running every 5 hours. |
62 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; | 64 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; |
63 | 65 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 bool extensions_enabled() { return extensions_enabled_; } | 196 bool extensions_enabled() { return extensions_enabled_; } |
195 | 197 |
196 void set_show_extensions_prompts(bool enabled) { | 198 void set_show_extensions_prompts(bool enabled) { |
197 show_extensions_prompts_ = enabled; | 199 show_extensions_prompts_ = enabled; |
198 } | 200 } |
199 | 201 |
200 bool show_extensions_prompts() { | 202 bool show_extensions_prompts() { |
201 return show_extensions_prompts_; | 203 return show_extensions_prompts_; |
202 } | 204 } |
203 | 205 |
| 206 Profile* profile() { return profile_; } |
| 207 |
204 // Profile calls this when it is destroyed so that we know not to call it. | 208 // Profile calls this when it is destroyed so that we know not to call it. |
205 void ProfileDestroyed() { profile_ = NULL; } | 209 void ProfileDestroyed() { profile_ = NULL; } |
206 | 210 |
207 ExtensionPrefs* extension_prefs() { return extension_prefs_.get(); } | 211 ExtensionPrefs* extension_prefs() { return extension_prefs_.get(); } |
208 | 212 |
209 // Whether the extension service is ready. | 213 // Whether the extension service is ready. |
210 bool is_ready() { return ready_; } | 214 bool is_ready() { return ready_; } |
211 | 215 |
212 // Note that this may return NULL if autoupdate is not turned on. | 216 // Note that this may return NULL if autoupdate is not turned on. |
213 ExtensionUpdater* updater() { return updater_.get(); } | 217 ExtensionUpdater* updater() { return updater_.get(); } |
214 | 218 |
215 // Notify the frontend that there was an error loading an extension. | 219 // Notify the frontend that there was an error loading an extension. |
216 // This method is public because ExtensionsServiceBackend can post to here. | 220 // This method is public because ExtensionsServiceBackend can post to here. |
217 void ReportExtensionLoadError(const FilePath& extension_path, | 221 void ReportExtensionLoadError(const FilePath& extension_path, |
218 const std::string& error, | 222 const std::string& error, |
219 NotificationType type, | 223 NotificationType type, |
220 bool be_noisy); | 224 bool be_noisy); |
221 | 225 |
| 226 // BlacklistPathProvider: |
| 227 virtual std::vector<FilePath> GetPersistentBlacklistPaths(); |
| 228 virtual std::vector<FilePath> GetTransientBlacklistPaths(); |
| 229 |
222 private: | 230 private: |
223 // Look up an extension by ID, optionally including either or both of enabled | 231 // Look up an extension by ID, optionally including either or both of enabled |
224 // and disabled extensions. | 232 // and disabled extensions. |
225 Extension* GetExtensionByIdInternal(const std::string& id, | 233 Extension* GetExtensionByIdInternal(const std::string& id, |
226 bool include_enabled, | 234 bool include_enabled, |
227 bool include_disabled); | 235 bool include_disabled); |
228 | 236 |
229 // Load a single extension from the prefs. This can be done on the UI thread | 237 // Load a single extension from the prefs. This can be done on the UI thread |
230 // because we don't touch the disk. | 238 // because we don't touch the disk. |
231 void LoadInstalledExtension( | 239 void LoadInstalledExtension( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 369 |
362 // A map of all external extension providers. | 370 // A map of all external extension providers. |
363 typedef std::map<Extension::Location, | 371 typedef std::map<Extension::Location, |
364 linked_ptr<ExternalExtensionProvider> > ProviderMap; | 372 linked_ptr<ExternalExtensionProvider> > ProviderMap; |
365 ProviderMap external_extension_providers_; | 373 ProviderMap external_extension_providers_; |
366 | 374 |
367 DISALLOW_COPY_AND_ASSIGN(ExtensionsServiceBackend); | 375 DISALLOW_COPY_AND_ASSIGN(ExtensionsServiceBackend); |
368 }; | 376 }; |
369 | 377 |
370 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 378 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
OLD | NEW |