OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/shell/renderer/test_runner/notification_presenter.h" | 5 #include "content/shell/renderer/test_runner/notification_presenter.h" |
6 | 6 |
7 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 7 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
8 #include "third_party/WebKit/public/platform/Platform.h" | 8 #include "third_party/WebKit/public/platform/Platform.h" |
9 #include "third_party/WebKit/public/platform/WebString.h" | 9 #include "third_party/WebKit/public/platform/WebString.h" |
10 #include "third_party/WebKit/public/platform/WebURL.h" | 10 #include "third_party/WebKit/public/platform/WebURL.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return false; | 48 return false; |
49 | 49 |
50 const WebNotification& notification = iter->second; | 50 const WebNotification& notification = iter->second; |
51 | 51 |
52 WebNotification event_target(notification); | 52 WebNotification event_target(notification); |
53 event_target.dispatchClickEvent(); | 53 event_target.dispatchClickEvent(); |
54 | 54 |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 void NotificationPresenter::CancelAllActiveNotifications() { | 58 void NotificationPresenter::Reset() { |
59 while (!active_notifications_.empty()) { | 59 while (!active_notifications_.empty()) { |
60 const WebNotification& notification = active_notifications_.begin()->second; | 60 const WebNotification& notification = active_notifications_.begin()->second; |
61 cancel(notification); | 61 cancel(notification); |
62 } | 62 } |
63 } | |
64 | 63 |
65 void NotificationPresenter::Reset() { | |
66 CancelAllActiveNotifications(); | |
67 known_origins_.clear(); | 64 known_origins_.clear(); |
68 replacements_.clear(); | 65 replacements_.clear(); |
69 } | 66 } |
70 | 67 |
71 bool NotificationPresenter::show(const WebNotification& notification) { | 68 bool NotificationPresenter::show(const WebNotification& notification) { |
72 if (!notification.replaceId().isEmpty()) { | 69 if (!notification.replaceId().isEmpty()) { |
73 std::string replaceId(notification.replaceId().utf8()); | 70 std::string replaceId(notification.replaceId().utf8()); |
74 if (replacements_.find(replaceId) != replacements_.end()) { | 71 if (replacements_.find(replaceId) != replacements_.end()) { |
75 delegate_->printMessage(std::string("REPLACING NOTIFICATION ") + | 72 delegate_->printMessage(std::string("REPLACING NOTIFICATION ") + |
76 replacements_.find(replaceId)->second + "\n"); | 73 replacements_.find(replaceId)->second + "\n"); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void NotificationPresenter::requestPermission( | 145 void NotificationPresenter::requestPermission( |
149 const WebSecurityOrigin& security_origin, | 146 const WebSecurityOrigin& security_origin, |
150 WebNotificationPermissionCallback* callback) { | 147 WebNotificationPermissionCallback* callback) { |
151 std::string origin = security_origin.toString().utf8(); | 148 std::string origin = security_origin.toString().utf8(); |
152 delegate_->printMessage("DESKTOP NOTIFICATION PERMISSION REQUESTED: " + | 149 delegate_->printMessage("DESKTOP NOTIFICATION PERMISSION REQUESTED: " + |
153 origin + "\n"); | 150 origin + "\n"); |
154 callback->permissionRequestComplete(); | 151 callback->permissionRequestComplete(); |
155 } | 152 } |
156 | 153 |
157 } // namespace content | 154 } // namespace content |
OLD | NEW |