[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / content / shell / renderer / test_runner / notification_presenter.h
blobb0934cd7d15138bf1d6a6806d39309799fe626b8
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_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "third_party/WebKit/public/web/WebNotification.h"
13 #include "third_party/WebKit/public/web/WebNotificationPresenter.h"
15 namespace WebTestRunner {
16 class WebTestDelegate;
19 namespace content {
21 // A class that implements WebNotificationPresenter for the TestRunner library.
22 class NotificationPresenter : public blink::WebNotificationPresenter {
23 public:
24 NotificationPresenter();
25 virtual ~NotificationPresenter();
27 // Called by the TestRunner to simulate a user granting permission.
28 void GrantPermission(const std::string& origin, bool permission_granted);
30 // Called by the TestRunner to simulate a user clicking on a notification.
31 bool SimulateClick(const std::string& title);
33 // Called by the TestRunner to reset the presenter to an default state.
34 void Reset();
36 void set_delegate(WebTestRunner::WebTestDelegate* delegate) {
37 delegate_ = delegate;
40 // blink::WebNotificationPresenter interface
41 virtual bool show(const blink::WebNotification& notification);
42 virtual void cancel(const blink::WebNotification& notification);
43 virtual void objectDestroyed(const blink::WebNotification& notification);
44 virtual Permission checkPermission(
45 const blink::WebSecurityOrigin& security_origin);
46 virtual void requestPermission(
47 const blink::WebSecurityOrigin& security_origin,
48 blink::WebNotificationPermissionCallback* callback);
50 private:
51 WebTestRunner::WebTestDelegate* delegate_;
53 // Map of known origins and whether they are allowed to show notifications.
54 typedef std::map<std::string, bool> KnownOriginMap;
55 KnownOriginMap known_origins_;
57 // Map of currently active notifications.
58 typedef std::map<std::string, blink::WebNotification> ActiveNotificationMap;
59 ActiveNotificationMap active_notifications_;
61 // Map of replacement identifiers to the titles of those notifications.
62 std::map<std::string, std::string> replacements_;
64 DISALLOW_COPY_AND_ASSIGN(NotificationPresenter);
67 } // namespace content
69 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_