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

Unified Diff: chrome/browser/notifications/stub_notification_platform_bridge.cc

Issue 1895473002: PlatformNotificationService layering cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@display_manager2
Patch Set: Created 4 years, 8 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/notifications/stub_notification_platform_bridge.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..257a5ec3729c699103101e321f8bb866169dca20
--- /dev/null
+++ b/chrome/browser/notifications/stub_notification_platform_bridge.cc
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/notifications/stub_notification_platform_bridge.h"
+
+StubNotificationPlatformBridge::StubNotificationPlatformBridge()
+ : NotificationPlatformBridge() {}
+
+StubNotificationPlatformBridge::~StubNotificationPlatformBridge() {}
+
+Notification StubNotificationPlatformBridge::GetNotificationAt(
+ std::string profile_id,
+ size_t index) {
+ DCHECK(notifications_.find(profile_id) != notifications_.end());
+ DCHECK_GT(notifications_[profile_id].size(), index);
+
+ return notifications_[profile_id][index];
+}
+
+void StubNotificationPlatformBridge::Display(const std::string& notification_id,
+ const std::string& profile_id,
+ bool incognito,
+ const Notification& notification) {
+ notifications_[profile_id].push_back(notification);
+}
+
+void StubNotificationPlatformBridge::Close(const std::string& profile_id,
+ const std::string& notification_id) {
+ if (notifications_.find(profile_id) == notifications_.end())
+ return;
+ std::vector<Notification> profile_notifications = notifications_[profile_id];
+ for (auto iter = profile_notifications.begin();
+ iter != profile_notifications.end(); ++iter) {
+ if (iter->id() == notification_id) {
+ profile_notifications.erase(iter);
+ if (profile_notifications.empty())
+ notifications_.erase(profile_id);
+ break;
+ }
+ }
+}
+
+bool 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 std::vector<Notification>& profile_notifications =
+ notifications_.at(profile_id);
+ for (auto notification : profile_notifications)
+ notifications->insert(notification.id());
+ return true;
+}
+
+bool StubNotificationPlatformBridge::SupportsNotificationCenter() const {
+ return false;
+}
« no previous file with comments | « chrome/browser/notifications/stub_notification_platform_bridge.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698