Chromium Code Reviews| 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_PLATFORM_NOTIFICATION_SERVICE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | |
| 9 #include <string> | 8 #include <string> |
| 10 | 9 |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 14 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onPermission.h" | 11 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onPermission.h" |
| 15 | 12 |
| 16 class GURL; | 13 class GURL; |
| 17 class SkBitmap; | 14 |
| 15 namespace message_center { | |
| 16 class Notification; | |
| 17 } | |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class BrowserContext; | 21 class BrowserContext; |
| 22 class DesktopNotificationDelegate; | |
| 23 struct PlatformNotificationData; | |
| 24 class ResourceContext; | 22 class ResourceContext; |
| 25 | 23 |
| 26 // The service using which notifications can be presented to the user. There | 24 // Interface for the service through which platform notifications can be |
| 27 // should be a unique instance of the PlatformNotificationService depending | 25 // presented to the user. |
| 28 // on the browsing context being used. | |
| 29 class CONTENT_EXPORT PlatformNotificationService { | 26 class CONTENT_EXPORT PlatformNotificationService { |
| 30 public: | 27 public: |
| 31 virtual ~PlatformNotificationService() {} | 28 virtual ~PlatformNotificationService() {} |
| 32 | 29 |
| 33 // Checks if |origin| has permission to display Web Notifications. | 30 // Checks if |origin| has permission to display Web Notifications. |
| 34 // This method must only be called on the UI thread. | 31 // This method must only be called on the UI thread. |
| 35 virtual blink::WebNotificationPermission CheckPermissionOnUIThread( | 32 virtual blink::WebNotificationPermission CheckPermissionOnUIThread( |
| 36 BrowserContext* browser_context, | 33 BrowserContext* browser_context, |
| 37 const GURL& origin, | 34 const GURL& origin, |
| 38 int render_process_id) = 0; | 35 int render_process_id) = 0; |
| 39 | 36 |
| 40 // Checks if |origin| has permission to display Web Notifications. This method | 37 // Checks if |origin| has permission to display Web Notifications. This method |
| 41 // exists to serve the synchronous IPC required by the Notification.permission | 38 // exists to serve the synchronous IPC required by the Notification.permission |
| 42 // JavaScript getter, and should not be used for other purposes. See | 39 // JavaScript getter, and should not be used for other purposes. See |
| 43 // https://crbug.com/446497 for the plan to deprecate this method. | 40 // https://crbug.com/446497 for the plan to deprecate this method. |
| 44 // This method must only be called on the IO thread. | 41 // This method must only be called on the IO thread. |
| 45 virtual blink::WebNotificationPermission CheckPermissionOnIOThread( | 42 virtual blink::WebNotificationPermission CheckPermissionOnIOThread( |
| 46 ResourceContext* resource_context, | 43 ResourceContext* resource_context, |
| 47 const GURL& origin, | 44 const GURL& origin, |
| 48 int render_process_id) = 0; | 45 int render_process_id) = 0; |
| 49 | 46 |
| 50 // Displays the notification described in |params| to the user. A closure | 47 // Displays the |notification| to the user. This method must be called on the |
|
dewittj
2015/05/02 18:43:29
I like the simplification. If layering is an issu
| |
| 51 // through which the notification can be closed will be stored in the | 48 // UI thread. |
| 52 // |cancel_callback| argument. This method must be called on the UI thread. | |
| 53 virtual void DisplayNotification( | 49 virtual void DisplayNotification( |
| 54 BrowserContext* browser_context, | 50 BrowserContext* browser_context, |
| 55 const GURL& origin, | 51 const message_center::Notification& notification) = 0; |
| 56 const SkBitmap& icon, | |
| 57 const PlatformNotificationData& notification_data, | |
| 58 scoped_ptr<DesktopNotificationDelegate> delegate, | |
| 59 base::Closure* cancel_callback) = 0; | |
| 60 | 52 |
| 61 // Displays the persistent notification described in |notification_data| to | 53 // Ensures that the notification identified by |notification_id| will be |
| 62 // the user. This method must be called on the UI thread. | 54 // closed for the user. This method must be called on the UI thread. |
| 63 virtual void DisplayPersistentNotification( | 55 virtual void CloseNotification(BrowserContext* browser_context, |
| 64 BrowserContext* browser_context, | 56 const std::string& notification_id) = 0; |
| 65 int64_t persistent_notification_id, | |
| 66 const GURL& origin, | |
| 67 const SkBitmap& icon, | |
| 68 const PlatformNotificationData& notification_data) = 0; | |
| 69 | |
| 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; | |
| 75 }; | 57 }; |
| 76 | 58 |
| 77 } // namespace content | 59 } // namespace content |
| 78 | 60 |
| 79 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ | 61 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_ |
| OLD | NEW |