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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // notifications on a Service Worker. This class is a singleton, the instance of | 25 // notifications on a Service Worker. This class is a singleton, the instance of |
26 // which can be retrieved using the static GetInstance() method. All methods | 26 // which can be retrieved using the static GetInstance() method. All methods |
27 // must be called on the UI thread. | 27 // must be called on the UI thread. |
28 class CONTENT_EXPORT NotificationEventDispatcher { | 28 class CONTENT_EXPORT NotificationEventDispatcher { |
29 public: | 29 public: |
30 static NotificationEventDispatcher* GetInstance(); | 30 static NotificationEventDispatcher* GetInstance(); |
31 | 31 |
32 using NotificationDispatchCompleteCallback = | 32 using NotificationDispatchCompleteCallback = |
33 base::Callback<void(PersistentNotificationStatus)>; | 33 base::Callback<void(PersistentNotificationStatus)>; |
34 | 34 |
| 35 // Dispatch methods for persistent (SW backed) notifications. |
| 36 // TODO(miguelg) consider merging them with the non persistent ones below. |
| 37 |
35 // Dispatches the "notificationclick" event on the Service Worker associated | 38 // Dispatches the "notificationclick" event on the Service Worker associated |
36 // with |notification_id| belonging to |origin|. The |callback| will be | 39 // with |notification_id| belonging to |origin|. The |callback| will be |
37 // invoked when it's known whether the event successfully executed. | 40 // invoked when it's known whether the event successfully executed. |
38 virtual void DispatchNotificationClickEvent( | 41 virtual void DispatchNotificationClickEvent( |
39 BrowserContext* browser_context, | 42 BrowserContext* browser_context, |
40 const std::string& notification_id, | 43 const std::string& notification_id, |
41 const GURL& origin, | 44 const GURL& origin, |
42 int action_index, | 45 int action_index, |
43 const base::NullableString16& reply, | 46 const base::NullableString16& reply, |
44 const NotificationDispatchCompleteCallback& | 47 const NotificationDispatchCompleteCallback& |
45 dispatch_complete_callback) = 0; | 48 dispatch_complete_callback) = 0; |
46 | 49 |
47 // Dispatches the "notificationclose" event on the Service Worker associated | 50 // Dispatches the "notificationclose" event on the Service Worker associated |
48 // with |notification_id| belonging to |origin|. The | 51 // with |notification_id| belonging to |origin|. The |
49 // |dispatch_complete_callback| will be invoked when it's known whether the | 52 // |dispatch_complete_callback| will be invoked when it's known whether the |
50 // event successfully executed. | 53 // event successfully executed. |
51 virtual void DispatchNotificationCloseEvent( | 54 virtual void DispatchNotificationCloseEvent( |
52 BrowserContext* browser_context, | 55 BrowserContext* browser_context, |
53 const std::string& notification_id, | 56 const std::string& notification_id, |
54 const GURL& origin, | 57 const GURL& origin, |
55 bool by_user, | 58 bool by_user, |
56 const NotificationDispatchCompleteCallback& | 59 const NotificationDispatchCompleteCallback& |
57 dispatch_complete_callback) = 0; | 60 dispatch_complete_callback) = 0; |
58 | 61 |
| 62 // Dispatch methods for the different non persistent (not backed by a service |
| 63 // worker) notification events. |
| 64 virtual void DispatchNonPersistentShowEvent( |
| 65 const std::string& notification_id) = 0; |
| 66 virtual void DispatchNonPersistentClickEvent( |
| 67 const std::string& notification_id) = 0; |
| 68 virtual void DispatchNonPersistentCloseEvent( |
| 69 const std::string& notification_id) = 0; |
| 70 |
59 protected: | 71 protected: |
60 virtual ~NotificationEventDispatcher() {} | 72 virtual ~NotificationEventDispatcher() {} |
61 }; | 73 }; |
62 | 74 |
63 } // namespace content | 75 } // namespace content |
64 | 76 |
65 #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_ | 77 #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_ |
OLD | NEW |