| 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 | |
| 175 // Attempts to uninstall an extension from a given ExtensionService. Returns | 158 // Attempts to uninstall an extension from a given ExtensionService. Returns |
| 176 // true iff the target extension exists. | 159 // true iff the target extension exists. |
| 177 static bool UninstallExtensionHelper(ExtensionService* extensions_service, | 160 static bool UninstallExtensionHelper( |
| 178 const std::string& extension_id, | 161 ExtensionService* extensions_service, |
| 179 UninstallReason reason); | 162 const std::string& extension_id, |
| 163 extensions::UninstalledExtensionInfo::Reason reason); |
| 180 | 164 |
| 181 // Constructor stores pointers to |profile| and |extension_prefs| but | 165 // Constructor stores pointers to |profile| and |extension_prefs| but |
| 182 // ownership remains at caller. | 166 // ownership remains at caller. |
| 183 ExtensionService(Profile* profile, | 167 ExtensionService(Profile* profile, |
| 184 const base::CommandLine* command_line, | 168 const base::CommandLine* command_line, |
| 185 const base::FilePath& install_directory, | 169 const base::FilePath& install_directory, |
| 186 extensions::ExtensionPrefs* extension_prefs, | 170 extensions::ExtensionPrefs* extension_prefs, |
| 187 extensions::Blacklist* blacklist, | 171 extensions::Blacklist* blacklist, |
| 188 bool autoupdate_enabled, | 172 bool autoupdate_enabled, |
| 189 bool extensions_enabled, | 173 bool extensions_enabled, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 // Called when the associated Profile is going to be destroyed. | 237 // Called when the associated Profile is going to be destroyed. |
| 254 void Shutdown(); | 238 void Shutdown(); |
| 255 | 239 |
| 256 // Reloads the specified extension, sending the onLaunched() event to it if it | 240 // Reloads the specified extension, sending the onLaunched() event to it if it |
| 257 // currently has any window showing. | 241 // currently has any window showing. |
| 258 void ReloadExtension(const std::string& extension_id); | 242 void ReloadExtension(const std::string& extension_id); |
| 259 | 243 |
| 260 // Uninstalls the specified extension. Callers should only call this method | 244 // Uninstalls the specified extension. Callers should only call this method |
| 261 // with extensions that exist. |reason| lets the caller specify why the | 245 // with extensions that exist. |reason| lets the caller specify why the |
| 262 // extension is uninstalled. | 246 // extension is uninstalled. |
| 263 virtual bool UninstallExtension(const std::string& extension_id, | 247 virtual bool UninstallExtension( |
| 264 UninstallReason reason, | 248 const std::string& extension_id, |
| 265 base::string16* error); | 249 extensions::UninstalledExtensionInfo::Reason reason, |
| 250 base::string16* error); |
| 266 | 251 |
| 267 // Enables the extension. If the extension is already enabled, does | 252 // Enables the extension. If the extension is already enabled, does |
| 268 // nothing. | 253 // nothing. |
| 269 virtual void EnableExtension(const std::string& extension_id); | 254 virtual void EnableExtension(const std::string& extension_id); |
| 270 | 255 |
| 271 // Disables the extension. If the extension is already disabled, or | 256 // Disables the extension. If the extension is already disabled, or |
| 272 // cannot be disabled, does nothing. | 257 // cannot be disabled, does nothing. |
| 273 virtual void DisableExtension( | 258 virtual void DisableExtension( |
| 274 const std::string& extension_id, | 259 const std::string& extension_id, |
| 275 extensions::Extension::DisableReason disable_reason); | 260 extensions::Extension::DisableReason disable_reason); |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 GreylistedExtensionDisabled); | 702 GreylistedExtensionDisabled); |
| 718 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 703 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 719 GreylistDontEnableManuallyDisabled); | 704 GreylistDontEnableManuallyDisabled); |
| 720 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 705 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 721 GreylistUnknownDontChange); | 706 GreylistUnknownDontChange); |
| 722 | 707 |
| 723 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 708 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 724 }; | 709 }; |
| 725 | 710 |
| 726 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 711 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |