OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/notifications/stub_notification_display_service.h" | 5 #include "chrome/browser/notifications/stub_notification_display_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
10 | 11 |
11 // static | 12 // static |
12 std::unique_ptr<KeyedService> StubNotificationDisplayService::FactoryForTests( | 13 std::unique_ptr<KeyedService> StubNotificationDisplayService::FactoryForTests( |
13 content::BrowserContext* /* browser_context */) { | 14 content::BrowserContext* context) { |
14 return base::MakeUnique<StubNotificationDisplayService>(); | 15 return base::MakeUnique<StubNotificationDisplayService>( |
| 16 Profile::FromBrowserContext(context)); |
15 } | 17 } |
16 | 18 |
17 StubNotificationDisplayService::StubNotificationDisplayService() = default; | 19 StubNotificationDisplayService::StubNotificationDisplayService(Profile* profile) |
| 20 : NotificationDisplayService(profile) {} |
18 | 21 |
19 StubNotificationDisplayService::~StubNotificationDisplayService() = default; | 22 StubNotificationDisplayService::~StubNotificationDisplayService() = default; |
20 | 23 |
21 void StubNotificationDisplayService::RemoveNotification( | 24 void StubNotificationDisplayService::RemoveNotification( |
22 NotificationCommon::Type notification_type, | 25 NotificationCommon::Type notification_type, |
23 const std::string& notification_id, | 26 const std::string& notification_id, |
24 bool by_user) { | 27 bool by_user) { |
25 auto iter = std::find_if( | 28 auto iter = std::find_if( |
26 notifications_.begin(), notifications_.end(), | 29 notifications_.begin(), notifications_.end(), |
27 [notification_type, notification_id](const NotificationData& data) { | 30 [notification_type, notification_id](const NotificationData& data) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 void StubNotificationDisplayService::GetDisplayed( | 83 void StubNotificationDisplayService::GetDisplayed( |
81 const DisplayedNotificationsCallback& callback) { | 84 const DisplayedNotificationsCallback& callback) { |
82 std::unique_ptr<std::set<std::string>> notifications = | 85 std::unique_ptr<std::set<std::string>> notifications = |
83 base::MakeUnique<std::set<std::string>>(); | 86 base::MakeUnique<std::set<std::string>>(); |
84 | 87 |
85 for (const auto& notification_data : notifications_) | 88 for (const auto& notification_data : notifications_) |
86 notifications->insert(notification_data.second.delegate_id()); | 89 notifications->insert(notification_data.second.delegate_id()); |
87 | 90 |
88 callback.Run(std::move(notifications), true /* supports_synchronization */); | 91 callback.Run(std::move(notifications), true /* supports_synchronization */); |
89 } | 92 } |
OLD | NEW |