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

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

Issue 284103002: Replace "external_install" boolean parameter with explicit enumeration in ExtensionUninstall method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 }; 121 };
122 122
123 // Manages installed and running Chromium extensions. An instance is shared 123 // Manages installed and running Chromium extensions. An instance is shared
124 // between normal and incognito profiles. 124 // between normal and incognito profiles.
125 class ExtensionService 125 class ExtensionService
126 : public ExtensionServiceInterface, 126 : public ExtensionServiceInterface,
127 public extensions::ExternalProviderInterface::VisitorInterface, 127 public extensions::ExternalProviderInterface::VisitorInterface,
128 public content::NotificationObserver, 128 public content::NotificationObserver,
129 public extensions::Blacklist::Observer { 129 public extensions::Blacklist::Observer {
130 public: 130 public:
131 enum UninstallReason {
132 kUninstallReasonDefault,
Devlin 2014/05/14 23:14:20 For better or worse, Extensions code overwhelmingl
rpaquay 2014/06/30 23:16:18 Done.
133 kUninstallReasonOrphanedSharedModule,
134 kUninstallReasonOrphanedTheme,
135 kUninstallReasonOrphanedExternalExtension,
136 kUninstallReasonOrphanedEphemeralExtension,
137 kUninstallReasonUserInitiated,
138 kUninstallReasonSynch,
Devlin 2014/05/14 23:14:20 nit: "Sync" is more common spelling in the code.
rpaquay 2014/06/30 23:16:18 Done.
139 };
140
131 // Attempts to uninstall an extension from a given ExtensionService. Returns 141 // Attempts to uninstall an extension from a given ExtensionService. Returns
132 // true iff the target extension exists. 142 // true iff the target extension exists.
133 static bool UninstallExtensionHelper(ExtensionService* extensions_service, 143 static bool UninstallExtensionHelper(ExtensionService* extensions_service,
134 const std::string& extension_id); 144 const std::string& extension_id,
145 UninstallReason reason);
135 146
136 // Constructor stores pointers to |profile| and |extension_prefs| but 147 // Constructor stores pointers to |profile| and |extension_prefs| but
137 // ownership remains at caller. 148 // ownership remains at caller.
138 ExtensionService(Profile* profile, 149 ExtensionService(Profile* profile,
139 const base::CommandLine* command_line, 150 const base::CommandLine* command_line,
140 const base::FilePath& install_directory, 151 const base::FilePath& install_directory,
141 extensions::ExtensionPrefs* extension_prefs, 152 extensions::ExtensionPrefs* extension_prefs,
142 extensions::Blacklist* blacklist, 153 extensions::Blacklist* blacklist,
143 bool autoupdate_enabled, 154 bool autoupdate_enabled,
144 bool extensions_enabled, 155 bool extensions_enabled,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const std::string& id, 200 const std::string& id,
190 const base::FilePath& extension_path, 201 const base::FilePath& extension_path,
191 bool file_ownership_passed, 202 bool file_ownership_passed,
192 extensions::CrxInstaller** out_crx_installer) OVERRIDE; 203 extensions::CrxInstaller** out_crx_installer) OVERRIDE;
193 204
194 // Reloads the specified extension, sending the onLaunched() event to it if it 205 // Reloads the specified extension, sending the onLaunched() event to it if it
195 // currently has any window showing. 206 // currently has any window showing.
196 void ReloadExtension(const std::string extension_id); 207 void ReloadExtension(const std::string extension_id);
197 208
198 // Uninstalls the specified extension. Callers should only call this method 209 // Uninstalls the specified extension. Callers should only call this method
199 // with extensions that exist. |external_uninstall| is a magical parameter 210 // with extensions that exist. |reason| lets the caller specify why the
200 // that is only used to send information to ExtensionPrefs, which external 211 // extension is uninstalled.
201 // callers should never set to true.
202 //
203 // We pass the |extension_id| by value to avoid having it deleted from under
204 // us incase someone calls it with Extension::id() or another string that we
205 // are going to delete in this function.
206 //
207 // TODO(aa): Remove |external_uninstall| -- this information should be passed
208 // to ExtensionPrefs some other way.
209 virtual bool UninstallExtension(const std::string& extension_id, 212 virtual bool UninstallExtension(const std::string& extension_id,
210 bool external_uninstall, 213 UninstallReason reason,
211 base::string16* error); 214 base::string16* error);
212 215
213 virtual bool IsExtensionEnabled( 216 virtual bool IsExtensionEnabled(
214 const std::string& extension_id) const OVERRIDE; 217 const std::string& extension_id) const OVERRIDE;
215 218
216 // Enables the extension. If the extension is already enabled, does 219 // Enables the extension. If the extension is already enabled, does
217 // nothing. 220 // nothing.
218 virtual void EnableExtension(const std::string& extension_id); 221 virtual void EnableExtension(const std::string& extension_id);
219 222
220 // Disables the extension. If the extension is already disabled, or 223 // Disables the extension. If the extension is already disabled, or
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 710 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
708 GreylistedExtensionDisabled); 711 GreylistedExtensionDisabled);
709 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 712 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
710 GreylistDontEnableManuallyDisabled); 713 GreylistDontEnableManuallyDisabled);
711 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 714 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
712 GreylistUnknownDontChange); 715 GreylistUnknownDontChange);
713 DISALLOW_COPY_AND_ASSIGN(ExtensionService); 716 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
714 }; 717 };
715 718
716 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 719 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698