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