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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 }; | 318 }; |
319 | 319 |
320 // Look up an extension by ID, selecting which sets to look in: | 320 // Look up an extension by ID, selecting which sets to look in: |
321 // * extensions() --> INCLUDE_ENABLED | 321 // * extensions() --> INCLUDE_ENABLED |
322 // * disabled_extensions() --> INCLUDE_DISABLED | 322 // * disabled_extensions() --> INCLUDE_DISABLED |
323 // * terminated_extensions() --> INCLUDE_TERMINATED | 323 // * terminated_extensions() --> INCLUDE_TERMINATED |
324 // * blacklisted_extensions() --> INCLUDE_BLACKLISTED | 324 // * blacklisted_extensions() --> INCLUDE_BLACKLISTED |
325 const extensions::Extension* GetExtensionById(const std::string& id, | 325 const extensions::Extension* GetExtensionById(const std::string& id, |
326 int include_mask) const; | 326 int include_mask) const; |
327 | 327 |
| 328 // Returns the site of the given |extension_id|. Suitable for use with |
| 329 // BrowserContext::GetStoragePartitionForSite(). |
| 330 GURL GetSiteForExtensionId(const std::string& extension_id); |
| 331 |
328 // Looks up a terminated (crashed) extension by ID. | 332 // Looks up a terminated (crashed) extension by ID. |
329 const extensions::Extension* | 333 const extensions::Extension* |
330 GetTerminatedExtension(const std::string& id) const; | 334 GetTerminatedExtension(const std::string& id) const; |
331 | 335 |
332 // Looks up an extension by ID, regardless of whether it's enabled, | 336 // Looks up an extension by ID, regardless of whether it's enabled, |
333 // disabled, blacklisted, or terminated. | 337 // disabled, blacklisted, or terminated. |
334 virtual const extensions::Extension* GetInstalledExtension( | 338 virtual const extensions::Extension* GetInstalledExtension( |
335 const std::string& id) const OVERRIDE; | 339 const std::string& id) const OVERRIDE; |
336 | 340 |
337 // Updates a currently-installed extension with the contents from | 341 // Updates a currently-installed extension with the contents from |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 void TrackTerminatedExtension(const extensions::Extension* extension); | 777 void TrackTerminatedExtension(const extensions::Extension* extension); |
774 | 778 |
775 // Removes the extension with the given id from the list of | 779 // Removes the extension with the given id from the list of |
776 // terminated extensions if it is there. | 780 // terminated extensions if it is there. |
777 void UntrackTerminatedExtension(const std::string& id); | 781 void UntrackTerminatedExtension(const std::string& id); |
778 | 782 |
779 // Update preferences for a new or updated extension; notify observers that | 783 // Update preferences for a new or updated extension; notify observers that |
780 // the extension is installed, e.g., to update event handlers on background | 784 // the extension is installed, e.g., to update event handlers on background |
781 // pages; and perform other extension install tasks before calling | 785 // pages; and perform other extension install tasks before calling |
782 // AddExtension. | 786 // AddExtension. |
783 void AddNewOrUpdatedExtension( | 787 void AddNewOrUpdatedExtension(const extensions::Extension* extension, |
784 const extensions::Extension* extension, | 788 extensions::Extension::State initial_state, |
785 const syncer::StringOrdinal& page_ordinal, | 789 const syncer::StringOrdinal& page_ordinal); |
786 extensions::Extension::State initial_state); | |
787 | 790 |
788 // Handles sending notification that |extension| was loaded. | 791 // Handles sending notification that |extension| was loaded. |
789 void NotifyExtensionLoaded(const extensions::Extension* extension); | 792 void NotifyExtensionLoaded(const extensions::Extension* extension); |
790 | 793 |
791 // Handles sending notification that |extension| was unloaded. | 794 // Handles sending notification that |extension| was unloaded. |
792 void NotifyExtensionUnloaded(const extensions::Extension* extension, | 795 void NotifyExtensionUnloaded(const extensions::Extension* extension, |
793 extension_misc::UnloadedExtensionReason reason); | 796 extension_misc::UnloadedExtensionReason reason); |
794 | 797 |
795 // Common helper to finish installing the given extension. | 798 // Common helper to finish installing the given extension. |
796 void FinishInstallation(const extensions::Extension* extension); | 799 void FinishInstallation(const extensions::Extension* extension); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 | 843 |
841 // Helper to determine if an extension is idle, and it should be safe | 844 // Helper to determine if an extension is idle, and it should be safe |
842 // to update the extension. | 845 // to update the extension. |
843 bool IsExtensionIdle(const std::string& extension_id) const; | 846 bool IsExtensionIdle(const std::string& extension_id) const; |
844 | 847 |
845 // Helper to determine if updating an extensions should proceed immediately, | 848 // Helper to determine if updating an extensions should proceed immediately, |
846 // or if we should delay the update until further notice. | 849 // or if we should delay the update until further notice. |
847 bool ShouldDelayExtensionUpdate(const std::string& extension_id, | 850 bool ShouldDelayExtensionUpdate(const std::string& extension_id, |
848 bool wait_for_idle) const; | 851 bool wait_for_idle) const; |
849 | 852 |
| 853 // Helper to search storage directories for extensions with isolated storage |
| 854 // that have been orphaned by an uninstall. |
| 855 void GarbageCollectIsolatedStorage(); |
| 856 void OnGarbageCollectIsolatedStorageFinished(); |
| 857 void OnNeedsToGarbageCollectIsolatedStorage(); |
| 858 |
850 // extensions::Blacklist::Observer implementation. | 859 // extensions::Blacklist::Observer implementation. |
851 virtual void OnBlacklistUpdated() OVERRIDE; | 860 virtual void OnBlacklistUpdated() OVERRIDE; |
852 | 861 |
853 // Manages the blacklisted extensions, intended as callback from | 862 // Manages the blacklisted extensions, intended as callback from |
854 // Blacklist::GetBlacklistedIDs. | 863 // Blacklist::GetBlacklistedIDs. |
855 void ManageBlacklist(const std::set<std::string>& old_blacklisted_ids, | 864 void ManageBlacklist(const std::set<std::string>& old_blacklisted_ids, |
856 const std::set<std::string>& new_blacklisted_ids); | 865 const std::set<std::string>& new_blacklisted_ids); |
857 | 866 |
| 867 // Controls if installs are delayed. See comment for |installs_delayed_|. |
| 868 void set_installs_delayed(bool value) { installs_delayed_ = value; } |
| 869 bool installs_delayed() const { return installs_delayed_; } |
| 870 |
858 // The normal profile associated with this ExtensionService. | 871 // The normal profile associated with this ExtensionService. |
859 Profile* profile_; | 872 Profile* profile_; |
860 | 873 |
861 // The ExtensionSystem for the profile above. | 874 // The ExtensionSystem for the profile above. |
862 extensions::ExtensionSystem* system_; | 875 extensions::ExtensionSystem* system_; |
863 | 876 |
864 // Preferences for the owning profile. | 877 // Preferences for the owning profile. |
865 extensions::ExtensionPrefs* extension_prefs_; | 878 extensions::ExtensionPrefs* extension_prefs_; |
866 | 879 |
867 // Blacklist for the owning profile. | 880 // Blacklist for the owning profile. |
(...skipping 10 matching lines...) Expand all Loading... |
878 | 891 |
879 // The list of installed extensions that have been terminated. | 892 // The list of installed extensions that have been terminated. |
880 ExtensionSet terminated_extensions_; | 893 ExtensionSet terminated_extensions_; |
881 | 894 |
882 // The list of installed extensions that have been blacklisted. Generally | 895 // The list of installed extensions that have been blacklisted. Generally |
883 // these shouldn't be considered as installed by the extension platform: we | 896 // these shouldn't be considered as installed by the extension platform: we |
884 // only keep them around so that if extensions are blacklisted by mistake | 897 // only keep them around so that if extensions are blacklisted by mistake |
885 // they can easily be un-blacklisted. | 898 // they can easily be un-blacklisted. |
886 ExtensionSet blacklisted_extensions_; | 899 ExtensionSet blacklisted_extensions_; |
887 | 900 |
888 // The list of extension updates that are waiting to be installed. | 901 // The list of extension updates that have had their installs delayed because |
889 ExtensionSet pending_extension_updates_; | 902 // they are waiting for idle. |
| 903 ExtensionSet delayed_updates_for_idle_; |
| 904 |
| 905 // The list of extension installs delayed by |installs_delayed_|. |
| 906 // This is a disjoint set from |delayed_updates_for_idle_|. Extensions in |
| 907 // the |delayed_installs_| do not need to wait for idle. |
| 908 ExtensionSet delayed_installs_; |
890 | 909 |
891 // Hold the set of pending extensions. | 910 // Hold the set of pending extensions. |
892 extensions::PendingExtensionManager pending_extension_manager_; | 911 extensions::PendingExtensionManager pending_extension_manager_; |
893 | 912 |
894 // The map of extension IDs to their runtime data. | 913 // The map of extension IDs to their runtime data. |
895 ExtensionRuntimeDataMap extension_runtime_data_; | 914 ExtensionRuntimeDataMap extension_runtime_data_; |
896 | 915 |
897 // The full path to the directory where extensions are installed. | 916 // The full path to the directory where extensions are installed. |
898 FilePath install_directory_; | 917 FilePath install_directory_; |
899 | 918 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 // has to wait for the external providers. Used in | 1012 // has to wait for the external providers. Used in |
994 // OnAllExternalProvidersReady() to determine if an update check is needed to | 1013 // OnAllExternalProvidersReady() to determine if an update check is needed to |
995 // install pending extensions. | 1014 // install pending extensions. |
996 bool update_once_all_providers_are_ready_; | 1015 bool update_once_all_providers_are_ready_; |
997 | 1016 |
998 // Set when the browser is terminating. Prevents us from installing or | 1017 // Set when the browser is terminating. Prevents us from installing or |
999 // updating additional extensions and allows in-progress installations to | 1018 // updating additional extensions and allows in-progress installations to |
1000 // decide to abort. | 1019 // decide to abort. |
1001 bool browser_terminating_; | 1020 bool browser_terminating_; |
1002 | 1021 |
| 1022 // Set to true to delay all new extension installations. Acts as a lock |
| 1023 // to allow background processing of tasks such as garbage collection of |
| 1024 // on-disk state without needing to worry about race conditions caused |
| 1025 // by extension installation and reinstallation. |
| 1026 bool installs_delayed_; |
| 1027 |
1003 // Whether any extension should be considered for wipeout. | 1028 // Whether any extension should be considered for wipeout. |
1004 bool wipeout_is_active_; | 1029 bool wipeout_is_active_; |
1005 | 1030 |
1006 NaClModuleInfoList nacl_module_list_; | 1031 NaClModuleInfoList nacl_module_list_; |
1007 | 1032 |
1008 extensions::AppSyncBundle app_sync_bundle_; | 1033 extensions::AppSyncBundle app_sync_bundle_; |
1009 extensions::ExtensionSyncBundle extension_sync_bundle_; | 1034 extensions::ExtensionSyncBundle extension_sync_bundle_; |
1010 | 1035 |
1011 extensions::ProcessMap process_map_; | 1036 extensions::ProcessMap process_map_; |
1012 | 1037 |
1013 extensions::AppShortcutManager app_shortcut_manager_; | 1038 extensions::AppShortcutManager app_shortcut_manager_; |
1014 | 1039 |
1015 scoped_ptr<ExtensionErrorUI> extension_error_ui_; | 1040 scoped_ptr<ExtensionErrorUI> extension_error_ui_; |
1016 // Sequenced task runner for extension related file operations. | 1041 // Sequenced task runner for extension related file operations. |
1017 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 1042 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
1018 | 1043 |
1019 #if defined(ENABLE_EXTENSIONS) | 1044 #if defined(ENABLE_EXTENSIONS) |
1020 scoped_ptr<extensions::ExtensionActionStorageManager> | 1045 scoped_ptr<extensions::ExtensionActionStorageManager> |
1021 extension_action_storage_manager_; | 1046 extension_action_storage_manager_; |
1022 #endif | 1047 #endif |
1023 | 1048 |
1024 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 1049 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
1025 InstallAppsWithUnlimtedStorage); | 1050 InstallAppsWithUnlimtedStorage); |
1026 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 1051 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
1027 InstallAppsAndCheckStorageProtection); | 1052 InstallAppsAndCheckStorageProtection); |
1028 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 1053 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
1029 }; | 1054 }; |
1030 | 1055 |
1031 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 1056 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
OLD | NEW |