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