| 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" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/public/common/persistent_notification_status.h" | 12 #include "content/public/common/persistent_notification_status.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class BrowserContext; | 18 class BrowserContext; |
| 19 struct ShowDesktopNotificationHostMsgParams; | 19 struct PlatformNotificationData; |
| 20 | 20 |
| 21 // This is the dispatcher to be used for firing events related to persistent | 21 // This is the dispatcher to be used for firing events related to persistent |
| 22 // notifications on a Service Worker. This class is a singleton, the instance of | 22 // notifications on a Service Worker. This class is a singleton, the instance of |
| 23 // which can be retrieved using the static GetInstance() method. All methods | 23 // which can be retrieved using the static GetInstance() method. All methods |
| 24 // must be called on the UI thread. | 24 // must be called on the UI thread. |
| 25 class CONTENT_EXPORT NotificationEventDispatcher { | 25 class CONTENT_EXPORT NotificationEventDispatcher { |
| 26 public: | 26 public: |
| 27 static NotificationEventDispatcher* GetInstance(); | 27 static NotificationEventDispatcher* GetInstance(); |
| 28 | 28 |
| 29 using NotificationClickDispatchCompleteCallback = | 29 using NotificationClickDispatchCompleteCallback = |
| 30 base::Callback<void(PersistentNotificationStatus)>; | 30 base::Callback<void(PersistentNotificationStatus)>; |
| 31 | 31 |
| 32 // Dispatches the "notificationclick" event on the Service Worker associated | 32 // Dispatches the "notificationclick" event on the Service Worker associated |
| 33 // with |origin| and |service_worker_registration_id|. The |callback| will | 33 // with |origin| and |service_worker_registration_id|. The |callback| will |
| 34 // be invoked when it's known whether the event successfully executed. | 34 // be invoked when it's known whether the event successfully executed. |
| 35 virtual void DispatchNotificationClickEvent( | 35 virtual void DispatchNotificationClickEvent( |
| 36 BrowserContext* browser_context, | 36 BrowserContext* browser_context, |
| 37 const GURL& origin, | 37 const GURL& origin, |
| 38 int64 service_worker_registration_id, | 38 int64 service_worker_registration_id, |
| 39 const std::string& notification_id, | 39 const std::string& notification_id, |
| 40 const ShowDesktopNotificationHostMsgParams& notification_data, | 40 const PlatformNotificationData& notification_data, |
| 41 const NotificationClickDispatchCompleteCallback& | 41 const NotificationClickDispatchCompleteCallback& |
| 42 dispatch_complete_callback) = 0; | 42 dispatch_complete_callback) = 0; |
| 43 | 43 |
| 44 protected: | 44 protected: |
| 45 virtual ~NotificationEventDispatcher() {} | 45 virtual ~NotificationEventDispatcher() {} |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 } // namespace content | 48 } // namespace content |
| 49 | 49 |
| 50 #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_ | 50 #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_ |
| OLD | NEW |