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

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

Issue 11415216: Make Blacklist::IsBlacklist asynchronous (it will need to be for safe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another test Created 8 years 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 | Annotate | Revision Log
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 <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 virtual const ExtensionSet* disabled_extensions() const = 0; 100 virtual const ExtensionSet* disabled_extensions() const = 0;
101 virtual extensions::PendingExtensionManager* pending_extension_manager() = 0; 101 virtual extensions::PendingExtensionManager* pending_extension_manager() = 0;
102 102
103 // Install an update. Return true if the install can be started. 103 // Install an update. Return true if the install can be started.
104 // Set out_crx_installer to the installer if one was started. 104 // Set out_crx_installer to the installer if one was started.
105 virtual bool UpdateExtension( 105 virtual bool UpdateExtension(
106 const std::string& id, 106 const std::string& id,
107 const FilePath& path, 107 const FilePath& path,
108 const GURL& download_url, 108 const GURL& download_url,
109 extensions::CrxInstaller** out_crx_installer) = 0; 109 extensions::CrxInstaller** out_crx_installer) = 0;
110 virtual const extensions::Extension* GetExtensionById(const std::string& id, 110 virtual const extensions::Extension* GetExtensionById(
111 bool include_disabled) const = 0; 111 const std::string& id,
112 bool include_disabled) const = 0;
112 virtual const extensions::Extension* GetInstalledExtension( 113 virtual const extensions::Extension* GetInstalledExtension(
113 const std::string& id) const = 0; 114 const std::string& id) const = 0;
114 115
115 virtual const extensions::Extension* GetPendingExtensionUpdate( 116 virtual const extensions::Extension* GetPendingExtensionUpdate(
116 const std::string& extension_id) const = 0; 117 const std::string& extension_id) const = 0;
117 virtual void FinishDelayedInstallation(const std::string& extension_id) = 0; 118 virtual void FinishDelayedInstallation(const std::string& extension_id) = 0;
118 119
119 virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0; 120 virtual bool IsExtensionEnabled(const std::string& extension_id) const = 0;
120 virtual bool IsExternalExtensionUninstalled( 121 virtual bool IsExternalExtensionUninstalled(
121 const std::string& extension_id) const = 0; 122 const std::string& extension_id) const = 0;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 extensions::Blacklist* blacklist, 205 extensions::Blacklist* blacklist,
205 bool autoupdate_enabled, 206 bool autoupdate_enabled,
206 bool extensions_enabled); 207 bool extensions_enabled);
207 208
208 virtual ~ExtensionService(); 209 virtual ~ExtensionService();
209 210
210 // Gets the list of currently installed extensions. 211 // Gets the list of currently installed extensions.
211 virtual const ExtensionSet* extensions() const OVERRIDE; 212 virtual const ExtensionSet* extensions() const OVERRIDE;
212 virtual const ExtensionSet* disabled_extensions() const OVERRIDE; 213 virtual const ExtensionSet* disabled_extensions() const OVERRIDE;
213 const ExtensionSet* terminated_extensions() const; 214 const ExtensionSet* terminated_extensions() const;
215 const ExtensionSet* blacklisted_extensions() const;
214 216
215 // Returns a set of all installed, disabled, and terminated extensions and 217 // Returns a set of all installed, disabled, blacklisted, and terminated
216 // transfers ownership to caller. 218 // extensions.
217 const ExtensionSet* GenerateInstalledExtensionsSet() const; 219 scoped_ptr<const ExtensionSet> GenerateInstalledExtensionsSet() const;
218 220
219 // Returns a set of all extensions disabled by the sideload wipeout 221 // Returns a set of all extensions disabled by the sideload wipeout
220 // initiative. 222 // initiative.
221 const ExtensionSet* GetWipedOutExtensions() const; 223 scoped_ptr<const ExtensionSet> GetWipedOutExtensions() const;
222 224
223 // Gets the object managing the set of pending extensions. 225 // Gets the object managing the set of pending extensions.
224 virtual extensions::PendingExtensionManager* 226 virtual extensions::PendingExtensionManager*
225 pending_extension_manager() OVERRIDE; 227 pending_extension_manager() OVERRIDE;
226 228
227 const FilePath& install_directory() const { return install_directory_; } 229 const FilePath& install_directory() const { return install_directory_; }
228 230
229 extensions::ProcessMap* process_map() { return &process_map_; } 231 extensions::ProcessMap* process_map() { return &process_map_; }
230 232
231 // Whether this extension can run in an incognito window. 233 // Whether this extension can run in an incognito window.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // Called when the ProfileSyncService for the associated Profile is 300 // Called when the ProfileSyncService for the associated Profile is
299 // going to be destroyed. This is guaranteed to be called exactly 301 // going to be destroyed. This is guaranteed to be called exactly
300 // once before Shutdown() is called. 302 // once before Shutdown() is called.
301 // 303 //
302 // TODO(akalin): Remove this once http://crbug.com/153827 is fixed. 304 // TODO(akalin): Remove this once http://crbug.com/153827 is fixed.
303 void OnProfileSyncServiceShutdown(); 305 void OnProfileSyncServiceShutdown();
304 306
305 // Called when the associated Profile is going to be destroyed. 307 // Called when the associated Profile is going to be destroyed.
306 void Shutdown(); 308 void Shutdown();
307 309
308 // Look up an extension by ID. Does not include terminated 310 // Look up an extension by ID. Does not include terminated
309 // extensions. 311 // extensions.
310 virtual const extensions::Extension* GetExtensionById( 312 virtual const extensions::Extension* GetExtensionById(
311 const std::string& id, bool include_disabled) const OVERRIDE; 313 const std::string& id, bool include_disabled) const OVERRIDE;
312 314
315 enum IncludeFlag {
316 INCLUDE_NONE = 0,
317 INCLUDE_ENABLED = 1 << 0,
318 INCLUDE_DISABLED = 1 << 1,
319 INCLUDE_TERMINATED = 1 << 2,
320 INCLUDE_BLACKLISTED = 1 << 3,
321 INCLUDE_EVERYTHING = (1 << 4) - 1,
322 };
323
324 // Look up an extension by ID, selecting which sets to look in:
325 // * extensions() --> INCLUDE_ENABLED
326 // * disabled_extensions() --> INCLUDE_DISABLED
327 // * terminated_extensions() --> INCLUDE_TERMINATED
328 // * blacklisted_extensions() --> INCLUDE_BLACKLISTED
329 const extensions::Extension* GetExtensionById(const std::string& id,
330 int include_mask) const;
331
313 // Looks up a terminated (crashed) extension by ID. 332 // Looks up a terminated (crashed) extension by ID.
314 const extensions::Extension* 333 const extensions::Extension*
315 GetTerminatedExtension(const std::string& id) const; 334 GetTerminatedExtension(const std::string& id) const;
316 335
317 // 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,
318 // disabled, or terminated. 337 // disabled, blacklisted, or terminated.
319 virtual const extensions::Extension* GetInstalledExtension( 338 virtual const extensions::Extension* GetInstalledExtension(
320 const std::string& id) const OVERRIDE; 339 const std::string& id) const OVERRIDE;
321 340
322 // Updates a currently-installed extension with the contents from 341 // Updates a currently-installed extension with the contents from
323 // |extension_path|. 342 // |extension_path|.
324 // TODO(aa): This method can be removed. ExtensionUpdater could use 343 // TODO(aa): This method can be removed. ExtensionUpdater could use
325 // CrxInstaller directly instead. 344 // CrxInstaller directly instead.
326 virtual bool UpdateExtension( 345 virtual bool UpdateExtension(
327 const std::string& id, 346 const std::string& id,
328 const FilePath& extension_path, 347 const FilePath& extension_path,
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 void OnExtensionInstallPrefChanged(); 754 void OnExtensionInstallPrefChanged();
736 755
737 // Handles setting the extension specific values in |extension_sync_data| to 756 // Handles setting the extension specific values in |extension_sync_data| to
738 // the current system. 757 // the current system.
739 // Returns false if the changes were not completely applied and need to be 758 // Returns false if the changes were not completely applied and need to be
740 // tried again later. 759 // tried again later.
741 bool ProcessExtensionSyncDataHelper( 760 bool ProcessExtensionSyncDataHelper(
742 const extensions::ExtensionSyncData& extension_sync_data, 761 const extensions::ExtensionSyncData& extension_sync_data,
743 syncer::ModelType type); 762 syncer::ModelType type);
744 763
745 enum IncludeFlag {
746 INCLUDE_NONE = 0,
747 INCLUDE_ENABLED = 1 << 0,
748 INCLUDE_DISABLED = 1 << 1,
749 INCLUDE_TERMINATED = 1 << 2
750 };
751
752 // Events to be fired after an extension is reloaded. 764 // Events to be fired after an extension is reloaded.
753 enum PostReloadEvents { 765 enum PostReloadEvents {
754 EVENT_NONE = 0, 766 EVENT_NONE = 0,
755 EVENT_LAUNCHED = 1 << 0, 767 EVENT_LAUNCHED = 1 << 0,
756 EVENT_RESTARTED = 1 << 1, 768 EVENT_RESTARTED = 1 << 1,
757 }; 769 };
758 770
759 // Look up an extension by ID, optionally including either or both of enabled
760 // and disabled extensions.
761 const extensions::Extension* GetExtensionByIdInternal(
762 const std::string& id,
763 int include_mask) const;
764
765 // Adds the given extension to the list of terminated extensions if 771 // Adds the given extension to the list of terminated extensions if
766 // it is not already there and unloads it. 772 // it is not already there and unloads it.
767 void TrackTerminatedExtension(const extensions::Extension* extension); 773 void TrackTerminatedExtension(const extensions::Extension* extension);
768 774
769 // Removes the extension with the given id from the list of 775 // Removes the extension with the given id from the list of
770 // terminated extensions if it is there. 776 // terminated extensions if it is there.
771 void UntrackTerminatedExtension(const std::string& id); 777 void UntrackTerminatedExtension(const std::string& id);
772 778
773 // Update preferences for a new or updated extension; notify observers that 779 // Update preferences for a new or updated extension; notify observers that
774 // the extension is installed, e.g., to update event handlers on background 780 // the extension is installed, e.g., to update event handlers on background
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 bool IsExtensionIdle(const std::string& extension_id) const; 843 bool IsExtensionIdle(const std::string& extension_id) const;
838 844
839 // Helper to determine if updating an extensions should proceed immediately, 845 // Helper to determine if updating an extensions should proceed immediately,
840 // or if we should delay the update until further notice. 846 // or if we should delay the update until further notice.
841 bool ShouldDelayExtensionUpdate(const std::string& extension_id, 847 bool ShouldDelayExtensionUpdate(const std::string& extension_id,
842 bool wait_for_idle) const; 848 bool wait_for_idle) const;
843 849
844 // extensions::Blacklist::Observer implementation. 850 // extensions::Blacklist::Observer implementation.
845 virtual void OnBlacklistUpdated() OVERRIDE; 851 virtual void OnBlacklistUpdated() OVERRIDE;
846 852
853 // Manages the blacklisted extensions, intended as callback from
854 // Blacklist::GetBlacklistedIDs.
855 void ManageBlacklist(const std::set<std::string>& old_blacklisted_ids,
856 const std::set<std::string>& new_blacklisted_ids);
857
847 // The normal profile associated with this ExtensionService. 858 // The normal profile associated with this ExtensionService.
848 Profile* profile_; 859 Profile* profile_;
849 860
850 // The ExtensionSystem for the profile above. 861 // The ExtensionSystem for the profile above.
851 extensions::ExtensionSystem* system_; 862 extensions::ExtensionSystem* system_;
852 863
853 // Preferences for the owning profile (weak reference). 864 // Preferences for the owning profile.
854 extensions::ExtensionPrefs* extension_prefs_; 865 extensions::ExtensionPrefs* extension_prefs_;
855 866
867 // Blacklist for the owning profile.
868 extensions::Blacklist* blacklist_;
869
856 // Settings for the owning profile. 870 // Settings for the owning profile.
857 scoped_ptr<extensions::SettingsFrontend> settings_frontend_; 871 scoped_ptr<extensions::SettingsFrontend> settings_frontend_;
858 872
859 // The current list of installed extensions. 873 // The current list of installed extensions.
860 ExtensionSet extensions_; 874 ExtensionSet extensions_;
861 875
862 // The list of installed extensions that have been disabled. 876 // The list of installed extensions that have been disabled.
863 ExtensionSet disabled_extensions_; 877 ExtensionSet disabled_extensions_;
864 878
865 // The list of installed extensions that have been terminated. 879 // The list of installed extensions that have been terminated.
866 ExtensionSet terminated_extensions_; 880 ExtensionSet terminated_extensions_;
867 881
882 // The list of installed extensions that have been blacklisted. Generally
883 // 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
885 // they can easily be un-blacklisted.
886 ExtensionSet blacklisted_extensions_;
887
868 // The list of extension updates that are waiting to be installed. 888 // The list of extension updates that are waiting to be installed.
869 ExtensionSet pending_extension_updates_; 889 ExtensionSet pending_extension_updates_;
870 890
871 // Hold the set of pending extensions. 891 // Hold the set of pending extensions.
872 extensions::PendingExtensionManager pending_extension_manager_; 892 extensions::PendingExtensionManager pending_extension_manager_;
873 893
874 // The map of extension IDs to their runtime data. 894 // The map of extension IDs to their runtime data.
875 ExtensionRuntimeDataMap extension_runtime_data_; 895 ExtensionRuntimeDataMap extension_runtime_data_;
876 896
877 // The full path to the directory where extensions are installed. 897 // The full path to the directory where extensions are installed.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 #endif 1028 #endif
1009 1029
1010 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 1030 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
1011 InstallAppsWithUnlimtedStorage); 1031 InstallAppsWithUnlimtedStorage);
1012 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 1032 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
1013 InstallAppsAndCheckStorageProtection); 1033 InstallAppsAndCheckStorageProtection);
1014 DISALLOW_COPY_AND_ASSIGN(ExtensionService); 1034 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
1015 }; 1035 };
1016 1036
1017 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 1037 #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