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 <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 class BrowserEventRouter; | 59 class BrowserEventRouter; |
60 class ComponentLoader; | 60 class ComponentLoader; |
61 class ContentSettingsStore; | 61 class ContentSettingsStore; |
62 class CrxInstaller; | 62 class CrxInstaller; |
63 class ExtensionActionStorageManager; | 63 class ExtensionActionStorageManager; |
64 class ExtensionSyncData; | 64 class ExtensionSyncData; |
65 class ExtensionSystem; | 65 class ExtensionSystem; |
66 class ExtensionUpdater; | 66 class ExtensionUpdater; |
67 class PendingExtensionManager; | 67 class PendingExtensionManager; |
68 class SettingsFrontend; | 68 class SettingsFrontend; |
69 } // namespace extensions | 69 } // namespace extensions |
70 | 70 |
71 namespace syncer { | 71 namespace syncer { |
72 class SyncErrorFactory; | 72 class SyncErrorFactory; |
73 } | 73 } |
74 | 74 |
75 // This is an interface class to encapsulate the dependencies that | 75 // This is an interface class to encapsulate the dependencies that |
76 // various classes have on ExtensionService. This allows easy mocking. | 76 // various classes have on ExtensionService. This allows easy mocking. |
77 class ExtensionServiceInterface : public syncer::SyncableService { | 77 class ExtensionServiceInterface : public syncer::SyncableService { |
78 public: | 78 public: |
79 virtual ~ExtensionServiceInterface() {} | 79 virtual ~ExtensionServiceInterface() {} |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 // Adds |extension| to this ExtensionService and notifies observers that the | 397 // Adds |extension| to this ExtensionService and notifies observers that the |
398 // extensions have been loaded. | 398 // extensions have been loaded. |
399 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE; | 399 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE; |
400 | 400 |
401 // Check if we have preferences for the component extension and, if not or if | 401 // Check if we have preferences for the component extension and, if not or if |
402 // the stored version differs, install the extension (without requirements | 402 // the stored version differs, install the extension (without requirements |
403 // checking) before calling AddExtension. | 403 // checking) before calling AddExtension. |
404 virtual void AddComponentExtension(const extensions::Extension* extension) | 404 virtual void AddComponentExtension(const extensions::Extension* extension) |
405 OVERRIDE; | 405 OVERRIDE; |
406 | 406 |
| 407 enum ImportStatus { |
| 408 IMPORT_STATUS_OK, |
| 409 IMPORT_STATUS_UNSATISFIED, |
| 410 IMPORT_STATUS_UNRECOVERABLE |
| 411 }; |
| 412 |
| 413 // Checks an extension's shared module imports to see if they are satisfied. |
| 414 // If they are not, this function adds the dependencies to the pending install |
| 415 // list if |extension| came from the webstore. |
| 416 ImportStatus SatisfyImports(const extensions::Extension* extension); |
| 417 |
| 418 // Returns a set of extensions that import a given extension. |
| 419 scoped_ptr<const ExtensionSet> GetDependentExtensions( |
| 420 const extensions::Extension* extension); |
| 421 |
| 422 // Uninstalls shared modules that were only referenced by |extension|. |
| 423 void PruneSharedModulesOnUninstall(const extensions::Extension* extension); |
| 424 |
407 // Informs the service that an extension's files are in place for loading. | 425 // Informs the service that an extension's files are in place for loading. |
408 // | 426 // |
409 // Please make sure the Blacklist is checked some time before calling this | 427 // Please make sure the Blacklist is checked some time before calling this |
410 // method. | 428 // method. |
411 void OnExtensionInstalled( | 429 void OnExtensionInstalled( |
412 const extensions::Extension* extension, | 430 const extensions::Extension* extension, |
413 const syncer::StringOrdinal& page_ordinal, | 431 const syncer::StringOrdinal& page_ordinal, |
414 bool has_requirement_errors, | 432 bool has_requirement_errors, |
415 bool wait_for_idle); | 433 bool wait_for_idle); |
416 | 434 |
| 435 // Checks for delayed installation for all pending installs. |
| 436 void MaybeFinishDelayedInstallations(); |
| 437 |
417 // Similar to FinishInstallation, but first checks if there still is an update | 438 // Similar to FinishInstallation, but first checks if there still is an update |
418 // pending for the extension, and makes sure the extension is still idle. | 439 // pending for the extension, and makes sure the extension is still idle. |
419 void MaybeFinishDelayedInstallation(const std::string& extension_id); | 440 void MaybeFinishDelayedInstallation(const std::string& extension_id); |
420 | 441 |
421 // Finishes installation of an update for an extension with the specified id, | 442 // Finishes installation of an update for an extension with the specified id, |
422 // when installation of that extension was previously delayed because the | 443 // when installation of that extension was previously delayed because the |
423 // extension was in use. | 444 // extension was in use. |
424 virtual void FinishDelayedInstallation( | 445 virtual void FinishDelayedInstallation( |
425 const std::string& extension_id) OVERRIDE; | 446 const std::string& extension_id) OVERRIDE; |
426 | 447 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 void OnNeedsToGarbageCollectIsolatedStorage(); | 775 void OnNeedsToGarbageCollectIsolatedStorage(); |
755 | 776 |
756 // extensions::Blacklist::Observer implementation. | 777 // extensions::Blacklist::Observer implementation. |
757 virtual void OnBlacklistUpdated() OVERRIDE; | 778 virtual void OnBlacklistUpdated() OVERRIDE; |
758 | 779 |
759 // Manages the blacklisted extensions, intended as callback from | 780 // Manages the blacklisted extensions, intended as callback from |
760 // Blacklist::GetBlacklistedIDs. | 781 // Blacklist::GetBlacklistedIDs. |
761 void ManageBlacklist(const std::set<std::string>& old_blacklisted_ids, | 782 void ManageBlacklist(const std::set<std::string>& old_blacklisted_ids, |
762 const std::set<std::string>& new_blacklisted_ids); | 783 const std::set<std::string>& new_blacklisted_ids); |
763 | 784 |
764 // Controls if installs are delayed. See comment for |installs_delayed_|. | 785 // Controls if installs are delayed. See comment for |
765 void set_installs_delayed(bool value) { installs_delayed_ = value; } | 786 // |installs_delayed_for_gc_|. |
766 bool installs_delayed() const { return installs_delayed_; } | 787 void set_installs_delayed_for_gc(bool value) { |
| 788 installs_delayed_for_gc_ = value; |
| 789 } |
| 790 bool installs_delayed_for_gc() const { return installs_delayed_for_gc_; } |
767 | 791 |
768 // The normal profile associated with this ExtensionService. | 792 // The normal profile associated with this ExtensionService. |
769 Profile* profile_; | 793 Profile* profile_; |
770 | 794 |
771 // The ExtensionSystem for the profile above. | 795 // The ExtensionSystem for the profile above. |
772 extensions::ExtensionSystem* system_; | 796 extensions::ExtensionSystem* system_; |
773 | 797 |
774 // Preferences for the owning profile. | 798 // Preferences for the owning profile. |
775 extensions::ExtensionPrefs* extension_prefs_; | 799 extensions::ExtensionPrefs* extension_prefs_; |
776 | 800 |
(...skipping 11 matching lines...) Expand all Loading... |
788 | 812 |
789 // The list of installed extensions that have been terminated. | 813 // The list of installed extensions that have been terminated. |
790 ExtensionSet terminated_extensions_; | 814 ExtensionSet terminated_extensions_; |
791 | 815 |
792 // The list of installed extensions that have been blacklisted. Generally | 816 // The list of installed extensions that have been blacklisted. Generally |
793 // these shouldn't be considered as installed by the extension platform: we | 817 // these shouldn't be considered as installed by the extension platform: we |
794 // only keep them around so that if extensions are blacklisted by mistake | 818 // only keep them around so that if extensions are blacklisted by mistake |
795 // they can easily be un-blacklisted. | 819 // they can easily be un-blacklisted. |
796 ExtensionSet blacklisted_extensions_; | 820 ExtensionSet blacklisted_extensions_; |
797 | 821 |
798 // The list of extension updates that have had their installs delayed because | 822 // The list of extension installs delayed for various reasons. The reason |
799 // they are waiting for idle. | 823 // for delayed install is stored in ExtensionPrefs. |
800 ExtensionSet delayed_updates_for_idle_; | |
801 | |
802 // The list of extension installs delayed by |installs_delayed_|. | |
803 // This is a disjoint set from |delayed_updates_for_idle_|. Extensions in | |
804 // the |delayed_installs_| do not need to wait for idle. | |
805 ExtensionSet delayed_installs_; | 824 ExtensionSet delayed_installs_; |
806 | 825 |
807 // Hold the set of pending extensions. | 826 // Hold the set of pending extensions. |
808 extensions::PendingExtensionManager pending_extension_manager_; | 827 extensions::PendingExtensionManager pending_extension_manager_; |
809 | 828 |
810 // The map of extension IDs to their runtime data. | 829 // The map of extension IDs to their runtime data. |
811 ExtensionRuntimeDataMap extension_runtime_data_; | 830 ExtensionRuntimeDataMap extension_runtime_data_; |
812 | 831 |
813 // The full path to the directory where extensions are installed. | 832 // The full path to the directory where extensions are installed. |
814 base::FilePath install_directory_; | 833 base::FilePath install_directory_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 // has to wait for the external providers. Used in | 894 // has to wait for the external providers. Used in |
876 // OnAllExternalProvidersReady() to determine if an update check is needed to | 895 // OnAllExternalProvidersReady() to determine if an update check is needed to |
877 // install pending extensions. | 896 // install pending extensions. |
878 bool update_once_all_providers_are_ready_; | 897 bool update_once_all_providers_are_ready_; |
879 | 898 |
880 // Set when the browser is terminating. Prevents us from installing or | 899 // Set when the browser is terminating. Prevents us from installing or |
881 // updating additional extensions and allows in-progress installations to | 900 // updating additional extensions and allows in-progress installations to |
882 // decide to abort. | 901 // decide to abort. |
883 bool browser_terminating_; | 902 bool browser_terminating_; |
884 | 903 |
885 // Set to true to delay all new extension installations. Acts as a lock | 904 // Set to true to delay all new extension installations. Acts as a lock to |
886 // to allow background processing of tasks such as garbage collection of | 905 // allow background processing of garbage collection of on-disk state without |
887 // on-disk state without needing to worry about race conditions caused | 906 // needing to worry about race conditions caused by extension installation and |
888 // by extension installation and reinstallation. | 907 // reinstallation. |
889 bool installs_delayed_; | 908 bool installs_delayed_for_gc_; |
890 | 909 |
891 // Set to true if this is the first time this ExtensionService has run. | 910 // Set to true if this is the first time this ExtensionService has run. |
892 // Used for specially handling external extensions that are installed the | 911 // Used for specially handling external extensions that are installed the |
893 // first time. | 912 // first time. |
894 bool is_first_run_; | 913 bool is_first_run_; |
895 | 914 |
896 extensions::AppSyncBundle app_sync_bundle_; | 915 extensions::AppSyncBundle app_sync_bundle_; |
897 extensions::ExtensionSyncBundle extension_sync_bundle_; | 916 extensions::ExtensionSyncBundle extension_sync_bundle_; |
898 | 917 |
899 extensions::ProcessMap process_map_; | 918 extensions::ProcessMap process_map_; |
(...skipping 10 matching lines...) Expand all Loading... |
910 ObserverList<extensions::UpdateObserver, true> update_observers_; | 929 ObserverList<extensions::UpdateObserver, true> update_observers_; |
911 | 930 |
912 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 931 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
913 InstallAppsWithUnlimtedStorage); | 932 InstallAppsWithUnlimtedStorage); |
914 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 933 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
915 InstallAppsAndCheckStorageProtection); | 934 InstallAppsAndCheckStorageProtection); |
916 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 935 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
917 }; | 936 }; |
918 | 937 |
919 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 938 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |