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 "third_party/WebKit/public/platform/WebNotificationPermission.h" | 14 #include "third_party/WebKit/public/platform/WebNotificationPermission.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 struct ShowDesktopNotificationHostMsgParams; | |
20 class DesktopNotificationDelegate; | 19 class DesktopNotificationDelegate; |
| 20 struct PlatformNotificationData; |
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. |
30 // Must be called on the IO thread. | 30 // Must be called on the IO thread. |
(...skipping 11 matching lines...) Expand all Loading... |
42 // Simulates a click on the notification titled |title|. Must be called on the | 42 // Simulates a click on the notification titled |title|. Must be called on the |
43 // UI thread. | 43 // UI thread. |
44 void SimulateClick(const std::string& title); | 44 void SimulateClick(const std::string& title); |
45 | 45 |
46 // PlatformNotificationService implementation. | 46 // PlatformNotificationService implementation. |
47 blink::WebNotificationPermission CheckPermission( | 47 blink::WebNotificationPermission CheckPermission( |
48 ResourceContext* resource_context, | 48 ResourceContext* resource_context, |
49 const GURL& origin, | 49 const GURL& origin, |
50 int render_process_id) override; | 50 int render_process_id) override; |
51 void DisplayNotification(BrowserContext* browser_context, | 51 void DisplayNotification(BrowserContext* browser_context, |
52 const ShowDesktopNotificationHostMsgParams& params, | 52 const GURL& origin, |
| 53 const SkBitmap& icon, |
| 54 const PlatformNotificationData& notification_data, |
53 scoped_ptr<DesktopNotificationDelegate> delegate, | 55 scoped_ptr<DesktopNotificationDelegate> delegate, |
54 int render_process_id, | 56 int render_process_id, |
55 base::Closure* cancel_callback) override; | 57 base::Closure* cancel_callback) override; |
56 void DisplayPersistentNotification( | 58 void DisplayPersistentNotification( |
57 BrowserContext* browser_context, | 59 BrowserContext* browser_context, |
58 int64 service_worker_registration_id, | 60 int64 service_worker_registration_id, |
59 const ShowDesktopNotificationHostMsgParams& params, | 61 const GURL& origin, |
| 62 const SkBitmap& icon, |
| 63 const PlatformNotificationData& notification_data, |
60 int render_process_id) override; | 64 int render_process_id) override; |
61 void ClosePersistentNotification( | 65 void ClosePersistentNotification( |
62 BrowserContext* browser_context, | 66 BrowserContext* browser_context, |
63 const std::string& persistent_notification_id) override; | 67 const std::string& persistent_notification_id) override; |
64 | 68 |
65 private: | 69 private: |
66 // Closes the notification titled |title|. Must be called on the UI thread. | 70 // Closes the notification titled |title|. Must be called on the UI thread. |
67 void Close(const std::string& title); | 71 void Close(const std::string& title); |
68 | 72 |
69 typedef std::map<GURL, blink::WebNotificationPermission> | 73 typedef std::map<GURL, blink::WebNotificationPermission> |
70 NotificationPermissionMap; | 74 NotificationPermissionMap; |
71 NotificationPermissionMap permission_map_; | 75 NotificationPermissionMap permission_map_; |
72 | 76 |
73 std::map<std::string, DesktopNotificationDelegate*> notifications_; | 77 std::map<std::string, DesktopNotificationDelegate*> notifications_; |
74 std::map<std::string, std::string> replacements_; | 78 std::map<std::string, std::string> replacements_; |
75 | 79 |
76 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_; | 80 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_; |
77 | 81 |
78 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager); | 82 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager); |
79 }; | 83 }; |
80 | 84 |
81 } // content | 85 } // content |
82 | 86 |
83 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ | 87 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ |
OLD | NEW |