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_PLATFORM_NOTIFICATION_SERVICE_H_
6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_
12 #include "base/callback_forward.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "content/common/content_export.h"
15 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificationPermission.h"
23 class DesktopNotificationDelegate
;
24 struct PlatformNotificationData
;
25 class ResourceContext
;
27 // The service using which notifications can be presented to the user. There
28 // should be a unique instance of the PlatformNotificationService depending
29 // on the browsing context being used.
30 class CONTENT_EXPORT PlatformNotificationService
{
32 virtual ~PlatformNotificationService() {}
34 // Checks if |origin| has permission to display Web Notifications.
35 // This method must only be called on the UI thread.
36 virtual blink::WebNotificationPermission
CheckPermissionOnUIThread(
37 BrowserContext
* browser_context
,
39 int render_process_id
) = 0;
41 // Checks if |origin| has permission to display Web Notifications. This method
42 // exists to serve the synchronous IPC required by the Notification.permission
43 // JavaScript getter, and should not be used for other purposes. See
44 // https://crbug.com/446497 for the plan to deprecate this method.
45 // This method must only be called on the IO thread.
46 virtual blink::WebNotificationPermission
CheckPermissionOnIOThread(
47 ResourceContext
* resource_context
,
49 int render_process_id
) = 0;
51 // Displays the notification described in |params| to the user. A closure
52 // through which the notification can be closed will be stored in the
53 // |cancel_callback| argument. This method must be called on the UI thread.
54 virtual void DisplayNotification(
55 BrowserContext
* browser_context
,
58 const PlatformNotificationData
& notification_data
,
59 scoped_ptr
<DesktopNotificationDelegate
> delegate
,
60 base::Closure
* cancel_callback
) = 0;
62 // Displays the persistent notification described in |notification_data| to
63 // the user. This method must be called on the UI thread.
64 virtual void DisplayPersistentNotification(
65 BrowserContext
* browser_context
,
66 int64_t persistent_notification_id
,
69 const PlatformNotificationData
& notification_data
) = 0;
71 // Closes the persistent notification identified by
72 // |persistent_notification_id|. This method must be called on the UI thread.
73 virtual void ClosePersistentNotification(
74 BrowserContext
* browser_context
,
75 int64_t persistent_notification_id
) = 0;
77 // Writes the ids of all currently displaying persistent notifications for the
78 // given |browser_context| to |displayed_notifications|. Returns whether the
79 // platform is able to provide such a set.
80 virtual bool GetDisplayedPersistentNotifications(
81 BrowserContext
* browser_context
,
82 std::set
<std::string
>* displayed_notifications
) = 0;
85 } // namespace content
87 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_