| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_STUB_NOTIFICATION_DISPLAY_SERVICE_H_ |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_STUB_NOTIFICATION_DISPLAY_SERVICE_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <utility> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "chrome/browser/notifications/notification.h" |
| 14 #include "chrome/browser/notifications/notification_common.h" |
| 15 #include "chrome/browser/notifications/notification_display_service.h" |
| 16 |
| 17 // Implementation of the NotificationDisplayService interface that can be used |
| 18 // for testing purposes. Supports additional methods enabling instrumenting the |
| 19 // faked underlying notification system. |
| 20 class StubNotificationDisplayService : public NotificationDisplayService { |
| 21 public: |
| 22 // Factory function to be used with NotificationDisplayServiceFactory's |
| 23 // SetTestingFactory method, overriding the default display service. |
| 24 static std::unique_ptr<KeyedService> FactoryForTests( |
| 25 content::BrowserContext* browser_context); |
| 26 |
| 27 StubNotificationDisplayService(); |
| 28 ~StubNotificationDisplayService() override; |
| 29 |
| 30 // Removes the notification identified by |notification_id|. |
| 31 void RemoveNotification(NotificationCommon::Type notification_type, |
| 32 const std::string& notification_id, |
| 33 bool by_user); |
| 34 |
| 35 // Removes all notifications shown by this display service. |
| 36 void RemoveAllNotifications(NotificationCommon::Type notification_type, |
| 37 bool by_user); |
| 38 |
| 39 // NotificationDisplayService implementation: |
| 40 void Display(NotificationCommon::Type notification_type, |
| 41 const std::string& notification_id, |
| 42 const Notification& notification) override; |
| 43 void Close(NotificationCommon::Type notification_type, |
| 44 const std::string& notification_id) override; |
| 45 void GetDisplayed( |
| 46 const DisplayedNotificationsCallback& callback) const override; |
| 47 |
| 48 private: |
| 49 // Data to store for a notification that's being shown through this service. |
| 50 using NotificationData = std::pair<NotificationCommon::Type, Notification>; |
| 51 |
| 52 std::vector<NotificationData> notifications_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(StubNotificationDisplayService); |
| 55 }; |
| 56 |
| 57 #endif // CHROME_BROWSER_NOTIFICATIONS_STUB_NOTIFICATION_DISPLAY_SERVICE_H_ |
| OLD | NEW |