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

Unified Diff: chrome/browser/notifications/stub_notification_display_service.h

Issue 2703213004: Migrate extension notifications to the new NotificationDisplayService (Closed)
Patch Set: Migrate extension notifications to the new NotificationDisplayService Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698