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/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/notification_registrar.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 MessageLoop; | 33 class MessageLoop; |
33 class PrefService; | 34 class PrefService; |
34 class Profile; | 35 class Profile; |
(...skipping 10 matching lines...) Expand all Loading... |
45 virtual const ExtensionList* extensions() const = 0; | 46 virtual const ExtensionList* extensions() const = 0; |
46 virtual void UpdateExtension(const std::string& id, const FilePath& path) = 0; | 47 virtual void UpdateExtension(const std::string& id, const FilePath& path) = 0; |
47 virtual Extension* GetExtensionById(const std::string& id) = 0; | 48 virtual Extension* GetExtensionById(const std::string& id) = 0; |
48 virtual void UpdateExtensionBlacklist( | 49 virtual void UpdateExtensionBlacklist( |
49 const std::vector<std::string>& blacklist) = 0; | 50 const std::vector<std::string>& blacklist) = 0; |
50 }; | 51 }; |
51 | 52 |
52 // Manages installed and running Chromium extensions. | 53 // Manages installed and running Chromium extensions. |
53 class ExtensionsService | 54 class ExtensionsService |
54 : public ExtensionUpdateService, | 55 : public ExtensionUpdateService, |
| 56 public NotificationObserver, |
55 public base::RefCountedThreadSafe<ExtensionsService> { | 57 public base::RefCountedThreadSafe<ExtensionsService> { |
56 public: | 58 public: |
57 | 59 |
58 // The name of the directory inside the profile where extensions are | 60 // The name of the directory inside the profile where extensions are |
59 // installed to. | 61 // installed to. |
60 static const char* kInstallDirectoryName; | 62 static const char* kInstallDirectoryName; |
61 | 63 |
62 // If auto-updates are turned on, default to running every 5 hours. | 64 // If auto-updates are turned on, default to running every 5 hours. |
63 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; | 65 static const int kDefaultUpdateFrequencySeconds = 60 * 60 * 5; |
64 | 66 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 204 } |
203 | 205 |
204 // Profile calls this when it is destroyed so that we know not to call it. | 206 // Profile calls this when it is destroyed so that we know not to call it. |
205 void ProfileDestroyed() { profile_ = NULL; } | 207 void ProfileDestroyed() { profile_ = NULL; } |
206 | 208 |
207 ExtensionPrefs* extension_prefs() { return extension_prefs_.get(); } | 209 ExtensionPrefs* extension_prefs() { return extension_prefs_.get(); } |
208 | 210 |
209 // Whether the extension service is ready. | 211 // Whether the extension service is ready. |
210 bool is_ready() { return ready_; } | 212 bool is_ready() { return ready_; } |
211 | 213 |
| 214 // NotificationObserver |
| 215 virtual void Observe(NotificationType type, |
| 216 const NotificationSource& source, |
| 217 const NotificationDetails& details); |
| 218 |
212 private: | 219 private: |
213 // Look up an extension by ID, optionally including either or both of enabled | 220 // Look up an extension by ID, optionally including either or both of enabled |
214 // and disabled extensions. | 221 // and disabled extensions. |
215 Extension* GetExtensionByIdInternal(const std::string& id, | 222 Extension* GetExtensionByIdInternal(const std::string& id, |
216 bool include_enabled, | 223 bool include_enabled, |
217 bool include_disabled); | 224 bool include_disabled); |
218 | 225 |
219 // The profile this ExtensionsService is part of. | 226 // The profile this ExtensionsService is part of. |
220 Profile* profile_; | 227 Profile* profile_; |
221 | 228 |
(...skipping 17 matching lines...) Expand all Loading... |
239 | 246 |
240 // Whether to notify users when they attempt to install an extension. | 247 // Whether to notify users when they attempt to install an extension. |
241 bool show_extensions_prompts_; | 248 bool show_extensions_prompts_; |
242 | 249 |
243 // The backend that will do IO on behalf of this instance. | 250 // The backend that will do IO on behalf of this instance. |
244 scoped_refptr<ExtensionsServiceBackend> backend_; | 251 scoped_refptr<ExtensionsServiceBackend> backend_; |
245 | 252 |
246 // Is the service ready to go? | 253 // Is the service ready to go? |
247 bool ready_; | 254 bool ready_; |
248 | 255 |
| 256 NotificationRegistrar registrar_; |
| 257 |
249 // Our extension updater, if updates are turned on. | 258 // Our extension updater, if updates are turned on. |
250 scoped_refptr<ExtensionUpdater> updater_; | 259 scoped_refptr<ExtensionUpdater> updater_; |
251 | 260 |
252 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); | 261 DISALLOW_COPY_AND_ASSIGN(ExtensionsService); |
253 }; | 262 }; |
254 | 263 |
255 // Implements IO for the ExtensionsService. | 264 // Implements IO for the ExtensionsService. |
256 // TODO(aa): This can probably move into the .cc file. | 265 // TODO(aa): This can probably move into the .cc file. |
257 class ExtensionsServiceBackend | 266 class ExtensionsServiceBackend |
258 : public base::RefCountedThreadSafe<ExtensionsServiceBackend>, | 267 : public base::RefCountedThreadSafe<ExtensionsServiceBackend>, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 372 |
364 // A map of all external extension providers. | 373 // A map of all external extension providers. |
365 typedef std::map<Extension::Location, | 374 typedef std::map<Extension::Location, |
366 linked_ptr<ExternalExtensionProvider> > ProviderMap; | 375 linked_ptr<ExternalExtensionProvider> > ProviderMap; |
367 ProviderMap external_extension_providers_; | 376 ProviderMap external_extension_providers_; |
368 | 377 |
369 DISALLOW_COPY_AND_ASSIGN(ExtensionsServiceBackend); | 378 DISALLOW_COPY_AND_ASSIGN(ExtensionsServiceBackend); |
370 }; | 379 }; |
371 | 380 |
372 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ | 381 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_SERVICE_H_ |
OLD | NEW |