Index: chrome/browser/notifications/stub_notification_platform_bridge.cc |
diff --git a/chrome/browser/notifications/stub_notification_platform_bridge.cc b/chrome/browser/notifications/stub_notification_platform_bridge.cc |
index 13ebe20db4cd5cbb00bb91da2460a97bfea1994e..94d444262d545d8e30af58dd65271db71c8829da 100644 |
--- a/chrome/browser/notifications/stub_notification_platform_bridge.cc |
+++ b/chrome/browser/notifications/stub_notification_platform_bridge.cc |
@@ -4,6 +4,9 @@ |
#include "chrome/browser/notifications/stub_notification_platform_bridge.h" |
+#include "base/memory/ptr_util.h" |
+#include "content/public/browser/browser_thread.h" |
+ |
StubNotificationPlatformBridge::StubNotificationPlatformBridge() |
: NotificationPlatformBridge() {} |
@@ -18,6 +21,14 @@ Notification StubNotificationPlatformBridge::GetNotificationAt( |
return notifications_[profile_id][index]; |
} |
+size_t StubNotificationPlatformBridge::GetNotificationCount() { |
+ int count = 0; |
+ for (const auto& profile : notifications_) { |
Peter Beverloo
2017/03/15 18:07:50
nit: s/profile/pair/
Miguel Garcia
2017/03/16 14:57:42
Done.
|
+ count += profile.second.size(); |
+ } |
+ return count; |
+} |
+ |
void StubNotificationPlatformBridge::Display( |
NotificationCommon::Type notification_type, |
const std::string& notification_id, |
@@ -43,16 +54,22 @@ void StubNotificationPlatformBridge::Close(const std::string& profile_id, |
} |
} |
-bool StubNotificationPlatformBridge::GetDisplayed( |
+void StubNotificationPlatformBridge::GetDisplayed( |
const std::string& profile_id, |
bool incognito, |
- std::set<std::string>* notifications) const { |
- if (notifications_.find(profile_id) == notifications_.end()) |
- return true; |
+ const NotificationResultCallback& callback) const { |
+ std::unique_ptr<std::set<std::string>> displayed_notifications = |
+ base::MakeUnique<std::set<std::string>>(); |
+ |
+ if (notifications_.find(profile_id) != notifications_.end()) { |
+ const std::vector<Notification>& profile_notifications = |
+ notifications_.at(profile_id); |
+ for (auto notification : profile_notifications) |
+ displayed_notifications->insert(notification.id()); |
+ } |
- const std::vector<Notification>& profile_notifications = |
- notifications_.at(profile_id); |
- for (auto notification : profile_notifications) |
- notifications->insert(notification.id()); |
- return true; |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, FROM_HERE, |
+ base::Bind(callback, base::Passed(&displayed_notifications), |
+ true /* supports synchronization */)); |
} |