OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/test/mock_platform_notification_service.h" | 5 #include "content/test/mock_platform_notification_service.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/strings/nullable_string16.h" | 8 #include "base/strings/nullable_string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 void MockPlatformNotificationService::ClosePersistentNotification( | 75 void MockPlatformNotificationService::ClosePersistentNotification( |
76 BrowserContext* browser_context, | 76 BrowserContext* browser_context, |
77 const std::string& notification_id) { | 77 const std::string& notification_id) { |
78 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 78 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
79 | 79 |
80 persistent_notifications_.erase(notification_id); | 80 persistent_notifications_.erase(notification_id); |
81 } | 81 } |
82 | 82 |
83 bool MockPlatformNotificationService::GetDisplayedNotifications( | 83 void MockPlatformNotificationService::GetDisplayedNotifications( |
84 BrowserContext* browser_context, | 84 BrowserContext* browser_context, |
85 std::set<std::string>* displayed_notifications) { | 85 const DisplayedNotificationsCallback& callback) { |
86 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 86 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
87 DCHECK(displayed_notifications); | 87 auto displayed_notifications = base::MakeUnique<std::set<std::string>>(); |
88 | 88 |
89 for (const auto& kv : persistent_notifications_) | 89 for (const auto& kv : persistent_notifications_) |
90 displayed_notifications->insert(kv.first); | 90 displayed_notifications->insert(kv.first); |
91 | 91 |
92 return true; | 92 BrowserThread::PostTask( |
| 93 content::BrowserThread::UI, FROM_HERE, |
| 94 base::Bind(callback, base::Passed(&displayed_notifications), |
| 95 true /* supports_synchronization */)); |
93 } | 96 } |
94 | 97 |
95 void MockPlatformNotificationService::SimulateClick( | 98 void MockPlatformNotificationService::SimulateClick( |
96 const std::string& title, | 99 const std::string& title, |
97 int action_index, | 100 int action_index, |
98 const base::NullableString16& reply) { | 101 const base::NullableString16& reply) { |
99 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 102 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
100 | 103 |
101 const auto notification_id_iter = notification_id_map_.find(title); | 104 const auto notification_id_iter = notification_id_map_.find(title); |
102 if (notification_id_iter == notification_id_map_.end()) | 105 if (notification_id_iter == notification_id_map_.end()) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 non_persistent_notifications_.erase(non_persistent_iter); | 190 non_persistent_notifications_.erase(non_persistent_iter); |
188 } | 191 } |
189 } | 192 } |
190 | 193 |
191 blink::mojom::PermissionStatus MockPlatformNotificationService::CheckPermission( | 194 blink::mojom::PermissionStatus MockPlatformNotificationService::CheckPermission( |
192 const GURL& origin) { | 195 const GURL& origin) { |
193 return blink::mojom::PermissionStatus::GRANTED; | 196 return blink::mojom::PermissionStatus::GRANTED; |
194 } | 197 } |
195 | 198 |
196 } // namespace content | 199 } // namespace content |
OLD | NEW |