OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "chrome/browser/extensions/extensions_quota_service.h" | 34 #include "chrome/browser/extensions/extensions_quota_service.h" |
35 #include "chrome/browser/extensions/external_extension_provider_interface.h" | 35 #include "chrome/browser/extensions/external_extension_provider_interface.h" |
36 #include "chrome/browser/extensions/pending_extension_manager.h" | 36 #include "chrome/browser/extensions/pending_extension_manager.h" |
37 #include "chrome/browser/extensions/process_map.h" | 37 #include "chrome/browser/extensions/process_map.h" |
38 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" | 38 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" |
39 #include "chrome/browser/prefs/pref_change_registrar.h" | 39 #include "chrome/browser/prefs/pref_change_registrar.h" |
40 #include "chrome/browser/sync/api/sync_change.h" | 40 #include "chrome/browser/sync/api/sync_change.h" |
41 #include "chrome/browser/sync/api/syncable_service.h" | 41 #include "chrome/browser/sync/api/syncable_service.h" |
42 #include "chrome/common/extensions/extension.h" | 42 #include "chrome/common/extensions/extension.h" |
43 #include "chrome/common/extensions/extension_constants.h" | 43 #include "chrome/common/extensions/extension_constants.h" |
| 44 #include "chrome/common/extensions/extension_set.h" |
44 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
45 #include "content/public/browser/notification_observer.h" | 46 #include "content/public/browser/notification_observer.h" |
46 #include "content/public/browser/notification_registrar.h" | 47 #include "content/public/browser/notification_registrar.h" |
47 | 48 |
48 class AppNotificationManager; | 49 class AppNotificationManager; |
49 class BookmarkExtensionEventRouter; | 50 class BookmarkExtensionEventRouter; |
50 class CrxInstaller; | 51 class CrxInstaller; |
51 class ExtensionBrowserEventRouter; | 52 class ExtensionBrowserEventRouter; |
52 class ExtensionContentSettingsStore; | 53 class ExtensionContentSettingsStore; |
53 class ExtensionCookiesEventRouter; | 54 class ExtensionCookiesEventRouter; |
(...skipping 25 matching lines...) Expand all Loading... |
79 // This is an interface class to encapsulate the dependencies that | 80 // This is an interface class to encapsulate the dependencies that |
80 // various classes have on ExtensionService. This allows easy mocking. | 81 // various classes have on ExtensionService. This allows easy mocking. |
81 class ExtensionServiceInterface : public SyncableService { | 82 class ExtensionServiceInterface : public SyncableService { |
82 public: | 83 public: |
83 // A function that returns true if the given extension should be | 84 // A function that returns true if the given extension should be |
84 // included and false if it should be filtered out. Identical to | 85 // included and false if it should be filtered out. Identical to |
85 // PendingExtensionInfo::ShouldAllowInstallPredicate. | 86 // PendingExtensionInfo::ShouldAllowInstallPredicate. |
86 typedef bool (*ExtensionFilter)(const Extension&); | 87 typedef bool (*ExtensionFilter)(const Extension&); |
87 | 88 |
88 virtual ~ExtensionServiceInterface() {} | 89 virtual ~ExtensionServiceInterface() {} |
89 virtual const ExtensionList* extensions() const = 0; | 90 virtual const ExtensionSet* extensions() const = 0; |
90 virtual PendingExtensionManager* pending_extension_manager() = 0; | 91 virtual PendingExtensionManager* pending_extension_manager() = 0; |
91 | 92 |
92 // Install an update. Return true if the install can be started. | 93 // Install an update. Return true if the install can be started. |
93 // Set out_crx_installer to the installer if one was started. | 94 // Set out_crx_installer to the installer if one was started. |
94 virtual bool UpdateExtension( | 95 virtual bool UpdateExtension( |
95 const std::string& id, | 96 const std::string& id, |
96 const FilePath& path, | 97 const FilePath& path, |
97 const GURL& download_url, | 98 const GURL& download_url, |
98 CrxInstaller** out_crx_installer) = 0; | 99 CrxInstaller** out_crx_installer) = 0; |
99 virtual const Extension* GetExtensionById(const std::string& id, | 100 virtual const Extension* GetExtensionById(const std::string& id, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 ExtensionService(Profile* profile, | 186 ExtensionService(Profile* profile, |
186 const CommandLine* command_line, | 187 const CommandLine* command_line, |
187 const FilePath& install_directory, | 188 const FilePath& install_directory, |
188 ExtensionPrefs* extension_prefs, | 189 ExtensionPrefs* extension_prefs, |
189 bool autoupdate_enabled, | 190 bool autoupdate_enabled, |
190 bool extensions_enabled); | 191 bool extensions_enabled); |
191 | 192 |
192 virtual ~ExtensionService(); | 193 virtual ~ExtensionService(); |
193 | 194 |
194 // Gets the list of currently installed extensions. | 195 // Gets the list of currently installed extensions. |
195 virtual const ExtensionList* extensions() const OVERRIDE; | 196 virtual const ExtensionSet* extensions() const OVERRIDE; |
196 const ExtensionList* disabled_extensions() const; | 197 const ExtensionSet* disabled_extensions() const; |
197 const ExtensionList* terminated_extensions() const; | 198 const ExtensionSet* terminated_extensions() const; |
198 | 199 |
199 // Gets the object managing the set of pending extensions. | 200 // Gets the object managing the set of pending extensions. |
200 virtual PendingExtensionManager* pending_extension_manager() OVERRIDE; | 201 virtual PendingExtensionManager* pending_extension_manager() OVERRIDE; |
201 | 202 |
202 const FilePath& install_directory() const { return install_directory_; } | 203 const FilePath& install_directory() const { return install_directory_; } |
203 | 204 |
204 AppsPromo* apps_promo() { return &apps_promo_; } | 205 AppsPromo* apps_promo() { return &apps_promo_; } |
205 | 206 |
206 extensions::ProcessMap* process_map() { return &process_map_; } | 207 extensions::ProcessMap* process_map() { return &process_map_; } |
207 | 208 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 std::vector<ExtensionSyncData> GetSyncDataList( | 616 std::vector<ExtensionSyncData> GetSyncDataList( |
616 const SyncBundle& bundle) const; | 617 const SyncBundle& bundle) const; |
617 | 618 |
618 // Gets the sync data for the given extension, assuming that the extension is | 619 // Gets the sync data for the given extension, assuming that the extension is |
619 // syncable. | 620 // syncable. |
620 ExtensionSyncData GetSyncData(const Extension& extension) const; | 621 ExtensionSyncData GetSyncData(const Extension& extension) const; |
621 | 622 |
622 // Appends sync data objects for every extension in |extensions| | 623 // Appends sync data objects for every extension in |extensions| |
623 // that passes |filter|. | 624 // that passes |filter|. |
624 void GetSyncDataListHelper( | 625 void GetSyncDataListHelper( |
625 const ExtensionList& extensions, | 626 const ExtensionSet& extensions, |
626 const SyncBundle& bundle, | 627 const SyncBundle& bundle, |
627 std::vector<ExtensionSyncData>* sync_data_list) const; | 628 std::vector<ExtensionSyncData>* sync_data_list) const; |
628 | 629 |
629 // Applies the change specified in an ExtensionSyncData to the current system. | 630 // Applies the change specified in an ExtensionSyncData to the current system. |
630 void ProcessExtensionSyncData( | 631 void ProcessExtensionSyncData( |
631 const ExtensionSyncData& extension_sync_data, | 632 const ExtensionSyncData& extension_sync_data, |
632 SyncBundle& bundle); | 633 SyncBundle& bundle); |
633 | 634 |
634 // Look up an extension by ID, optionally including either or both of enabled | 635 // Look up an extension by ID, optionally including either or both of enabled |
635 // and disabled extensions. | 636 // and disabled extensions. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 Profile* profile_; | 676 Profile* profile_; |
676 | 677 |
677 // Preferences for the owning profile (weak reference). | 678 // Preferences for the owning profile (weak reference). |
678 ExtensionPrefs* extension_prefs_; | 679 ExtensionPrefs* extension_prefs_; |
679 | 680 |
680 // Settings for the owning profile. | 681 // Settings for the owning profile. |
681 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; | 682 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; |
682 | 683 |
683 // The current list of installed extensions. | 684 // The current list of installed extensions. |
684 // TODO(aa): This should use chrome/common/extensions/extension_set.h. | 685 // TODO(aa): This should use chrome/common/extensions/extension_set.h. |
685 ExtensionList extensions_; | 686 ExtensionSet extensions_; |
686 | 687 |
687 // The list of installed extensions that have been disabled. | 688 // The list of installed extensions that have been disabled. |
688 ExtensionList disabled_extensions_; | 689 ExtensionSet disabled_extensions_; |
689 | 690 |
690 // The list of installed extensions that have been terminated. | 691 // The list of installed extensions that have been terminated. |
691 ExtensionList terminated_extensions_; | 692 ExtensionSet terminated_extensions_; |
692 | |
693 // Used to quickly check if an extension was terminated. | |
694 std::set<std::string> terminated_extension_ids_; | |
695 | 693 |
696 // Hold the set of pending extensions. | 694 // Hold the set of pending extensions. |
697 PendingExtensionManager pending_extension_manager_; | 695 PendingExtensionManager pending_extension_manager_; |
698 | 696 |
699 // The map of extension IDs to their runtime data. | 697 // The map of extension IDs to their runtime data. |
700 ExtensionRuntimeDataMap extension_runtime_data_; | 698 ExtensionRuntimeDataMap extension_runtime_data_; |
701 | 699 |
702 // Holds a map between renderer process IDs that are associated with an | 700 // Holds a map between renderer process IDs that are associated with an |
703 // installed app and their app. | 701 // installed app and their app. |
704 typedef std::map<int, scoped_refptr<const Extension> > InstalledAppMap; | 702 typedef std::map<int, scoped_refptr<const Extension> > InstalledAppMap; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 extensions::ProcessMap process_map_; | 809 extensions::ProcessMap process_map_; |
812 | 810 |
813 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 811 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
814 InstallAppsWithUnlimtedStorage); | 812 InstallAppsWithUnlimtedStorage); |
815 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 813 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
816 InstallAppsAndCheckStorageProtection); | 814 InstallAppsAndCheckStorageProtection); |
817 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 815 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
818 }; | 816 }; |
819 | 817 |
820 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 818 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |