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
3 // found in the LICENSE file.
5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_
11 #include "base/basictypes.h"
12 #include "third_party/WebKit/public/web/WebNotification.h"
13 #include "third_party/WebKit/public/web/WebNotificationPresenter.h"
17 class WebTestDelegate;
19 // A class that implements WebNotificationPresenter for the TestRunner library.
20 class NotificationPresenter : public blink::WebNotificationPresenter {
22 NotificationPresenter();
23 virtual ~NotificationPresenter();
25 // Called by the TestRunner to simulate a user granting permission.
26 void GrantPermission(const std::string& origin, bool permission_granted);
28 // Called by the TestRunner to simulate a user clicking on a notification.
29 bool SimulateClick(const std::string& title);
31 // Called by the TestRunner to reset the presenter to an default state.
34 void set_delegate(WebTestDelegate* delegate) { delegate_ = delegate; }
36 // blink::WebNotificationPresenter interface
37 virtual bool show(const blink::WebNotification& notification);
38 virtual void cancel(const blink::WebNotification& notification);
39 virtual void objectDestroyed(const blink::WebNotification& notification);
40 virtual Permission checkPermission(
41 const blink::WebSecurityOrigin& security_origin);
42 virtual void requestPermission(
43 const blink::WebSecurityOrigin& security_origin,
44 blink::WebNotificationPermissionCallback* callback);
47 WebTestDelegate* delegate_;
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_;
53 // Map of currently active notifications.
54 typedef std::map<std::string, blink::WebNotification> ActiveNotificationMap;
55 ActiveNotificationMap active_notifications_;
57 // Map of replacement identifiers to the titles of those notifications.
58 std::map<std::string, std::string> replacements_;
60 DISALLOW_COPY_AND_ASSIGN(NotificationPresenter);
63 } // namespace content
65 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_