Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: content/test/layout_tests/runner/NotificationPresenter.h

Issue 110533009: Import TestRunner library into chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 /*
6 * Copyright (C) 2010 Google Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Google Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef NotificationPresenter_h
36 #define NotificationPresenter_h
37
38 #include <map>
39 #include <set>
40 #include <string>
41
42 #include "third_party/WebKit/public/platform/WebNonCopyable.h"
43 #include "third_party/WebKit/public/web/WebNotification.h"
44 #include "third_party/WebKit/public/web/WebNotificationPresenter.h"
45
46 namespace WebTestRunner {
47
48 class WebTestDelegate;
49
50 // A class that implements WebNotificationPresenter for the TestRunner library.
51 class NotificationPresenter : public blink::WebNotificationPresenter, public bli nk::WebNonCopyable {
52 public:
53 NotificationPresenter();
54 virtual ~NotificationPresenter();
55
56 void setDelegate(WebTestDelegate* delegate) { m_delegate = delegate; }
57
58 // Called by the TestRunner to simulate a user granting permission.
59 void grantPermission(const blink::WebString& origin);
60
61 // Called by the TestRunner to simulate a user clicking on a notification.
62 bool simulateClick(const blink::WebString& notificationIdentifier);
63
64 // Called by the TestRunner to cancel all active notications.
65 void cancelAllActiveNotifications();
66
67 // blink::WebNotificationPresenter interface
68 virtual bool show(const blink::WebNotification&);
69 virtual void cancel(const blink::WebNotification&);
70 virtual void objectDestroyed(const blink::WebNotification&);
71 virtual Permission checkPermission(const blink::WebSecurityOrigin&);
72 virtual void requestPermission(const blink::WebSecurityOrigin&, blink::WebNo tificationPermissionCallback*);
73
74 void reset() { m_allowedOrigins.clear(); }
75
76 private:
77 WebTestDelegate* m_delegate;
78
79 // Set of allowed origins.
80 std::set<std::string> m_allowedOrigins;
81
82 // Map of active notifications.
83 std::map<std::string, blink::WebNotification> m_activeNotifications;
84
85 // Map of active replacement IDs to the titles of those notifications
86 std::map<std::string, std::string> m_replacements;
87 };
88
89 }
90
91 #endif // NotificationPresenter_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698