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/browser/layout_test/layout_test_notification_manager.h" | 5 #include "content/shell/browser/layout_test/layout_test_notification_manager.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/desktop_notification_delegate.h" | 10 #include "content/public/browser/desktop_notification_delegate.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 const PersistentNotification& notification = persistent_iterator->second; | 127 const PersistentNotification& notification = persistent_iterator->second; |
128 content::NotificationEventDispatcher::GetInstance() | 128 content::NotificationEventDispatcher::GetInstance() |
129 ->DispatchNotificationClickEvent( | 129 ->DispatchNotificationClickEvent( |
130 notification.browser_context, | 130 notification.browser_context, |
131 notification.persistent_id, | 131 notification.persistent_id, |
132 notification.origin, | 132 notification.origin, |
133 action_index, | 133 action_index, |
134 base::Bind(&OnEventDispatchComplete)); | 134 base::Bind(&OnEventDispatchComplete)); |
135 } | 135 } |
136 | 136 |
137 void LayoutTestNotificationManager::SimulateClose(const std::string& title, | |
138 bool by_user) { | |
139 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
140 | |
141 // First check for page-notifications with the given title. | |
142 const auto& page_iterator = page_notifications_.find(title); | |
143 if (page_iterator != page_notifications_.end()) { | |
144 page_iterator->second->NotificationClosed(); | |
Peter Beverloo
2016/02/02 23:50:10
No need to check for in-page notifications here -
Nina
2016/02/03 15:04:23
Removed.
| |
145 return; | |
146 } | |
147 | |
148 // Then check for persistent notifications with the given title. | |
149 const auto& persistent_iterator = persistent_notifications_.find(title); | |
150 if (persistent_iterator == persistent_notifications_.end()) | |
151 return; | |
152 | |
153 const PersistentNotification& notification = persistent_iterator->second; | |
154 content::NotificationEventDispatcher::GetInstance() | |
155 ->DispatchNotificationCloseEvent( | |
156 notification.browser_context, | |
157 notification.persistent_id, | |
158 notification.origin, | |
159 by_user, | |
160 base::Bind(&OnEventDispatchComplete)); | |
161 } | |
162 | |
137 blink::WebNotificationPermission | 163 blink::WebNotificationPermission |
138 LayoutTestNotificationManager::CheckPermissionOnUIThread( | 164 LayoutTestNotificationManager::CheckPermissionOnUIThread( |
139 BrowserContext* browser_context, | 165 BrowserContext* browser_context, |
140 const GURL& origin, | 166 const GURL& origin, |
141 int render_process_id) { | 167 int render_process_id) { |
142 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 168 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
143 return CheckPermission(origin); | 169 return CheckPermission(origin); |
144 } | 170 } |
145 | 171 |
146 blink::WebNotificationPermission | 172 blink::WebNotificationPermission |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 LayoutTestNotificationManager::CheckPermission(const GURL& origin) { | 222 LayoutTestNotificationManager::CheckPermission(const GURL& origin) { |
197 return ToWebNotificationPermission(LayoutTestContentBrowserClient::Get() | 223 return ToWebNotificationPermission(LayoutTestContentBrowserClient::Get() |
198 ->GetLayoutTestBrowserContext() | 224 ->GetLayoutTestBrowserContext() |
199 ->GetLayoutTestPermissionManager() | 225 ->GetLayoutTestPermissionManager() |
200 ->GetPermissionStatus(PermissionType::NOTIFICATIONS, | 226 ->GetPermissionStatus(PermissionType::NOTIFICATIONS, |
201 origin, | 227 origin, |
202 origin)); | 228 origin)); |
203 } | 229 } |
204 | 230 |
205 } // namespace content | 231 } // namespace content |
OLD | NEW |