Popular sites on the NTP: Try to keep the ordering constant
[chromium-blink-merge.git] / content / public / browser / notification_event_dispatcher.h
blobbb3df945e2364e89cf3eb712087fe24ffe35b635
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_
6 #define CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_
8 #include <stdint.h>
9 #include <string>
11 #include "base/callback_forward.h"
12 #include "content/common/content_export.h"
13 #include "content/public/common/persistent_notification_status.h"
15 class GURL;
17 namespace content {
19 class BrowserContext;
20 struct PlatformNotificationData;
22 // 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
24 // which can be retrieved using the static GetInstance() method. All methods
25 // must be called on the UI thread.
26 class CONTENT_EXPORT NotificationEventDispatcher {
27 public:
28 static NotificationEventDispatcher* GetInstance();
30 using NotificationClickDispatchCompleteCallback =
31 base::Callback<void(PersistentNotificationStatus)>;
33 // Dispatches the "notificationclick" event on the Service Worker associated
34 // with |persistent_notification_id| belonging to |origin|. The |callback|
35 // will be invoked when it's known whether the event successfully executed.
36 virtual void DispatchNotificationClickEvent(
37 BrowserContext* browser_context,
38 int64_t persistent_notification_id,
39 const GURL& origin,
40 int action_index,
41 const NotificationClickDispatchCompleteCallback&
42 dispatch_complete_callback) = 0;
44 protected:
45 virtual ~NotificationEventDispatcher() {}
48 } // namespace content
50 #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_EVENT_DISPATCHER_H_