Index: chrome/browser/browsing_data/browsing_data_remover.cc |
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc |
index 7987a92b972853da4aa464556bc68cac0b1fb197..ebd2309065244a983ac134f88eda933cc76bbad4 100644 |
--- a/chrome/browser/browsing_data/browsing_data_remover.cc |
+++ b/chrome/browser/browsing_data/browsing_data_remover.cc |
@@ -101,6 +101,24 @@ using content::BrowserContext; |
using content::BrowserThread; |
using content::DOMStorageContext; |
+namespace { |
+ |
+using CallbackList = |
+ base::CallbackList<void(const BrowsingDataRemover::NotificationDetails&)>; |
+ |
+// Contains all registered callbacks for browsing data removed notifications. |
+CallbackList* on_browsing_data_removed_callbacks_ = nullptr; |
Bernhard Bauer
2015/01/26 18:24:22
Name this |g_on_browsing_data_removed_callbacks| n
Simon Que
2015/01/26 18:43:00
Done.
|
+ |
+// Accessor for |*on_browsing_data_removed_callbacks_|. Creates a new object |
+// the first time so that it always returns a valid object. |
+CallbackList* GetOnBrowsingDataRemovedCallbacks() { |
+ if (!on_browsing_data_removed_callbacks_) |
+ on_browsing_data_removed_callbacks_ = new CallbackList(); |
+ return on_browsing_data_removed_callbacks_; |
+} |
+ |
+} // namespace |
+ |
bool BrowsingDataRemover::is_removing_ = false; |
BrowsingDataRemover::CompletionInhibitor* |
@@ -808,13 +826,11 @@ void BrowsingDataRemover::OnKeywordsLoaded() { |
void BrowsingDataRemover::NotifyAndDelete() { |
set_removing(false); |
- // Send global notification, then notify any explicit observers. |
+ // Notify observers. |
BrowsingDataRemover::NotificationDetails details(delete_begin_, remove_mask_, |
origin_set_mask_); |
- content::NotificationService::current()->Notify( |
- chrome::NOTIFICATION_BROWSING_DATA_REMOVED, |
- content::Source<Profile>(profile_), |
- content::Details<BrowsingDataRemover::NotificationDetails>(&details)); |
+ |
+ GetOnBrowsingDataRemovedCallbacks()->Notify(details); |
FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone()); |
@@ -1199,3 +1215,10 @@ void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { |
waiting_for_clear_domain_reliability_monitor_ = false; |
NotifyAndDeleteIfDone(); |
} |
+ |
+// static |
+BrowsingDataRemover::CallbackSubscription |
+ BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
+ const BrowsingDataRemover::Callback& callback) { |
+ return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
+} |