| 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_FOR_TESTING, // Used for testing code only |
| 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_INSTALL_CANCELED, |
| 164 UNINSTALL_REASON_MANAGEMENT_API, |
| 165 UNINSTALL_REASON_SYNC, |
| 166 UNINSTALL_REASON_ORPHANED_THEME, |
| 167 UNINSTALL_REASON_ORPHANED_EPHEMERAL_EXTENSION, |
| 168 // The entries below imply bypassing checking user has permission to |
| 169 // uninstall the corresponding extension id. |
| 170 UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION, |
| 171 UNINSTALL_REASON_ORPHANED_SHARED_MODULE, |
| 172 UNINSTALL_REASON_INTERNAL_MANAGEMENT // Internal extensions (see usages) |
| 173 }; |
| 174 |
| 158 // Attempts to uninstall an extension from a given ExtensionService. Returns | 175 // Attempts to uninstall an extension from a given ExtensionService. Returns |
| 159 // true iff the target extension exists. | 176 // true iff the target extension exists. |
| 160 static bool UninstallExtensionHelper(ExtensionService* extensions_service, | 177 static bool UninstallExtensionHelper(ExtensionService* extensions_service, |
| 161 const std::string& extension_id); | 178 const std::string& extension_id, |
| 179 UninstallReason reason); |
| 162 | 180 |
| 163 // Constructor stores pointers to |profile| and |extension_prefs| but | 181 // Constructor stores pointers to |profile| and |extension_prefs| but |
| 164 // ownership remains at caller. | 182 // ownership remains at caller. |
| 165 ExtensionService(Profile* profile, | 183 ExtensionService(Profile* profile, |
| 166 const base::CommandLine* command_line, | 184 const base::CommandLine* command_line, |
| 167 const base::FilePath& install_directory, | 185 const base::FilePath& install_directory, |
| 168 extensions::ExtensionPrefs* extension_prefs, | 186 extensions::ExtensionPrefs* extension_prefs, |
| 169 extensions::Blacklist* blacklist, | 187 extensions::Blacklist* blacklist, |
| 170 bool autoupdate_enabled, | 188 bool autoupdate_enabled, |
| 171 bool extensions_enabled, | 189 bool extensions_enabled, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 void Init(); | 251 void Init(); |
| 234 | 252 |
| 235 // Called when the associated Profile is going to be destroyed. | 253 // Called when the associated Profile is going to be destroyed. |
| 236 void Shutdown(); | 254 void Shutdown(); |
| 237 | 255 |
| 238 // Reloads the specified extension, sending the onLaunched() event to it if it | 256 // Reloads the specified extension, sending the onLaunched() event to it if it |
| 239 // currently has any window showing. | 257 // currently has any window showing. |
| 240 void ReloadExtension(const std::string& extension_id); | 258 void ReloadExtension(const std::string& extension_id); |
| 241 | 259 |
| 242 // Uninstalls the specified extension. Callers should only call this method | 260 // Uninstalls the specified extension. Callers should only call this method |
| 243 // with extensions that exist. |external_uninstall| is a magical parameter | 261 // with extensions that exist. |reason| lets the caller specify why the |
| 244 // that is only used to send information to ExtensionPrefs, which external | 262 // 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, | 263 virtual bool UninstallExtension(const std::string& extension_id, |
| 250 bool external_uninstall, | 264 UninstallReason reason, |
| 251 base::string16* error); | 265 base::string16* error); |
| 252 | 266 |
| 253 // Enables the extension. If the extension is already enabled, does | 267 // Enables the extension. If the extension is already enabled, does |
| 254 // nothing. | 268 // nothing. |
| 255 virtual void EnableExtension(const std::string& extension_id); | 269 virtual void EnableExtension(const std::string& extension_id); |
| 256 | 270 |
| 257 // Disables the extension. If the extension is already disabled, or | 271 // Disables the extension. If the extension is already disabled, or |
| 258 // cannot be disabled, does nothing. | 272 // cannot be disabled, does nothing. |
| 259 virtual void DisableExtension( | 273 virtual void DisableExtension( |
| 260 const std::string& extension_id, | 274 const std::string& extension_id, |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 GreylistedExtensionDisabled); | 729 GreylistedExtensionDisabled); |
| 716 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 730 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 717 GreylistDontEnableManuallyDisabled); | 731 GreylistDontEnableManuallyDisabled); |
| 718 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 732 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 719 GreylistUnknownDontChange); | 733 GreylistUnknownDontChange); |
| 720 | 734 |
| 721 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 735 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 722 }; | 736 }; |
| 723 | 737 |
| 724 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 738 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |