Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5914)

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 22799016: Kill NOTIFICATION_EXTENSION_REMOVED (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index ed7d9ce83109ea52d9080cc7296f0580934b2d3b..4ea8ff4a3eb6c3aab34b92ae5b641a032fa6a6df 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -1222,6 +1222,13 @@ void ExtensionService::NotifyExtensionUnloaded(
UpdateActiveExtensionsInCrashReporter();
}
+void ExtensionService::NotifyExtensionRemoved(const Extension* extension) {
+ for (size_t i = 0; i < extension_removed_callbacks_.size(); ++i) {
+ if (!extension_removed_callbacks_[i].is_null())
+ extension_removed_callbacks_[i].Run(extension);
+ }
+}
+
Profile* ExtensionService::profile() {
return profile_;
}
@@ -1956,10 +1963,7 @@ void ExtensionService::UnloadExtension(
NotifyExtensionUnloaded(extension.get(), reason);
}
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_EXTENSION_REMOVED,
- content::Source<Profile>(profile_),
- content::Details<const Extension>(extension.get()));
+ NotifyExtensionRemoved(extension.get());
}
void ExtensionService::UnloadAllExtensions() {
@@ -2651,12 +2655,8 @@ void ExtensionService::UntrackTerminatedExtension(const std::string& id) {
std::string lowercase_id = StringToLowerASCII(id);
const Extension* extension = terminated_extensions_.GetByID(lowercase_id);
terminated_extensions_.Remove(lowercase_id);
- if (extension) {
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_EXTENSION_REMOVED,
- content::Source<Profile>(profile_),
- content::Details<const Extension>(extension));
- }
+ if (extension)
+ NotifyExtensionRemoved(extension);
}
const Extension* ExtensionService::GetTerminatedExtension(
@@ -3175,3 +3175,19 @@ void ExtensionService::RemoveUpdateObserver(
extensions::UpdateObserver* observer) {
update_observers_.RemoveObserver(observer);
}
+
+void ExtensionService::RegisterExtensionRemovedCallback(
+ const base::Callback<void(const extensions::Extension*)>& callback) {
+ extension_removed_callbacks_.push_back(callback);
+}
+
+void ExtensionService::RemoveExtensionRemovedCallback(
+ const base::Callback<void(const extensions::Extension*)>& callback) {
+ for (size_t i = 0; i < extension_removed_callbacks_.size(); ++i) {
+ if (extension_removed_callbacks_[i].Equals(callback)) {
+ extension_removed_callbacks_.erase(
+ extension_removed_callbacks_.begin() + i);
+ return;
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698