| Index: chrome/browser/notifications/stub_notification_display_service.h
|
| diff --git a/chrome/browser/notifications/stub_notification_display_service.h b/chrome/browser/notifications/stub_notification_display_service.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e87800c34a4b3175419b85803055c7dbce18cfc4
|
| --- /dev/null
|
| +++ b/chrome/browser/notifications/stub_notification_display_service.h
|
| @@ -0,0 +1,57 @@
|
| +// Copyright 2017 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.
|
| +
|
| +#ifndef CHROME_BROWSER_NOTIFICATIONS_STUB_NOTIFICATION_DISPLAY_SERVICE_H_
|
| +#define CHROME_BROWSER_NOTIFICATIONS_STUB_NOTIFICATION_DISPLAY_SERVICE_H_
|
| +
|
| +#include <memory>
|
| +#include <utility>
|
| +#include <vector>
|
| +
|
| +#include "base/macros.h"
|
| +#include "chrome/browser/notifications/notification.h"
|
| +#include "chrome/browser/notifications/notification_common.h"
|
| +#include "chrome/browser/notifications/notification_display_service.h"
|
| +
|
| +// Implementation of the NotificationDisplayService interface that can be used
|
| +// for testing purposes. Supports additional methods enabling instrumenting the
|
| +// faked underlying notification system.
|
| +class StubNotificationDisplayService : public NotificationDisplayService {
|
| + public:
|
| + // Factory function to be used with NotificationDisplayServiceFactory's
|
| + // SetTestingFactory method, overriding the default display service.
|
| + static std::unique_ptr<KeyedService> FactoryForTests(
|
| + content::BrowserContext* browser_context);
|
| +
|
| + StubNotificationDisplayService();
|
| + ~StubNotificationDisplayService() override;
|
| +
|
| + // Removes the notification identified by |notification_id|.
|
| + void RemoveNotification(NotificationCommon::Type notification_type,
|
| + const std::string& notification_id,
|
| + bool by_user);
|
| +
|
| + // Removes all notifications shown by this display service.
|
| + void RemoveAllNotifications(NotificationCommon::Type notification_type,
|
| + bool by_user);
|
| +
|
| + // NotificationDisplayService implementation:
|
| + void Display(NotificationCommon::Type notification_type,
|
| + const std::string& notification_id,
|
| + const Notification& notification) override;
|
| + void Close(NotificationCommon::Type notification_type,
|
| + const std::string& notification_id) override;
|
| + void GetDisplayed(
|
| + const DisplayedNotificationsCallback& callback) const override;
|
| +
|
| + private:
|
| + // Data to store for a notification that's being shown through this service.
|
| + using NotificationData = std::pair<NotificationCommon::Type, Notification>;
|
| +
|
| + std::vector<NotificationData> notifications_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(StubNotificationDisplayService);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_NOTIFICATIONS_STUB_NOTIFICATION_DISPLAY_SERVICE_H_
|
|
|