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_EXTENSION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "chrome/browser/extensions/menu_manager.h" | 31 #include "chrome/browser/extensions/menu_manager.h" |
32 #include "chrome/browser/extensions/pending_extension_manager.h" | 32 #include "chrome/browser/extensions/pending_extension_manager.h" |
33 #include "chrome/browser/extensions/process_map.h" | 33 #include "chrome/browser/extensions/process_map.h" |
34 #include "chrome/browser/extensions/update_observer.h" | 34 #include "chrome/browser/extensions/update_observer.h" |
35 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
36 #include "chrome/common/extensions/extension_constants.h" | 36 #include "chrome/common/extensions/extension_constants.h" |
37 #include "chrome/common/extensions/extension_set.h" | 37 #include "chrome/common/extensions/extension_set.h" |
38 #include "chrome/common/extensions/manifest.h" | 38 #include "chrome/common/extensions/manifest.h" |
39 #include "content/public/browser/notification_observer.h" | 39 #include "content/public/browser/notification_observer.h" |
40 #include "content/public/browser/notification_registrar.h" | 40 #include "content/public/browser/notification_registrar.h" |
41 #include "extensions/common/async_event.h" | |
41 #include "sync/api/string_ordinal.h" | 42 #include "sync/api/string_ordinal.h" |
42 #include "sync/api/sync_change.h" | 43 #include "sync/api/sync_change.h" |
43 #include "sync/api/syncable_service.h" | 44 #include "sync/api/syncable_service.h" |
44 | 45 |
45 class CommandLine; | 46 class CommandLine; |
46 class ExtensionErrorUI; | 47 class ExtensionErrorUI; |
47 class ExtensionSyncData; | 48 class ExtensionSyncData; |
48 class ExtensionToolbarModel; | 49 class ExtensionToolbarModel; |
49 class GURL; | 50 class GURL; |
50 class Profile; | 51 class Profile; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 virtual void AddComponentExtension( | 125 virtual void AddComponentExtension( |
125 const extensions::Extension* extension) = 0; | 126 const extensions::Extension* extension) = 0; |
126 | 127 |
127 virtual void UnloadExtension( | 128 virtual void UnloadExtension( |
128 const std::string& extension_id, | 129 const std::string& extension_id, |
129 extension_misc::UnloadedExtensionReason reason) = 0; | 130 extension_misc::UnloadedExtensionReason reason) = 0; |
130 | 131 |
131 virtual void SyncExtensionChangeIfNeeded( | 132 virtual void SyncExtensionChangeIfNeeded( |
132 const extensions::Extension& extension) = 0; | 133 const extensions::Extension& extension) = 0; |
133 | 134 |
134 virtual bool is_ready() = 0; | 135 // Whether the extension service is ready. |
136 bool is_ready() const { return ready_.has_happened(); } | |
137 const extensions::AsyncEvent& ready() { return ready_; } | |
135 | 138 |
136 // Returns task runner for crx installation file I/O operations. | 139 // Returns task runner for crx installation file I/O operations. |
137 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; | 140 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; |
141 | |
142 protected: | |
143 // Record that Init() has been called, and chrome::EXTENSIONS_READY | |
144 // has fired. | |
145 extensions::AsyncEvent ready_; | |
Devlin
2013/05/15 00:21:16
I might suggest renaming ready_... Maybe on_ready_
Jeffrey Yasskin
2013/05/15 03:07:18
What's your reasoning behind that? We have a bunch
| |
138 }; | 146 }; |
139 | 147 |
140 // Manages installed and running Chromium extensions. | 148 // Manages installed and running Chromium extensions. |
141 class ExtensionService | 149 class ExtensionService |
142 : public ExtensionServiceInterface, | 150 : public ExtensionServiceInterface, |
143 public extensions::ExternalProviderInterface::VisitorInterface, | 151 public extensions::ExternalProviderInterface::VisitorInterface, |
144 public content::NotificationObserver, | 152 public content::NotificationObserver, |
145 public extensions::Blacklist::Observer { | 153 public extensions::Blacklist::Observer { |
146 public: | 154 public: |
147 // The name of the directory inside the profile where extensions are | 155 // The name of the directory inside the profile where extensions are |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 Profile* profile(); | 522 Profile* profile(); |
515 | 523 |
516 // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const, | 524 // TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const, |
517 // ExtensionPrefs* mutable_extension_prefs(). | 525 // ExtensionPrefs* mutable_extension_prefs(). |
518 extensions::ExtensionPrefs* extension_prefs(); | 526 extensions::ExtensionPrefs* extension_prefs(); |
519 | 527 |
520 extensions::SettingsFrontend* settings_frontend(); | 528 extensions::SettingsFrontend* settings_frontend(); |
521 | 529 |
522 extensions::ContentSettingsStore* GetContentSettingsStore(); | 530 extensions::ContentSettingsStore* GetContentSettingsStore(); |
523 | 531 |
524 // Whether the extension service is ready. | |
525 virtual bool is_ready() OVERRIDE; | |
526 | |
527 virtual base::SequencedTaskRunner* GetFileTaskRunner() OVERRIDE; | 532 virtual base::SequencedTaskRunner* GetFileTaskRunner() OVERRIDE; |
528 | 533 |
529 extensions::ComponentLoader* component_loader() { | 534 extensions::ComponentLoader* component_loader() { |
530 return component_loader_.get(); | 535 return component_loader_.get(); |
531 } | 536 } |
532 | 537 |
533 // Note that this may return NULL if autoupdate is not turned on. | 538 // Note that this may return NULL if autoupdate is not turned on. |
534 extensions::ExtensionUpdater* updater(); | 539 extensions::ExtensionUpdater* updater(); |
535 | 540 |
536 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; } | 541 ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; } |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
896 // Whether to notify users when they attempt to install an extension. | 901 // Whether to notify users when they attempt to install an extension. |
897 bool show_extensions_prompts_; | 902 bool show_extensions_prompts_; |
898 | 903 |
899 // Whether to delay installing of extension updates until the extension is | 904 // Whether to delay installing of extension updates until the extension is |
900 // idle. | 905 // idle. |
901 bool install_updates_when_idle_; | 906 bool install_updates_when_idle_; |
902 | 907 |
903 // Used by dispatchers to limit API quota for individual extensions. | 908 // Used by dispatchers to limit API quota for individual extensions. |
904 ExtensionsQuotaService quota_service_; | 909 ExtensionsQuotaService quota_service_; |
905 | 910 |
906 // Record that Init() has been called, and chrome::EXTENSIONS_READY | |
907 // has fired. | |
908 bool ready_; | |
909 | |
910 // Our extension updater, if updates are turned on. | 911 // Our extension updater, if updates are turned on. |
911 scoped_ptr<extensions::ExtensionUpdater> updater_; | 912 scoped_ptr<extensions::ExtensionUpdater> updater_; |
912 | 913 |
913 // The model that tracks extensions with BrowserAction buttons. | 914 // The model that tracks extensions with BrowserAction buttons. |
914 ExtensionToolbarModel toolbar_model_; | 915 ExtensionToolbarModel toolbar_model_; |
915 | 916 |
916 // Map unloaded extensions' ids to their paths. When a temporarily loaded | 917 // Map unloaded extensions' ids to their paths. When a temporarily loaded |
917 // extension is unloaded, we lose the information about it and don't have | 918 // extension is unloaded, we lose the information about it and don't have |
918 // any in the extension preferences file. | 919 // any in the extension preferences file. |
919 typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap; | 920 typedef std::map<std::string, base::FilePath> UnloadedExtensionPathMap; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1001 ObserverList<extensions::UpdateObserver, true> update_observers_; | 1002 ObserverList<extensions::UpdateObserver, true> update_observers_; |
1002 | 1003 |
1003 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 1004 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
1004 InstallAppsWithUnlimtedStorage); | 1005 InstallAppsWithUnlimtedStorage); |
1005 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 1006 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
1006 InstallAppsAndCheckStorageProtection); | 1007 InstallAppsAndCheckStorageProtection); |
1007 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 1008 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
1008 }; | 1009 }; |
1009 | 1010 |
1010 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 1011 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |