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_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_ | 5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_ |
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_ | 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "third_party/WebKit/public/web/WebNotification.h" | 12 #include "third_party/WebKit/public/web/WebNotification.h" |
13 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" | 13 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class WebTestDelegate; | 17 class WebTestDelegate; |
18 | 18 |
19 // A class that implements WebNotificationPresenter for the TestRunner library. | 19 // A class that implements WebNotificationPresenter for the TestRunner library. |
20 class NotificationPresenter : public blink::WebNotificationPresenter { | 20 class NotificationPresenter : public blink::WebNotificationPresenter { |
21 public: | 21 public: |
22 NotificationPresenter(); | 22 NotificationPresenter(); |
23 virtual ~NotificationPresenter(); | 23 virtual ~NotificationPresenter(); |
24 | 24 |
25 // Called by the TestRunner to simulate a user granting permission. | |
26 void GrantPermission(const std::string& origin, bool permission_granted); | |
27 | |
28 // Called by the TestRunner to simulate a user clicking on a notification. | 25 // Called by the TestRunner to simulate a user clicking on a notification. |
29 bool SimulateClick(const std::string& title); | 26 bool SimulateClick(const std::string& title); |
30 | 27 |
31 // Called by the TestRunner to reset the presenter to an default state. | 28 // Called by the TestRunner to reset the presenter to an default state. |
32 void Reset(); | 29 void Reset(); |
33 | 30 |
34 void set_delegate(WebTestDelegate* delegate) { delegate_ = delegate; } | 31 void set_delegate(WebTestDelegate* delegate) { delegate_ = delegate; } |
35 | 32 |
36 // blink::WebNotificationPresenter interface | 33 // blink::WebNotificationPresenter interface |
37 virtual bool show(const blink::WebNotification& notification); | 34 virtual bool show(const blink::WebNotification& notification); |
38 virtual void cancel(const blink::WebNotification& notification); | 35 virtual void cancel(const blink::WebNotification& notification); |
39 virtual void objectDestroyed(const blink::WebNotification& notification); | 36 virtual void objectDestroyed(const blink::WebNotification& notification); |
40 virtual Permission checkPermission( | 37 virtual Permission checkPermission( |
41 const blink::WebSecurityOrigin& security_origin); | 38 const blink::WebSecurityOrigin& security_origin); |
42 virtual void requestPermission( | 39 virtual void requestPermission( |
43 const blink::WebSecurityOrigin& security_origin, | 40 const blink::WebSecurityOrigin& security_origin, |
44 blink::WebNotificationPermissionCallback* callback); | 41 blink::WebNotificationPermissionCallback* callback); |
45 | 42 |
46 private: | 43 private: |
47 WebTestDelegate* delegate_; | 44 WebTestDelegate* delegate_; |
48 | 45 |
49 // Map of known origins and whether they are allowed to show notifications. | |
50 typedef std::map<std::string, bool> KnownOriginMap; | |
51 KnownOriginMap known_origins_; | |
52 | |
53 // Map of currently active notifications. | 46 // Map of currently active notifications. |
54 typedef std::map<std::string, blink::WebNotification> ActiveNotificationMap; | 47 typedef std::map<std::string, blink::WebNotification> ActiveNotificationMap; |
55 ActiveNotificationMap active_notifications_; | 48 ActiveNotificationMap active_notifications_; |
56 | 49 |
57 // Map of replacement identifiers to the titles of those notifications. | 50 // Map of replacement identifiers to the titles of those notifications. |
58 std::map<std::string, std::string> replacements_; | 51 std::map<std::string, std::string> replacements_; |
59 | 52 |
60 DISALLOW_COPY_AND_ASSIGN(NotificationPresenter); | 53 DISALLOW_COPY_AND_ASSIGN(NotificationPresenter); |
61 }; | 54 }; |
62 | 55 |
63 } // namespace content | 56 } // namespace content |
64 | 57 |
65 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_ | 58 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_ |
OLD | NEW |