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_
11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/common/content_export.h"
14 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificationPermission.h"
22 class DesktopNotificationDelegate
;
23 struct PlatformNotificationData
;
24 class ResourceContext
;
26 // The service using which notifications can be presented to the user. There
27 // should be a unique instance of the PlatformNotificationService depending
28 // on the browsing context being used.
29 class CONTENT_EXPORT PlatformNotificationService
{
31 virtual ~PlatformNotificationService() {}
33 // Checks if |origin| has permission to display Web Notifications.
34 // This method must only be called on the UI thread.
35 virtual blink::WebNotificationPermission
CheckPermissionOnUIThread(
36 BrowserContext
* browser_context
,
38 int render_process_id
) = 0;
40 // Checks if |origin| has permission to display Web Notifications. This method
41 // exists to serve the synchronous IPC required by the Notification.permission
42 // JavaScript getter, and should not be used for other purposes. See
43 // https://crbug.com/446497 for the plan to deprecate this method.
44 // This method must only be called on the IO thread.
45 virtual blink::WebNotificationPermission
CheckPermissionOnIOThread(
46 ResourceContext
* resource_context
,
48 int render_process_id
) = 0;
50 // Displays the notification described in |params| to the user. A closure
51 // through which the notification can be closed will be stored in the
52 // |cancel_callback| argument. This method must be called on the UI thread.
53 virtual void DisplayNotification(
54 BrowserContext
* browser_context
,
57 const PlatformNotificationData
& notification_data
,
58 scoped_ptr
<DesktopNotificationDelegate
> delegate
,
59 base::Closure
* cancel_callback
) = 0;
61 // Displays the persistent notification described in |notification_data| to
62 // the user. This method must be called on the UI thread.
63 virtual void DisplayPersistentNotification(
64 BrowserContext
* browser_context
,
65 int64_t persistent_notification_id
,
68 const PlatformNotificationData
& notification_data
) = 0;
70 // Closes the persistent notification identified by
71 // |persistent_notification_id|. This method must be called on the UI thread.
72 virtual void ClosePersistentNotification(
73 BrowserContext
* browser_context
,
74 int64_t persistent_notification_id
) = 0;
77 } // namespace content
79 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_