Warn user in case extension delays network traffic too much.
This CL adds a badge to the wrench menu and warning messages to chrome://extensions in case an extension delays network traffic too much and thereby causes a bad user experience.
BUG=82618
TEST=Install an extension using the webRequest API in a debug build. In debug build the extension should delay the network traffic enough to cause warning messages. You can use https://adblockplus.org/development-builds/experimental-adblock-plus-for-chrome-builds-available-with-better-blocking for example.
Review URL: http://codereview.chromium.org/8176001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104929 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 58ec01c..86004d7 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -603,7 +603,8 @@
app_notification_manager_(new AppNotificationManager(profile)),
permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
apps_promo_(profile->GetPrefs()),
- event_routers_initialized_(false) {
+ event_routers_initialized_(false),
+ extension_warnings_(profile) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Figure out if extension installation should be enabled.
@@ -971,6 +972,12 @@
UserMetrics::RecordAction(
UserMetricsAction("Extensions.ExtensionUninstalled"));
+ // Uninstalling one extension might have solved the problems of others.
+ // Therefore, we clear warnings of this type for all extensions.
+ std::set<ExtensionWarningSet::WarningType> warnings;
+ extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings);
+ extension_warnings_.ClearWarnings(warnings);
+
return true;
}
@@ -1071,6 +1078,12 @@
NotifyExtensionUnloaded(extension, extension_misc::UNLOAD_REASON_DISABLE);
SyncExtensionChangeIfNeeded(*extension);
+
+ // Deactivating one extension might have solved the problems of others.
+ // Therefore, we clear warnings of this type for all extensions.
+ std::set<ExtensionWarningSet::WarningType> warnings;
+ extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings);
+ extension_warnings_.ClearWarnings(warnings);
}
void ExtensionService::GrantPermissions(const Extension* extension) {