| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 std::vector<ExtensionSyncData> GetSyncDataList( | 629 std::vector<ExtensionSyncData> GetSyncDataList( |
| 629 const SyncBundle& bundle) const; | 630 const SyncBundle& bundle) const; |
| 630 | 631 |
| 631 // Gets the sync data for the given extension, assuming that the extension is | 632 // Gets the sync data for the given extension, assuming that the extension is |
| 632 // syncable. | 633 // syncable. |
| 633 ExtensionSyncData GetSyncData(const Extension& extension) const; | 634 ExtensionSyncData GetSyncData(const Extension& extension) const; |
| 634 | 635 |
| 635 // Appends sync data objects for every extension in |extensions| | 636 // Appends sync data objects for every extension in |extensions| |
| 636 // that passes |filter|. | 637 // that passes |filter|. |
| 637 void GetSyncDataListHelper( | 638 void GetSyncDataListHelper( |
| 638 const ExtensionList& extensions, | 639 const ExtensionSet& extensions, |
| 639 const SyncBundle& bundle, | 640 const SyncBundle& bundle, |
| 640 std::vector<ExtensionSyncData>* sync_data_list) const; | 641 std::vector<ExtensionSyncData>* sync_data_list) const; |
| 641 | 642 |
| 642 // Applies the change specified in an ExtensionSyncData to the current system. | 643 // Applies the change specified in an ExtensionSyncData to the current system. |
| 643 void ProcessExtensionSyncData( | 644 void ProcessExtensionSyncData( |
| 644 const ExtensionSyncData& extension_sync_data, | 645 const ExtensionSyncData& extension_sync_data, |
| 645 SyncBundle& bundle); | 646 SyncBundle& bundle); |
| 646 | 647 |
| 647 // Look up an extension by ID, optionally including either or both of enabled | 648 // Look up an extension by ID, optionally including either or both of enabled |
| 648 // and disabled extensions. | 649 // and disabled extensions. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 Profile* profile_; | 689 Profile* profile_; |
| 689 | 690 |
| 690 // Preferences for the owning profile (weak reference). | 691 // Preferences for the owning profile (weak reference). |
| 691 ExtensionPrefs* extension_prefs_; | 692 ExtensionPrefs* extension_prefs_; |
| 692 | 693 |
| 693 // Settings for the owning profile. | 694 // Settings for the owning profile. |
| 694 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; | 695 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; |
| 695 | 696 |
| 696 // The current list of installed extensions. | 697 // The current list of installed extensions. |
| 697 // TODO(aa): This should use chrome/common/extensions/extension_set.h. | 698 // TODO(aa): This should use chrome/common/extensions/extension_set.h. |
| 698 ExtensionList extensions_; | 699 ExtensionSet extensions_; |
| 699 | 700 |
| 700 // The list of installed extensions that have been disabled. | 701 // The list of installed extensions that have been disabled. |
| 701 ExtensionList disabled_extensions_; | 702 ExtensionSet disabled_extensions_; |
| 702 | 703 |
| 703 // The list of installed extensions that have been terminated. | 704 // The list of installed extensions that have been terminated. |
| 704 ExtensionList terminated_extensions_; | 705 ExtensionSet terminated_extensions_; |
| 705 | |
| 706 // Used to quickly check if an extension was terminated. | |
| 707 std::set<std::string> terminated_extension_ids_; | |
| 708 | 706 |
| 709 // Hold the set of pending extensions. | 707 // Hold the set of pending extensions. |
| 710 PendingExtensionManager pending_extension_manager_; | 708 PendingExtensionManager pending_extension_manager_; |
| 711 | 709 |
| 712 // The map of extension IDs to their runtime data. | 710 // The map of extension IDs to their runtime data. |
| 713 ExtensionRuntimeDataMap extension_runtime_data_; | 711 ExtensionRuntimeDataMap extension_runtime_data_; |
| 714 | 712 |
| 715 // Holds a map between renderer process IDs that are associated with an | 713 // Holds a map between renderer process IDs that are associated with an |
| 716 // installed app and their app. | 714 // installed app and their app. |
| 717 typedef std::map<int, scoped_refptr<const Extension> > InstalledAppMap; | 715 typedef std::map<int, scoped_refptr<const Extension> > InstalledAppMap; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 extensions::ProcessMap process_map_; | 822 extensions::ProcessMap process_map_; |
| 825 | 823 |
| 826 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 824 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 827 InstallAppsWithUnlimtedStorage); | 825 InstallAppsWithUnlimtedStorage); |
| 828 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 826 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 829 InstallAppsAndCheckStorageProtection); | 827 InstallAppsAndCheckStorageProtection); |
| 830 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 828 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 831 }; | 829 }; |
| 832 | 830 |
| 833 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 831 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |