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

Side by Side Diff: content/shell/browser/layout_test/layout_test_notification_manager.h

Issue 794633002: Remove ShowDesktopNotificationHostMsgParams in favor of PlatformNotificationData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 6 years 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_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 "content/public/common/platform_notification_data.h"
15 #include "third_party/WebKit/public/platform/WebNotificationPermission.h" 15 #include "third_party/WebKit/public/platform/WebNotificationPermission.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 class DesktopNotificationDelegate; 20 class DesktopNotificationDelegate;
21 struct PlatformNotificationData;
21 22
22 // Responsible for tracking active notifications and allowed origins for the 23 // Responsible for tracking active notifications and allowed origins for the
23 // Web Notification API when running layout tests. 24 // Web Notification API when running layout tests.
24 class LayoutTestNotificationManager : public PlatformNotificationService { 25 class LayoutTestNotificationManager : public PlatformNotificationService {
25 public: 26 public:
26 LayoutTestNotificationManager(); 27 LayoutTestNotificationManager();
27 ~LayoutTestNotificationManager() override; 28 ~LayoutTestNotificationManager() override;
28 29
29 // Requests permission for |origin| to display notifications in layout tests. 30 // Requests permission for |origin| to display notifications in layout tests.
30 // Must be called on the IO thread. 31 // Must be called on the IO thread.
(...skipping 11 matching lines...) Expand all
42 // Simulates a click on the notification titled |title|. Must be called on the 43 // Simulates a click on the notification titled |title|. Must be called on the
43 // UI thread. 44 // UI thread.
44 void SimulateClick(const std::string& title); 45 void SimulateClick(const std::string& title);
45 46
46 // PlatformNotificationService implementation. 47 // PlatformNotificationService implementation.
47 blink::WebNotificationPermission CheckPermission( 48 blink::WebNotificationPermission CheckPermission(
48 ResourceContext* resource_context, 49 ResourceContext* resource_context,
49 const GURL& origin, 50 const GURL& origin,
50 int render_process_id) override; 51 int render_process_id) override;
51 void DisplayNotification(BrowserContext* browser_context, 52 void DisplayNotification(BrowserContext* browser_context,
52 const ShowDesktopNotificationHostMsgParams& params, 53 const GURL& origin,
54 const SkBitmap& icon,
55 const PlatformNotificationData& notification_data,
53 scoped_ptr<DesktopNotificationDelegate> delegate, 56 scoped_ptr<DesktopNotificationDelegate> delegate,
54 int render_process_id, 57 int render_process_id,
55 base::Closure* cancel_callback) override; 58 base::Closure* cancel_callback) override;
56 void DisplayPersistentNotification( 59 void DisplayPersistentNotification(
57 BrowserContext* browser_context, 60 BrowserContext* browser_context,
58 int64 service_worker_registration_id, 61 int64 service_worker_registration_id,
59 const ShowDesktopNotificationHostMsgParams& params, 62 const GURL& origin,
63 const SkBitmap& icon,
64 const PlatformNotificationData& notification_data,
60 int render_process_id) override; 65 int render_process_id) override;
61 void ClosePersistentNotification( 66 void ClosePersistentNotification(
62 BrowserContext* browser_context, 67 BrowserContext* browser_context,
63 const std::string& persistent_notification_id) override; 68 const std::string& persistent_notification_id) override;
64 69
65 private: 70 private:
66 // Closes the notification titled |title|. Must be called on the UI thread. 71 // Closes the notification titled |title|. Must be called on the UI thread.
67 void Close(const std::string& title); 72 void Close(const std::string& title);
68 73
69 // Fakes replacing the notification identified by |params| when it has a tag 74 // Fakes replacing the notification identified by |params| when it has a tag
70 // and a previous notification has been displayed using the same tag. All 75 // and a previous notification has been displayed using the same tag. All
71 // notifications, both page and persistent ones, will be considered for this. 76 // notifications, both page and persistent ones, will be considered for this.
72 void ReplaceNotificationIfNeeded( 77 void ReplaceNotificationIfNeeded(
73 const ShowDesktopNotificationHostMsgParams& params); 78 const PlatformNotificationData& notification_data);
74 79
75 // Structure to represent the information of a persistent notification. 80 // Structure to represent the information of a persistent notification.
76 struct PersistentNotification { 81 struct PersistentNotification {
77 PersistentNotification(); 82 PersistentNotification();
78 83
79 BrowserContext* browser_context; 84 BrowserContext* browser_context;
85 GURL origin;
80 int64 service_worker_registration_id; 86 int64 service_worker_registration_id;
81 ShowDesktopNotificationHostMsgParams notification_data; 87 PlatformNotificationData notification_data;
82 std::string persistent_id; 88 std::string persistent_id;
83 }; 89 };
84 90
85 std::map<GURL, blink::WebNotificationPermission> permission_map_; 91 std::map<GURL, blink::WebNotificationPermission> permission_map_;
86 92
87 std::map<std::string, DesktopNotificationDelegate*> page_notifications_; 93 std::map<std::string, DesktopNotificationDelegate*> page_notifications_;
88 std::map<std::string, PersistentNotification> persistent_notifications_; 94 std::map<std::string, PersistentNotification> persistent_notifications_;
89 95
90 std::map<std::string, std::string> replacements_; 96 std::map<std::string, std::string> replacements_;
91 97
92 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_; 98 base::WeakPtrFactory<LayoutTestNotificationManager> weak_factory_;
93 99
94 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager); 100 DISALLOW_COPY_AND_ASSIGN(LayoutTestNotificationManager);
95 }; 101 };
96 102
97 } // content 103 } // content
98 104
99 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_ 105 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_NOTIFICATION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698