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_NOTIFICATION_EVENT_DISPATCHER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_ |
7 | 7 |
8 #include <stdint.h> | |
9 #include <string> | 8 #include <string> |
10 | 9 |
11 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
12 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
13 #include "content/public/common/persistent_notification_status.h" | 12 #include "content/public/common/persistent_notification_status.h" |
14 | 13 |
15 class GURL; | 14 class GURL; |
16 | 15 |
17 namespace content { | 16 namespace content { |
18 | 17 |
19 class BrowserContext; | 18 class BrowserContext; |
20 struct PlatformNotificationData; | |
21 | 19 |
22 // This is the dispatcher to be used for firing events related to persistent | 20 // This is the dispatcher to be used for firing events related to persistent |
23 // notifications on a Service Worker. This class is a singleton, the instance of | 21 // notifications on a Service Worker. This class is a singleton, the instance of |
24 // which can be retrieved using the static GetInstance() method. All methods | 22 // which can be retrieved using the static GetInstance() method. All methods |
25 // must be called on the UI thread. | 23 // must be called on the UI thread. |
26 class CONTENT_EXPORT NotificationEventDispatcher { | 24 class CONTENT_EXPORT NotificationEventDispatcher { |
27 public: | 25 public: |
28 static NotificationEventDispatcher* GetInstance(); | 26 static NotificationEventDispatcher* GetInstance(); |
29 | 27 |
30 using NotificationDispatchCompleteCallback = | 28 using NotificationDispatchCompleteCallback = |
31 base::Callback<void(PersistentNotificationStatus)>; | 29 base::Callback<void(PersistentNotificationStatus)>; |
32 | 30 |
33 // Dispatches the "notificationclick" event on the Service Worker associated | 31 // Dispatches the "notificationclick" event on the Service Worker associated |
34 // with |persistent_notification_id| belonging to |origin|. The |callback| | 32 // with |notification_id| belonging to |origin|. The |callback| will be |
35 // will be invoked when it's known whether the event successfully executed. | 33 // invoked when it's known whether the event successfully executed. |
36 virtual void DispatchNotificationClickEvent( | 34 virtual void DispatchNotificationClickEvent( |
37 BrowserContext* browser_context, | 35 BrowserContext* browser_context, |
38 int64_t persistent_notification_id, | 36 const std::string& notification_id, |
39 const GURL& origin, | 37 const GURL& origin, |
40 int action_index, | 38 int action_index, |
41 const NotificationDispatchCompleteCallback& | 39 const NotificationDispatchCompleteCallback& |
42 dispatch_complete_callback) = 0; | 40 dispatch_complete_callback) = 0; |
43 | 41 |
44 // Dispatches the "notificationclose" event on the Service Worker associated | 42 // Dispatches the "notificationclose" event on the Service Worker associated |
45 // with |persistent_notification_id| belonging to |origin|. The | 43 // with |notification_id| belonging to |origin|. The |
46 // |dispatch_complete_callback| will be invoked when it's known whether the | 44 // |dispatch_complete_callback| will be invoked when it's known whether the |
47 // event successfully executed. | 45 // event successfully executed. |
48 virtual void DispatchNotificationCloseEvent( | 46 virtual void DispatchNotificationCloseEvent( |
49 BrowserContext* browser_context, | 47 BrowserContext* browser_context, |
50 int64_t persistent_notification_id, | 48 const std::string& notification_id, |
51 const GURL& origin, | 49 const GURL& origin, |
52 bool by_user, | 50 bool by_user, |
53 const NotificationDispatchCompleteCallback& | 51 const NotificationDispatchCompleteCallback& |
54 dispatch_complete_callback) = 0; | 52 dispatch_complete_callback) = 0; |
55 | 53 |
56 protected: | 54 protected: |
57 virtual ~NotificationEventDispatcher() {} | 55 virtual ~NotificationEventDispatcher() {} |
58 }; | 56 }; |
59 | 57 |
60 } // namespace content | 58 } // namespace content |
61 | 59 |
62 #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_ | 60 #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_ |
OLD | NEW |