Chromium Code Reviews| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 // Manages installed and running Chromium extensions. An instance is shared | 150 // Manages installed and running Chromium extensions. An instance is shared |
| 151 // between normal and incognito profiles. | 151 // between normal and incognito profiles. |
| 152 class ExtensionService | 152 class ExtensionService |
| 153 : public ExtensionServiceInterface, | 153 : public ExtensionServiceInterface, |
| 154 public extensions::ExternalProviderInterface::VisitorInterface, | 154 public extensions::ExternalProviderInterface::VisitorInterface, |
| 155 public content::NotificationObserver, | 155 public content::NotificationObserver, |
| 156 public extensions::Blacklist::Observer { | 156 public extensions::Blacklist::Observer { |
| 157 public: | 157 public: |
| 158 enum UninstallReason { | |
| 159 UNINSTALL_REASON_DEFAULT, // Usually from testing code | |
|
Devlin
2014/07/01 17:39:10
Please rename this to UNINSTALL_REASON_FOR_TESTING
rpaquay
2014/07/01 22:56:53
Done.
| |
| 160 UNINSTALL_REASON_USER_INITIATED, // User performed some UI gesture | |
| 161 UNINSTALL_REASON_EXTENSION_DISABLED, // Extension disabled due to error | |
| 162 UNINSTALL_REASON_STORAGE_THRESHOLD_EXCEEDED, | |
| 163 UNINSTALL_REASON_EXTERNAL_INSTALL_CANCELED, | |
| 164 UNINSTALL_REASON_MANAGEMENT_API, | |
| 165 UNINSTALL_REASON_SYNC, | |
| 166 UNINSTALL_REASON_ORPHANED_SHARED_MODULE, | |
| 167 UNINSTALL_REASON_ORPHANED_THEME, | |
| 168 UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION, | |
| 169 UNINSTALL_REASON_ORPHANED_EPHEMERAL_EXTENSION | |
| 170 }; | |
| 171 | |
| 158 // Attempts to uninstall an extension from a given ExtensionService. Returns | 172 // Attempts to uninstall an extension from a given ExtensionService. Returns |
| 159 // true iff the target extension exists. | 173 // true iff the target extension exists. |
| 160 static bool UninstallExtensionHelper(ExtensionService* extensions_service, | 174 static bool UninstallExtensionHelper(ExtensionService* extensions_service, |
| 161 const std::string& extension_id); | 175 const std::string& extension_id, |
| 176 UninstallReason reason); | |
| 162 | 177 |
| 163 // Constructor stores pointers to |profile| and |extension_prefs| but | 178 // Constructor stores pointers to |profile| and |extension_prefs| but |
| 164 // ownership remains at caller. | 179 // ownership remains at caller. |
| 165 ExtensionService(Profile* profile, | 180 ExtensionService(Profile* profile, |
| 166 const base::CommandLine* command_line, | 181 const base::CommandLine* command_line, |
| 167 const base::FilePath& install_directory, | 182 const base::FilePath& install_directory, |
| 168 extensions::ExtensionPrefs* extension_prefs, | 183 extensions::ExtensionPrefs* extension_prefs, |
| 169 extensions::Blacklist* blacklist, | 184 extensions::Blacklist* blacklist, |
| 170 bool autoupdate_enabled, | 185 bool autoupdate_enabled, |
| 171 bool extensions_enabled, | 186 bool extensions_enabled, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 void Init(); | 248 void Init(); |
| 234 | 249 |
| 235 // Called when the associated Profile is going to be destroyed. | 250 // Called when the associated Profile is going to be destroyed. |
| 236 void Shutdown(); | 251 void Shutdown(); |
| 237 | 252 |
| 238 // Reloads the specified extension, sending the onLaunched() event to it if it | 253 // Reloads the specified extension, sending the onLaunched() event to it if it |
| 239 // currently has any window showing. | 254 // currently has any window showing. |
| 240 void ReloadExtension(const std::string& extension_id); | 255 void ReloadExtension(const std::string& extension_id); |
| 241 | 256 |
| 242 // Uninstalls the specified extension. Callers should only call this method | 257 // Uninstalls the specified extension. Callers should only call this method |
| 243 // with extensions that exist. |external_uninstall| is a magical parameter | 258 // with extensions that exist. |reason| lets the caller specify why the |
| 244 // that is only used to send information to ExtensionPrefs, which external | 259 // extension is uninstalled. |
| 245 // callers should never set to true. | |
| 246 // | |
| 247 // TODO(aa): Remove |external_uninstall| -- this information should be passed | |
| 248 // to ExtensionPrefs some other way. | |
| 249 virtual bool UninstallExtension(const std::string& extension_id, | 260 virtual bool UninstallExtension(const std::string& extension_id, |
| 250 bool external_uninstall, | 261 UninstallReason reason, |
| 251 base::string16* error); | 262 base::string16* error); |
| 252 | 263 |
| 253 // Enables the extension. If the extension is already enabled, does | 264 // Enables the extension. If the extension is already enabled, does |
| 254 // nothing. | 265 // nothing. |
| 255 virtual void EnableExtension(const std::string& extension_id); | 266 virtual void EnableExtension(const std::string& extension_id); |
| 256 | 267 |
| 257 // Disables the extension. If the extension is already disabled, or | 268 // Disables the extension. If the extension is already disabled, or |
| 258 // cannot be disabled, does nothing. | 269 // cannot be disabled, does nothing. |
| 259 virtual void DisableExtension( | 270 virtual void DisableExtension( |
| 260 const std::string& extension_id, | 271 const std::string& extension_id, |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 GreylistedExtensionDisabled); | 720 GreylistedExtensionDisabled); |
| 710 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 721 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 711 GreylistDontEnableManuallyDisabled); | 722 GreylistDontEnableManuallyDisabled); |
| 712 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 723 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 713 GreylistUnknownDontChange); | 724 GreylistUnknownDontChange); |
| 714 | 725 |
| 715 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 726 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 716 }; | 727 }; |
| 717 | 728 |
| 718 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 729 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |