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

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: Nit 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
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/external_install_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 2d0a040430758c1339aae98ed763a5ff5b917d34..264a76ac96c17c5d601b9052c446b0540bae5fa7 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_;
}
@@ -1955,10 +1962,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() {
@@ -2650,12 +2654,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(
@@ -3170,3 +3170,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;
+ }
+ }
+}
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/external_install_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698