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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "content/public/browser/platform_notification_service.h" | 13 #include "content/public/browser/platform_notification_service.h" |
| 14 #include "content/public/common/show_desktop_notification_params.h" |
14 #include "third_party/WebKit/public/platform/WebNotificationPermission.h" | 15 #include "third_party/WebKit/public/platform/WebNotificationPermission.h" |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 struct ShowDesktopNotificationHostMsgParams; | |
20 class DesktopNotificationDelegate; | 20 class DesktopNotificationDelegate; |
21 | 21 |
22 // Responsible for tracking active notifications and allowed origins for the | 22 // Responsible for tracking active notifications and allowed origins for the |
23 // Web Notification API when running layout tests. | 23 // Web Notification API when running layout tests. |
24 class LayoutTestNotificationManager : public PlatformNotificationService { | 24 class LayoutTestNotificationManager : public PlatformNotificationService { |
25 public: | 25 public: |
26 LayoutTestNotificationManager(); | 26 LayoutTestNotificationManager(); |
27 ~LayoutTestNotificationManager() override; | 27 ~LayoutTestNotificationManager() override; |
28 | 28 |
29 // Requests permission for |origin| to display notifications in layout tests. | 29 // Requests permission for |origin| to display notifications in layout tests. |
(...skipping 29 matching lines...) Expand all Loading... |
59 const ShowDesktopNotificationHostMsgParams& params, | 59 const ShowDesktopNotificationHostMsgParams& params, |
60 int render_process_id) override; | 60 int render_process_id) override; |
61 void ClosePersistentNotification( | 61 void ClosePersistentNotification( |
62 BrowserContext* browser_context, | 62 BrowserContext* browser_context, |
63 const std::string& persistent_notification_id) override; | 63 const std::string& persistent_notification_id) override; |
64 | 64 |
65 private: | 65 private: |
66 // Closes the notification titled |title|. Must be called on the UI thread. | 66 // Closes the notification titled |title|. Must be called on the UI thread. |
67 void Close(const std::string& title); | 67 void Close(const std::string& title); |
68 | 68 |
69 typedef std::map<GURL, blink::WebNotificationPermission> | 69 // Fakes replacing the notification identified by |params| when it has a tag |
70 NotificationPermissionMap; | 70 // and a previous notification has been displayed using the same tag. All |
71 NotificationPermissionMap permission_map_; | 71 // notifications, both page and persistent ones, will be considered for this. |
| 72 void ReplaceNotificationIfNeeded( |
| 73 const ShowDesktopNotificationHostMsgParams& params); |
72 | 74 |
73 std::map<std::string, DesktopNotificationDelegate*> notifications_; | 75 // Structure to represent the information of a persistent notification. |
| 76 struct PersistentNotification { |
| 77 PersistentNotification(); |
| 78 |
| 79 BrowserContext* browser_context; |
| 80 int64 service_worker_registration_id; |
| 81 ShowDesktopNotificationHostMsgParams notification_data; |
| 82 std::string persistent_id; |
| 83 }; |
| 84 |
| 85 std::map<GURL, blink::WebNotificationPermission> permission_map_; |
| 86 |
| 87 std::map<std::string, DesktopNotificationDelegate*> page_notifications_; |
| 88 std::map<std::string, PersistentNotification> persistent_notifications_; |
| 89 |
74 std::map<std::string, std::string> replacements_; | 90 std::map<std::string, std::string> replacements_; |
75 | 91 |
76 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_; | 92 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_; |
77 | 93 |
78 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager); | 94 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager); |
79 }; | 95 }; |
80 | 96 |
81 } // content | 97 } // content |
82 | 98 |
83 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ | 99 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ |
OLD | NEW |