Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1577)

Side by Side Diff: chrome/browser/extensions/extension_service.h

Issue 14973007: Auto-install/uninstall shared module dependencies for extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more feedback Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 } 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // Adds |extension| to this ExtensionService and notifies observers that the 403 // Adds |extension| to this ExtensionService and notifies observers that the
404 // extensions have been loaded. 404 // extensions have been loaded.
405 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE; 405 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE;
406 406
407 // Check if we have preferences for the component extension and, if not or if 407 // Check if we have preferences for the component extension and, if not or if
408 // the stored version differs, install the extension (without requirements 408 // the stored version differs, install the extension (without requirements
409 // checking) before calling AddExtension. 409 // checking) before calling AddExtension.
410 virtual void AddComponentExtension(const extensions::Extension* extension) 410 virtual void AddComponentExtension(const extensions::Extension* extension)
411 OVERRIDE; 411 OVERRIDE;
412 412
413 enum ImportStatus {
414 IMPORT_STATUS_OK,
415 IMPORT_STATUS_UNSATISFIED,
416 IMPORT_STATUS_UNRECOVERABLE
417 };
418
419 // Checks an extension's shared module imports to see if they are satisfied.
420 // If they are not, this function adds the dependencies to the pending install
421 // list if |extension| came from the webstore.
422 ImportStatus CheckImports(const extensions::Extension* extension);
asargent_no_longer_on_chrome 2013/06/13 23:43:55 optional naming suggestion: would "SatisfyImports"
elijahtaylor1 2013/06/19 00:26:58 Done.
423
424 // Returns a set of extensions that import a given extension.
425 scoped_ptr<const ExtensionSet> GetDependentExtensions(
426 const extensions::Extension* extension);
427
428 // Uninstalls shared modules that were only referenced by |extension|.
429 void PruneSharedModulesOnUninstall(const extensions::Extension* extension);
430
413 // Informs the service that an extension's files are in place for loading. 431 // Informs the service that an extension's files are in place for loading.
414 // 432 //
415 // Please make sure the Blacklist is checked some time before calling this 433 // Please make sure the Blacklist is checked some time before calling this
416 // method. 434 // method.
417 void OnExtensionInstalled( 435 void OnExtensionInstalled(
418 const extensions::Extension* extension, 436 const extensions::Extension* extension,
419 const syncer::StringOrdinal& page_ordinal, 437 const syncer::StringOrdinal& page_ordinal,
420 bool has_requirement_errors, 438 bool has_requirement_errors,
421 bool wait_for_idle); 439 bool wait_for_idle);
422 440
441 // Checks for delayed installation for all pending installs.
442 void MaybeFinishDelayedInstallations();
443
423 // Similar to FinishInstallation, but first checks if there still is an update 444 // Similar to FinishInstallation, but first checks if there still is an update
424 // pending for the extension, and makes sure the extension is still idle. 445 // pending for the extension, and makes sure the extension is still idle.
425 void MaybeFinishDelayedInstallation(const std::string& extension_id); 446 void MaybeFinishDelayedInstallation(const std::string& extension_id);
426 447
427 // Finishes installation of an update for an extension with the specified id, 448 // Finishes installation of an update for an extension with the specified id,
428 // when installation of that extension was previously delayed because the 449 // when installation of that extension was previously delayed because the
429 // extension was in use. 450 // extension was in use.
430 virtual void FinishDelayedInstallation( 451 virtual void FinishDelayedInstallation(
431 const std::string& extension_id) OVERRIDE; 452 const std::string& extension_id) OVERRIDE;
432 453
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 void OnNeedsToGarbageCollectIsolatedStorage(); 781 void OnNeedsToGarbageCollectIsolatedStorage();
761 782
762 // extensions::Blacklist::Observer implementation. 783 // extensions::Blacklist::Observer implementation.
763 virtual void OnBlacklistUpdated() OVERRIDE; 784 virtual void OnBlacklistUpdated() OVERRIDE;
764 785
765 // Manages the blacklisted extensions, intended as callback from 786 // Manages the blacklisted extensions, intended as callback from
766 // Blacklist::GetBlacklistedIDs. 787 // Blacklist::GetBlacklistedIDs.
767 void ManageBlacklist(const std::set<std::string>& old_blacklisted_ids, 788 void ManageBlacklist(const std::set<std::string>& old_blacklisted_ids,
768 const std::set<std::string>& new_blacklisted_ids); 789 const std::set<std::string>& new_blacklisted_ids);
769 790
770 // Controls if installs are delayed. See comment for |installs_delayed_|. 791 // Controls if installs are delayed. See comment for
771 void set_installs_delayed(bool value) { installs_delayed_ = value; } 792 // |installs_delayed_for_gc_|.
772 bool installs_delayed() const { return installs_delayed_; } 793 void set_installs_delayed_for_gc(bool value) {
794 installs_delayed_for_gc_ = value;
795 }
796 bool installs_delayed_for_gc() const { return installs_delayed_for_gc_; }
773 797
774 // The normal profile associated with this ExtensionService. 798 // The normal profile associated with this ExtensionService.
775 Profile* profile_; 799 Profile* profile_;
776 800
777 // The ExtensionSystem for the profile above. 801 // The ExtensionSystem for the profile above.
778 extensions::ExtensionSystem* system_; 802 extensions::ExtensionSystem* system_;
779 803
780 // Preferences for the owning profile. 804 // Preferences for the owning profile.
781 extensions::ExtensionPrefs* extension_prefs_; 805 extensions::ExtensionPrefs* extension_prefs_;
782 806
(...skipping 11 matching lines...) Expand all
794 818
795 // The list of installed extensions that have been terminated. 819 // The list of installed extensions that have been terminated.
796 ExtensionSet terminated_extensions_; 820 ExtensionSet terminated_extensions_;
797 821
798 // The list of installed extensions that have been blacklisted. Generally 822 // The list of installed extensions that have been blacklisted. Generally
799 // these shouldn't be considered as installed by the extension platform: we 823 // these shouldn't be considered as installed by the extension platform: we
800 // only keep them around so that if extensions are blacklisted by mistake 824 // only keep them around so that if extensions are blacklisted by mistake
801 // they can easily be un-blacklisted. 825 // they can easily be un-blacklisted.
802 ExtensionSet blacklisted_extensions_; 826 ExtensionSet blacklisted_extensions_;
803 827
804 // The list of extension updates that have had their installs delayed because 828 // The list of extension installs delayed for various reasons. The reason
805 // they are waiting for idle. 829 // for delayed install is stored in ExtensionPrefs.
806 ExtensionSet delayed_updates_for_idle_;
807
808 // The list of extension installs delayed by |installs_delayed_|.
809 // This is a disjoint set from |delayed_updates_for_idle_|. Extensions in
810 // the |delayed_installs_| do not need to wait for idle.
811 ExtensionSet delayed_installs_; 830 ExtensionSet delayed_installs_;
812 831
813 // Hold the set of pending extensions. 832 // Hold the set of pending extensions.
814 extensions::PendingExtensionManager pending_extension_manager_; 833 extensions::PendingExtensionManager pending_extension_manager_;
815 834
816 // The map of extension IDs to their runtime data. 835 // The map of extension IDs to their runtime data.
817 ExtensionRuntimeDataMap extension_runtime_data_; 836 ExtensionRuntimeDataMap extension_runtime_data_;
818 837
819 // The full path to the directory where extensions are installed. 838 // The full path to the directory where extensions are installed.
820 base::FilePath install_directory_; 839 base::FilePath install_directory_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 // has to wait for the external providers. Used in 900 // has to wait for the external providers. Used in
882 // OnAllExternalProvidersReady() to determine if an update check is needed to 901 // OnAllExternalProvidersReady() to determine if an update check is needed to
883 // install pending extensions. 902 // install pending extensions.
884 bool update_once_all_providers_are_ready_; 903 bool update_once_all_providers_are_ready_;
885 904
886 // Set when the browser is terminating. Prevents us from installing or 905 // Set when the browser is terminating. Prevents us from installing or
887 // updating additional extensions and allows in-progress installations to 906 // updating additional extensions and allows in-progress installations to
888 // decide to abort. 907 // decide to abort.
889 bool browser_terminating_; 908 bool browser_terminating_;
890 909
891 // Set to true to delay all new extension installations. Acts as a lock 910 // Set to true to delay all new extension installations. Acts as a lock to
892 // to allow background processing of tasks such as garbage collection of 911 // allow background processing of garbage collection of on-disk state without
893 // on-disk state without needing to worry about race conditions caused 912 // needing to worry about race conditions caused by extension installation and
894 // by extension installation and reinstallation. 913 // reinstallation.
895 bool installs_delayed_; 914 bool installs_delayed_for_gc_;
896 915
897 // Set to true if this is the first time this ExtensionService has run. 916 // Set to true if this is the first time this ExtensionService has run.
898 // Used for specially handling external extensions that are installed the 917 // Used for specially handling external extensions that are installed the
899 // first time. 918 // first time.
900 bool is_first_run_; 919 bool is_first_run_;
901 920
902 extensions::AppSyncBundle app_sync_bundle_; 921 extensions::AppSyncBundle app_sync_bundle_;
903 extensions::ExtensionSyncBundle extension_sync_bundle_; 922 extensions::ExtensionSyncBundle extension_sync_bundle_;
904 923
905 extensions::ProcessMap process_map_; 924 extensions::ProcessMap process_map_;
(...skipping 10 matching lines...) Expand all
916 ObserverList<extensions::UpdateObserver, true> update_observers_; 935 ObserverList<extensions::UpdateObserver, true> update_observers_;
917 936
918 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 937 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
919 InstallAppsWithUnlimtedStorage); 938 InstallAppsWithUnlimtedStorage);
920 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 939 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
921 InstallAppsAndCheckStorageProtection); 940 InstallAppsAndCheckStorageProtection);
922 DISALLOW_COPY_AND_ASSIGN(ExtensionService); 941 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
923 }; 942 };
924 943
925 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 944 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs_unittest.cc ('k') | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698