OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NotificationPresenter_h |
| 6 #define NotificationPresenter_h |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
| 11 |
| 12 #include "third_party/WebKit/public/platform/WebNonCopyable.h" |
| 13 #include "third_party/WebKit/public/web/WebNotification.h" |
| 14 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" |
| 15 |
| 16 namespace WebTestRunner { |
| 17 |
| 18 class WebTestDelegate; |
| 19 |
| 20 // A class that implements WebNotificationPresenter for the TestRunner library. |
| 21 class NotificationPresenter : public blink::WebNotificationPresenter, public bli
nk::WebNonCopyable { |
| 22 public: |
| 23 NotificationPresenter(); |
| 24 virtual ~NotificationPresenter(); |
| 25 |
| 26 void setDelegate(WebTestDelegate* delegate) { m_delegate = delegate; } |
| 27 |
| 28 // Called by the TestRunner to simulate a user granting permission. |
| 29 void grantPermission(const blink::WebString& origin); |
| 30 |
| 31 // Called by the TestRunner to simulate a user clicking on a notification. |
| 32 bool simulateClick(const blink::WebString& notificationIdentifier); |
| 33 |
| 34 // Called by the TestRunner to cancel all active notications. |
| 35 void cancelAllActiveNotifications(); |
| 36 |
| 37 // blink::WebNotificationPresenter interface |
| 38 virtual bool show(const blink::WebNotification&); |
| 39 virtual void cancel(const blink::WebNotification&); |
| 40 virtual void objectDestroyed(const blink::WebNotification&); |
| 41 virtual Permission checkPermission(const blink::WebSecurityOrigin&); |
| 42 virtual void requestPermission(const blink::WebSecurityOrigin&, blink::WebNo
tificationPermissionCallback*); |
| 43 |
| 44 void reset() { m_allowedOrigins.clear(); } |
| 45 |
| 46 private: |
| 47 WebTestDelegate* m_delegate; |
| 48 |
| 49 // Set of allowed origins. |
| 50 std::set<std::string> m_allowedOrigins; |
| 51 |
| 52 // Map of active notifications. |
| 53 std::map<std::string, blink::WebNotification> m_activeNotifications; |
| 54 |
| 55 // Map of active replacement IDs to the titles of those notifications |
| 56 std::map<std::string, std::string> m_replacements; |
| 57 }; |
| 58 |
| 59 } |
| 60 |
| 61 #endif // NotificationPresenter_h |
OLD | NEW |