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_PLATFORM_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/callback_forward.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "chrome/browser/notifications/notification_common.h" | 13 #include "chrome/browser/notifications/notification_common.h" |
13 | 14 |
14 class Notification; | 15 class Notification; |
15 | 16 |
16 // Provides the low-level interface that enables notifications to be displayed | 17 // Provides the low-level interface that enables notifications to be displayed |
17 // and interacted with on the user's screen, orthogonal of whether this | 18 // and interacted with on the user's screen, orthogonal of whether this |
18 // functionality is provided by the browser or by the operating system. | 19 // functionality is provided by the browser or by the operating system. |
19 // TODO(miguelg): Add support for click and close events. | 20 // TODO(miguelg): Add support for click and close events. |
20 class NotificationPlatformBridge { | 21 class NotificationPlatformBridge { |
21 public: | 22 public: |
| 23 using DisplayedNotificationsCallback = |
| 24 base::Callback<void(std::unique_ptr<std::set<std::string>>, |
| 25 bool /* supports_synchronization */)>; |
| 26 |
22 static NotificationPlatformBridge* Create(); | 27 static NotificationPlatformBridge* Create(); |
23 | 28 |
24 virtual ~NotificationPlatformBridge() {} | 29 virtual ~NotificationPlatformBridge() {} |
25 | 30 |
26 // Shows a toast on screen using the data passed in |notification|. | 31 // Shows a toast on screen using the data passed in |notification|. |
27 virtual void Display(NotificationCommon::Type notification_type, | 32 virtual void Display(NotificationCommon::Type notification_type, |
28 const std::string& notification_id, | 33 const std::string& notification_id, |
29 const std::string& profile_id, | 34 const std::string& profile_id, |
30 bool is_incognito, | 35 bool is_incognito, |
31 const Notification& notification) = 0; | 36 const Notification& notification) = 0; |
32 | 37 |
33 // Closes a nofication with |notification_id| and |profile_id| if being | 38 // Closes a nofication with |notification_id| and |profile_id| if being |
34 // displayed. | 39 // displayed. |
35 virtual void Close(const std::string& profile_id, | 40 virtual void Close(const std::string& profile_id, |
36 const std::string& notification_id) = 0; | 41 const std::string& notification_id) = 0; |
37 | 42 |
38 // Fills in |notifications| with a set of notification ids currently being | 43 // Writes the ids of all currently displaying notifications and posts |
39 // displayed for a given profile. | 44 // |callback| with the result. |
40 // The return value expresses whether the underlying platform has the | 45 virtual void GetDisplayed( |
41 // capability to provide displayed notifications so the empty set | 46 const std::string& profile_id, |
42 // can be disambiguated. | 47 bool incognito, |
43 virtual bool GetDisplayed(const std::string& profile_id, | 48 const DisplayedNotificationsCallback& callback) const = 0; |
44 bool incognito, | |
45 std::set<std::string>* notification_ids) const = 0; | |
46 | 49 |
47 protected: | 50 protected: |
48 NotificationPlatformBridge() {} | 51 NotificationPlatformBridge() {} |
49 | 52 |
50 private: | 53 private: |
51 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridge); | 54 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridge); |
52 }; | 55 }; |
53 | 56 |
54 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ | 57 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ |
OLD | NEW |