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_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ | 5 #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ |
6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ | 6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
8 #include <map> | 9 #include <map> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/callback.h" | 12 #include "base/callback.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
14 #include "content/public/browser/platform_notification_service.h" | 15 #include "content/public/browser/platform_notification_service.h" |
15 #include "content/public/common/permission_status.mojom.h" | 16 #include "content/public/common/permission_status.mojom.h" |
16 #include "content/public/common/platform_notification_data.h" | |
17 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onPermission.h" | 17 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onPermission.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 class DesktopNotificationDelegate; | 22 class DesktopNotificationDelegate; |
23 struct PlatformNotificationData; | 23 struct PlatformNotificationData; |
24 | 24 |
25 // Responsible for tracking active notifications and allowed origins for the | 25 // Responsible for tracking active notifications and allowed origins for the |
26 // Web Notification API when running layout tests. | 26 // Web Notification API when running layout tests. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const GURL& origin, | 63 const GURL& origin, |
64 int render_process_id) override; | 64 int render_process_id) override; |
65 void DisplayNotification(BrowserContext* browser_context, | 65 void DisplayNotification(BrowserContext* browser_context, |
66 const GURL& origin, | 66 const GURL& origin, |
67 const SkBitmap& icon, | 67 const SkBitmap& icon, |
68 const PlatformNotificationData& notification_data, | 68 const PlatformNotificationData& notification_data, |
69 scoped_ptr<DesktopNotificationDelegate> delegate, | 69 scoped_ptr<DesktopNotificationDelegate> delegate, |
70 base::Closure* cancel_callback) override; | 70 base::Closure* cancel_callback) override; |
71 void DisplayPersistentNotification( | 71 void DisplayPersistentNotification( |
72 BrowserContext* browser_context, | 72 BrowserContext* browser_context, |
73 int64 service_worker_registration_id, | 73 int64_t persistent_notification_id, |
74 const GURL& origin, | 74 const GURL& origin, |
75 const SkBitmap& icon, | 75 const SkBitmap& icon, |
76 const PlatformNotificationData& notification_data) override; | 76 const PlatformNotificationData& notification_data) override; |
77 void ClosePersistentNotification( | 77 void ClosePersistentNotification( |
78 BrowserContext* browser_context, | 78 BrowserContext* browser_context, |
79 const std::string& persistent_notification_id) override; | 79 int64_t persistent_notification_id) override; |
80 | 80 |
81 private: | 81 private: |
82 // Closes the notification titled |title|. Must be called on the UI thread. | 82 // Closes the notification titled |title|. Must be called on the UI thread. |
83 void Close(const std::string& title); | 83 void Close(const std::string& title); |
84 | 84 |
85 // Fakes replacing the notification identified by |params| when it has a tag | 85 // Fakes replacing the notification identified by |params| when it has a tag |
86 // and a previous notification has been displayed using the same tag. All | 86 // and a previous notification has been displayed using the same tag. All |
87 // notifications, both page and persistent ones, will be considered for this. | 87 // notifications, both page and persistent ones, will be considered for this. |
88 void ReplaceNotificationIfNeeded( | 88 void ReplaceNotificationIfNeeded( |
89 const PlatformNotificationData& notification_data); | 89 const PlatformNotificationData& notification_data); |
90 | 90 |
91 // Structure to represent the information of a persistent notification. | 91 // Structure to represent the information of a persistent notification. |
92 struct PersistentNotification { | 92 struct PersistentNotification { |
93 PersistentNotification(); | 93 BrowserContext* browser_context = nullptr; |
94 | |
95 BrowserContext* browser_context; | |
96 GURL origin; | 94 GURL origin; |
97 int64 service_worker_registration_id; | 95 int64_t persistent_id = 0; |
98 PlatformNotificationData notification_data; | |
99 std::string persistent_id; | |
100 }; | 96 }; |
101 | 97 |
102 std::map<GURL, blink::WebNotificationPermission> permission_map_; | 98 std::map<GURL, blink::WebNotificationPermission> permission_map_; |
103 base::Lock permission_lock_; | 99 base::Lock permission_lock_; |
104 | 100 |
105 std::map<std::string, DesktopNotificationDelegate*> page_notifications_; | 101 std::map<std::string, DesktopNotificationDelegate*> page_notifications_; |
106 std::map<std::string, PersistentNotification> persistent_notifications_; | 102 std::map<std::string, PersistentNotification> persistent_notifications_; |
107 | 103 |
108 std::map<std::string, std::string> replacements_; | 104 std::map<std::string, std::string> replacements_; |
109 | 105 |
110 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_; | 106 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_; |
111 | 107 |
112 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager); | 108 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager); |
113 }; | 109 }; |
114 | 110 |
115 } // content | 111 } // content |
116 | 112 |
117 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ | 113 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ |
OLD | NEW |