OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 15 matching lines...) Expand all Loading... |
26 struct PlatformNotificationData; | 26 struct PlatformNotificationData; |
27 class ResourceContext; | 27 class ResourceContext; |
28 | 28 |
29 // The service using which notifications can be presented to the user. There | 29 // The service using which notifications can be presented to the user. There |
30 // should be a unique instance of the PlatformNotificationService depending | 30 // should be a unique instance of the PlatformNotificationService depending |
31 // on the browsing context being used. | 31 // on the browsing context being used. |
32 class CONTENT_EXPORT PlatformNotificationService { | 32 class CONTENT_EXPORT PlatformNotificationService { |
33 public: | 33 public: |
34 virtual ~PlatformNotificationService() {} | 34 virtual ~PlatformNotificationService() {} |
35 | 35 |
| 36 using DisplayedNotificationsCallback = |
| 37 base::Callback<void(std::unique_ptr<std::set<std::string>>, |
| 38 bool /* supports synchronization */)>; |
| 39 |
36 // Checks if |origin| has permission to display Web Notifications. | 40 // Checks if |origin| has permission to display Web Notifications. |
37 // This method must only be called on the UI thread. | 41 // This method must only be called on the UI thread. |
38 virtual blink::mojom::PermissionStatus CheckPermissionOnUIThread( | 42 virtual blink::mojom::PermissionStatus CheckPermissionOnUIThread( |
39 BrowserContext* browser_context, | 43 BrowserContext* browser_context, |
40 const GURL& origin, | 44 const GURL& origin, |
41 int render_process_id) = 0; | 45 int render_process_id) = 0; |
42 | 46 |
43 // Checks if |origin| has permission to display Web Notifications. This method | 47 // Checks if |origin| has permission to display Web Notifications. This method |
44 // exists to serve the synchronous IPC required by the Notification.permission | 48 // exists to serve the synchronous IPC required by the Notification.permission |
45 // JavaScript getter, and should not be used for other purposes. See | 49 // JavaScript getter, and should not be used for other purposes. See |
(...skipping 25 matching lines...) Expand all Loading... |
71 const GURL& origin, | 75 const GURL& origin, |
72 const PlatformNotificationData& notification_data, | 76 const PlatformNotificationData& notification_data, |
73 const NotificationResources& notification_resources) = 0; | 77 const NotificationResources& notification_resources) = 0; |
74 | 78 |
75 // Closes the persistent notification identified by | 79 // Closes the persistent notification identified by |
76 // |persistent_notification_id|. This method must be called on the UI thread. | 80 // |persistent_notification_id|. This method must be called on the UI thread. |
77 virtual void ClosePersistentNotification( | 81 virtual void ClosePersistentNotification( |
78 BrowserContext* browser_context, | 82 BrowserContext* browser_context, |
79 const std::string& notification_id) = 0; | 83 const std::string& notification_id) = 0; |
80 | 84 |
81 // Writes the ids of all currently displaying notifications for the | 85 // Retrieves the ids of all currently displaying notifications and |
82 // given |browser_context| to |displayed_notifications|. Returns whether the | 86 // posts |callback| with the result. |
83 // platform is able to provide such a set. | 87 virtual void GetDisplayedNotifications( |
84 virtual bool GetDisplayedNotifications( | |
85 BrowserContext* browser_context, | 88 BrowserContext* browser_context, |
86 std::set<std::string>* displayed_notifications) = 0; | 89 const DisplayedNotificationsCallback& callback) = 0; |
87 }; | 90 }; |
88 | 91 |
89 } // namespace content | 92 } // namespace content |
90 | 93 |
91 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ | 94 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ |
OLD | NEW |