| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/prefs/pref_change_registrar.h" | 18 #include "base/prefs/pref_change_registrar.h" |
| 19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 20 #include "chrome/browser/extensions/blacklist.h" | 20 #include "chrome/browser/extensions/blacklist.h" |
| 21 #include "chrome/browser/extensions/pending_extension_manager.h" | 21 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
| 24 #include "extensions/browser/external_provider_interface.h" | 24 #include "extensions/browser/external_provider_interface.h" |
| 25 #include "extensions/browser/install_flag.h" | 25 #include "extensions/browser/install_flag.h" |
| 26 #include "extensions/browser/management_policy.h" | 26 #include "extensions/browser/management_policy.h" |
| 27 #include "extensions/browser/process_manager.h" | 27 #include "extensions/browser/process_manager.h" |
| 28 #include "extensions/browser/uninstall_reason.h" |
| 28 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
| 29 #include "extensions/common/extension_set.h" | 30 #include "extensions/common/extension_set.h" |
| 30 #include "extensions/common/manifest.h" | 31 #include "extensions/common/manifest.h" |
| 31 #include "sync/api/string_ordinal.h" | 32 #include "sync/api/string_ordinal.h" |
| 32 | 33 |
| 33 class ExtensionSyncService; | 34 class ExtensionSyncService; |
| 34 class GURL; | 35 class GURL; |
| 35 class Profile; | 36 class Profile; |
| 36 | 37 |
| 37 namespace base { | 38 namespace base { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 }; | 149 }; |
| 149 | 150 |
| 150 // Manages installed and running Chromium extensions. An instance is shared | 151 // Manages installed and running Chromium extensions. An instance is shared |
| 151 // between normal and incognito profiles. | 152 // between normal and incognito profiles. |
| 152 class ExtensionService | 153 class ExtensionService |
| 153 : public ExtensionServiceInterface, | 154 : public ExtensionServiceInterface, |
| 154 public extensions::ExternalProviderInterface::VisitorInterface, | 155 public extensions::ExternalProviderInterface::VisitorInterface, |
| 155 public content::NotificationObserver, | 156 public content::NotificationObserver, |
| 156 public extensions::Blacklist::Observer { | 157 public extensions::Blacklist::Observer { |
| 157 public: | 158 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 | 159 // Attempts to uninstall an extension from a given ExtensionService. Returns |
| 176 // true iff the target extension exists. | 160 // true iff the target extension exists. |
| 177 static bool UninstallExtensionHelper(ExtensionService* extensions_service, | 161 static bool UninstallExtensionHelper(ExtensionService* extensions_service, |
| 178 const std::string& extension_id, | 162 const std::string& extension_id, |
| 179 UninstallReason reason); | 163 extensions::UninstallReason 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // Allows noisy failures. | 242 // Allows noisy failures. |
| 259 void ReloadExtension(const std::string& extension_id); | 243 void ReloadExtension(const std::string& extension_id); |
| 260 | 244 |
| 261 // Suppresses noisy failures. | 245 // Suppresses noisy failures. |
| 262 void ReloadExtensionWithQuietFailure(const std::string& extension_id); | 246 void ReloadExtensionWithQuietFailure(const std::string& extension_id); |
| 263 | 247 |
| 264 // Uninstalls the specified extension. Callers should only call this method | 248 // Uninstalls the specified extension. Callers should only call this method |
| 265 // with extensions that exist. |reason| lets the caller specify why the | 249 // with extensions that exist. |reason| lets the caller specify why the |
| 266 // extension is uninstalled. | 250 // extension is uninstalled. |
| 267 virtual bool UninstallExtension(const std::string& extension_id, | 251 virtual bool UninstallExtension(const std::string& extension_id, |
| 268 UninstallReason reason, | 252 extensions::UninstallReason reason, |
| 269 base::string16* error); | 253 base::string16* error); |
| 270 | 254 |
| 271 // Enables the extension. If the extension is already enabled, does | 255 // Enables the extension. If the extension is already enabled, does |
| 272 // nothing. | 256 // nothing. |
| 273 virtual void EnableExtension(const std::string& extension_id); | 257 virtual void EnableExtension(const std::string& extension_id); |
| 274 | 258 |
| 275 // Disables the extension. If the extension is already disabled, or | 259 // Disables the extension. If the extension is already disabled, or |
| 276 // cannot be disabled, does nothing. | 260 // cannot be disabled, does nothing. |
| 277 virtual void DisableExtension( | 261 virtual void DisableExtension( |
| 278 const std::string& extension_id, | 262 const std::string& extension_id, |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 GreylistedExtensionDisabled); | 710 GreylistedExtensionDisabled); |
| 727 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 711 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 728 GreylistDontEnableManuallyDisabled); | 712 GreylistDontEnableManuallyDisabled); |
| 729 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 713 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 730 GreylistUnknownDontChange); | 714 GreylistUnknownDontChange); |
| 731 | 715 |
| 732 DISALLOW_COPY_AND_ASSIGN(ExtensionService); | 716 DISALLOW_COPY_AND_ASSIGN(ExtensionService); |
| 733 }; | 717 }; |
| 734 | 718 |
| 735 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ | 719 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ |
| OLD | NEW |