Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: content/test/mock_platform_notification_service.h

Issue 2906883003: Deprecate per notification type delegates. (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_TEST_MOCK_PLATFORM_NOTIFICATION_SERVICE_H_ 5 #ifndef CONTENT_TEST_MOCK_PLATFORM_NOTIFICATION_SERVICE_H_
6 #define CONTENT_TEST_MOCK_PLATFORM_NOTIFICATION_SERVICE_H_ 6 #define CONTENT_TEST_MOCK_PLATFORM_NOTIFICATION_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
11 #include <unordered_set>
11 12
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "content/public/browser/platform_notification_service.h" 16 #include "content/public/browser/platform_notification_service.h"
16 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h" 17 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 namespace base { 20 namespace base {
20 class NullableString16; 21 class NullableString16;
21 } 22 }
22 23
23 namespace content { 24 namespace content {
24 25
25 class DesktopNotificationDelegate;
26 struct NotificationResources; 26 struct NotificationResources;
27 struct PlatformNotificationData; 27 struct PlatformNotificationData;
28 28
29 // Responsible for tracking active notifications and allowed origins for the 29 // Responsible for tracking active notifications and allowed origins for the
30 // Web Notification API when running layout and content tests. 30 // Web Notification API when running layout and content tests.
31 class MockPlatformNotificationService : public PlatformNotificationService { 31 class MockPlatformNotificationService : public PlatformNotificationService {
32 public: 32 public:
33 MockPlatformNotificationService(); 33 MockPlatformNotificationService();
34 ~MockPlatformNotificationService() override; 34 ~MockPlatformNotificationService() override;
35 35
(...skipping 17 matching lines...) Expand all
53 blink::mojom::PermissionStatus CheckPermissionOnIOThread( 53 blink::mojom::PermissionStatus CheckPermissionOnIOThread(
54 ResourceContext* resource_context, 54 ResourceContext* resource_context,
55 const GURL& origin, 55 const GURL& origin,
56 int render_process_id) override; 56 int render_process_id) override;
57 void DisplayNotification( 57 void DisplayNotification(
58 BrowserContext* browser_context, 58 BrowserContext* browser_context,
59 const std::string& notification_id, 59 const std::string& notification_id,
60 const GURL& origin, 60 const GURL& origin,
61 const PlatformNotificationData& notification_data, 61 const PlatformNotificationData& notification_data,
62 const NotificationResources& notification_resources, 62 const NotificationResources& notification_resources,
63 std::unique_ptr<DesktopNotificationDelegate> delegate,
64 base::Closure* cancel_callback) override; 63 base::Closure* cancel_callback) override;
65 void DisplayPersistentNotification( 64 void DisplayPersistentNotification(
66 BrowserContext* browser_context, 65 BrowserContext* browser_context,
67 const std::string& notification_id, 66 const std::string& notification_id,
68 const GURL& service_worker_scope, 67 const GURL& service_worker_scope,
69 const GURL& origin, 68 const GURL& origin,
70 const PlatformNotificationData& notification_data, 69 const PlatformNotificationData& notification_data,
71 const NotificationResources& notification_resources) override; 70 const NotificationResources& notification_resources) override;
72 void ClosePersistentNotification(BrowserContext* browser_context, 71 void ClosePersistentNotification(BrowserContext* browser_context,
73 const std::string& notification_id) override; 72 const std::string& notification_id) override;
(...skipping 15 matching lines...) Expand all
89 88
90 // Closes the notification titled |title|. Must be called on the UI thread. 89 // Closes the notification titled |title|. Must be called on the UI thread.
91 void Close(const std::string& title); 90 void Close(const std::string& title);
92 91
93 // Fakes replacing the notification identified by |notification_id|. Both 92 // Fakes replacing the notification identified by |notification_id|. Both
94 // persistent and non-persistent notifications will be considered for this. 93 // persistent and non-persistent notifications will be considered for this.
95 void ReplaceNotificationIfNeeded(const std::string& notification_id); 94 void ReplaceNotificationIfNeeded(const std::string& notification_id);
96 95
97 std::unordered_map<std::string, PersistentNotification> 96 std::unordered_map<std::string, PersistentNotification>
98 persistent_notifications_; 97 persistent_notifications_;
99 std::unordered_map<std::string, std::unique_ptr<DesktopNotificationDelegate>> 98 std::unordered_set<std::string> non_persistent_notifications_;
100 non_persistent_notifications_;
101 99
102 // Mapping of titles to notification ids giving test a usable identifier. 100 // Mapping of titles to notification ids giving test a usable identifier.
103 std::unordered_map<std::string, std::string> notification_id_map_; 101 std::unordered_map<std::string, std::string> notification_id_map_;
104 102
105 base::WeakPtrFactory<MockPlatformNotificationService> weak_factory_; 103 base::WeakPtrFactory<MockPlatformNotificationService> weak_factory_;
106 104
107 DISALLOW_COPY_AND_ASSIGN(MockPlatformNotificationService); 105 DISALLOW_COPY_AND_ASSIGN(MockPlatformNotificationService);
108 }; 106 };
109 107
110 } // content 108 } // content
111 109
112 #endif // CONTENT_TEST_MOCK_PLATFORM_NOTIFICATION_SERVICE_H_ 110 #endif // CONTENT_TEST_MOCK_PLATFORM_NOTIFICATION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698