OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <set> | 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 | 11 |
| 12 #include "base/callback_forward.h" |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
12 #include "chrome/browser/notifications/notification_common.h" | 14 #include "chrome/browser/notifications/notification_common.h" |
13 #include "components/keyed_service/core/keyed_service.h" | 15 #include "components/keyed_service/core/keyed_service.h" |
14 | 16 |
15 class Notification; | 17 class Notification; |
16 class Profile; | 18 class Profile; |
17 | 19 |
18 // Profile-bound service that enables notifications to be displayed and | 20 // Profile-bound service that enables notifications to be displayed and |
19 // interacted with on the user's screen, orthogonal of whether this | 21 // interacted with on the user's screen, orthogonal of whether this |
20 // functionality is provided by the browser or by the operating system. An | 22 // functionality is provided by the browser or by the operating system. An |
21 // instance can be retrieved through the NotificationDisplayServiceFactory. | 23 // instance can be retrieved through the NotificationDisplayServiceFactory. |
22 // | 24 // |
23 // TODO(peter): Add a NotificationHandler mechanism for registering listeners. | 25 // TODO(peter): Add a NotificationHandler mechanism for registering listeners. |
24 // TODO(miguelg): Remove the SupportsNotificationCenter method. | |
25 class NotificationDisplayService : public KeyedService { | 26 class NotificationDisplayService : public KeyedService { |
26 public: | 27 public: |
| 28 using DisplayedNotificationsCallback = |
| 29 base::Callback<void(std::unique_ptr<std::set<std::string>>, |
| 30 bool /* supports_synchronization */)>; |
27 NotificationDisplayService() {} | 31 NotificationDisplayService() {} |
28 ~NotificationDisplayService() override {} | 32 ~NotificationDisplayService() override {} |
29 | 33 |
30 // Displays the |notification| identified by |notification_id|. | 34 // Displays the |notification| identified by |notification_id|. |
31 virtual void Display(NotificationCommon::Type notification_type, | 35 virtual void Display(NotificationCommon::Type notification_type, |
32 const std::string& notification_id, | 36 const std::string& notification_id, |
33 const Notification& notification) = 0; | 37 const Notification& notification) = 0; |
34 | 38 |
35 // Closes the notification identified by |notification_id|. | 39 // Closes the notification identified by |notification_id|. |
36 virtual void Close(NotificationCommon::Type notification_type, | 40 virtual void Close(NotificationCommon::Type notification_type, |
37 const std::string& notification_id) = 0; | 41 const std::string& notification_id) = 0; |
38 | 42 |
39 // Returns whether the implementation can retrieve a list of currently visible | 43 // Writes the ids of all currently displaying notifications and |
40 // notifications and stores them in |*notification_ids| when possible. | 44 // invokes |callback| with the result once known. |
41 virtual bool GetDisplayed(std::set<std::string>* notifications) const = 0; | 45 virtual void GetDisplayed( |
| 46 const DisplayedNotificationsCallback& callback) const = 0; |
42 | 47 |
43 private: | 48 private: |
44 DISALLOW_COPY_AND_ASSIGN(NotificationDisplayService); | 49 DISALLOW_COPY_AND_ASSIGN(NotificationDisplayService); |
45 }; | 50 }; |
46 | 51 |
47 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ | 52 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ |
OLD | NEW |