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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/notifications/stub_notification_platform_bridge.h"
6
7 StubNotificationPlatformBridge::StubNotificationPlatformBridge()
8 : NotificationPlatformBridge() {}
9
10 StubNotificationPlatformBridge::~StubNotificationPlatformBridge() {}
11
12 Notification StubNotificationPlatformBridge::GetNotificationAt(
13 std::string profile_id,
14 size_t index) {
15 DCHECK(notifications_.find(profile_id) != notifications_.end());
16 DCHECK_GT(notifications_[profile_id].size(), index);
17
18 return notifications_[profile_id][index];
19 }
20
21 void StubNotificationPlatformBridge::Display(const std::string& notification_id,
22 const std::string& profile_id,
23 bool incognito,
24 const Notification& notification) {
25 notifications_[profile_id].push_back(notification);
26 }
27
28 void StubNotificationPlatformBridge::Close(const std::string& profile_id,
29 const std::string& notification_id) {
30 if (notifications_.find(profile_id) == notifications_.end())
31 return;
32 std::vector<Notification> profile_notifications = notifications_[profile_id];
33 for (auto iter = profile_notifications.begin();
34 iter != profile_notifications.end(); ++iter) {
35 if (iter->id() == notification_id) {
36 profile_notifications.erase(iter);
37 if (profile_notifications.empty())
38 notifications_.erase(profile_id);
39 break;
40 }
41 }
42 }
43
44 bool StubNotificationPlatformBridge::GetDisplayed(
45 const std::string& profile_id,
46 bool incognito,
47 std::set<std::string>* notifications) const {
48 if (notifications_.find(profile_id) == notifications_.end())
49 return true;
50
51 const std::vector<Notification>& profile_notifications =
52 notifications_.at(profile_id);
53 for (auto notification : profile_notifications)
54 notifications->insert(notification.id());
55 return true;
56 }
57
58 bool StubNotificationPlatformBridge::SupportsNotificationCenter() const {
59 return false;
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698