summaryrefslogtreecommitdiffstats
path: root/content/shell/renderer/test_runner/NotificationPresenter.h
diff options
context:
space:
mode:
Diffstat (limited to 'content/shell/renderer/test_runner/NotificationPresenter.h')
-rw-r--r--content/shell/renderer/test_runner/NotificationPresenter.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/content/shell/renderer/test_runner/NotificationPresenter.h b/content/shell/renderer/test_runner/NotificationPresenter.h
new file mode 100644
index 0000000..a680a3a
--- /dev/null
+++ b/content/shell/renderer/test_runner/NotificationPresenter.h
@@ -0,0 +1,61 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NotificationPresenter_h
+#define NotificationPresenter_h
+
+#include <map>
+#include <set>
+#include <string>
+
+#include "third_party/WebKit/public/platform/WebNonCopyable.h"
+#include "third_party/WebKit/public/web/WebNotification.h"
+#include "third_party/WebKit/public/web/WebNotificationPresenter.h"
+
+namespace WebTestRunner {
+
+class WebTestDelegate;
+
+// A class that implements WebNotificationPresenter for the TestRunner library.
+class NotificationPresenter : public blink::WebNotificationPresenter, public blink::WebNonCopyable {
+public:
+ NotificationPresenter();
+ virtual ~NotificationPresenter();
+
+ void setDelegate(WebTestDelegate* delegate) { m_delegate = delegate; }
+
+ // Called by the TestRunner to simulate a user granting permission.
+ void grantPermission(const blink::WebString& origin);
+
+ // Called by the TestRunner to simulate a user clicking on a notification.
+ bool simulateClick(const blink::WebString& notificationIdentifier);
+
+ // Called by the TestRunner to cancel all active notications.
+ void cancelAllActiveNotifications();
+
+ // blink::WebNotificationPresenter interface
+ virtual bool show(const blink::WebNotification&);
+ virtual void cancel(const blink::WebNotification&);
+ virtual void objectDestroyed(const blink::WebNotification&);
+ virtual Permission checkPermission(const blink::WebSecurityOrigin&);
+ virtual void requestPermission(const blink::WebSecurityOrigin&, blink::WebNotificationPermissionCallback*);
+
+ void reset() { m_allowedOrigins.clear(); }
+
+private:
+ WebTestDelegate* m_delegate;
+
+ // Set of allowed origins.
+ std::set<std::string> m_allowedOrigins;
+
+ // Map of active notifications.
+ std::map<std::string, blink::WebNotification> m_activeNotifications;
+
+ // Map of active replacement IDs to the titles of those notifications
+ std::map<std::string, std::string> m_replacements;
+};
+
+}
+
+#endif // NotificationPresenter_h