Chromium Code Reviews| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 | 99 |
| 100 bool LayoutTestNotificationManager::GetDisplayedPersistentNotifications( | 100 bool LayoutTestNotificationManager::GetDisplayedPersistentNotifications( |
| 101 BrowserContext* browser_context, | 101 BrowserContext* browser_context, |
| 102 std::set<std::string>* displayed_notifications) { | 102 std::set<std::string>* displayed_notifications) { |
| 103 DCHECK(displayed_notifications); | 103 DCHECK(displayed_notifications); |
| 104 | 104 |
| 105 // Notifications will never outlive the lifetime of running layout tests. | 105 // Notifications will never outlive the lifetime of running layout tests. |
| 106 return false; | 106 return false; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void LayoutTestNotificationManager::SimulateClick(const std::string& title) { | 109 void LayoutTestNotificationManager::SimulateClick(const std::string& title, |
| 110 int action_index) { | |
| 110 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 111 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 111 | 112 |
| 112 // First check for page-notifications with the given title. | 113 // First check for page-notifications with the given title. |
| 113 const auto& page_iterator = page_notifications_.find(title); | 114 const auto& page_iterator = page_notifications_.find(title); |
| 114 if (page_iterator != page_notifications_.end()) { | 115 if (page_iterator != page_notifications_.end()) { |
| 116 CHECK(action_index < 0) << "Simulating action clicks for page notifications" | |
|
Peter Beverloo
2015/08/04 21:08:33
Please make sure there's a TODO + a bug for this.
johnme
2015/08/05 13:51:27
Added a TODO. Plumbing action clicks to page notif
| |
| 117 << " is not yet implemented"; | |
| 115 page_iterator->second->NotificationClick(); | 118 page_iterator->second->NotificationClick(); |
| 116 return; | 119 return; |
| 117 } | 120 } |
| 118 | 121 |
| 119 // Then check for persistent notifications with the given title. | 122 // Then check for persistent notifications with the given title. |
| 120 const auto& persistent_iterator = persistent_notifications_.find(title); | 123 const auto& persistent_iterator = persistent_notifications_.find(title); |
| 121 if (persistent_iterator == persistent_notifications_.end()) | 124 if (persistent_iterator == persistent_notifications_.end()) |
| 122 return; | 125 return; |
| 123 | 126 |
| 124 const PersistentNotification& notification = persistent_iterator->second; | 127 const PersistentNotification& notification = persistent_iterator->second; |
| 125 content::NotificationEventDispatcher::GetInstance() | 128 content::NotificationEventDispatcher::GetInstance() |
| 126 ->DispatchNotificationClickEvent( | 129 ->DispatchNotificationClickEvent( |
| 127 notification.browser_context, | 130 notification.browser_context, |
| 128 notification.persistent_id, | 131 notification.persistent_id, |
| 129 notification.origin, | 132 notification.origin, |
| 130 -1 /* action_index */, | 133 action_index, |
| 131 base::Bind(&OnEventDispatchComplete)); | 134 base::Bind(&OnEventDispatchComplete)); |
| 132 } | 135 } |
| 133 | 136 |
| 134 blink::WebNotificationPermission | 137 blink::WebNotificationPermission |
| 135 LayoutTestNotificationManager::CheckPermissionOnUIThread( | 138 LayoutTestNotificationManager::CheckPermissionOnUIThread( |
| 136 BrowserContext* browser_context, | 139 BrowserContext* browser_context, |
| 137 const GURL& origin, | 140 const GURL& origin, |
| 138 int render_process_id) { | 141 int render_process_id) { |
| 139 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 142 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 140 return CheckPermission(origin); | 143 return CheckPermission(origin); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 LayoutTestNotificationManager::CheckPermission(const GURL& origin) { | 196 LayoutTestNotificationManager::CheckPermission(const GURL& origin) { |
| 194 return ToWebNotificationPermission(LayoutTestContentBrowserClient::Get() | 197 return ToWebNotificationPermission(LayoutTestContentBrowserClient::Get() |
| 195 ->GetLayoutTestBrowserContext() | 198 ->GetLayoutTestBrowserContext() |
| 196 ->GetLayoutTestPermissionManager() | 199 ->GetLayoutTestPermissionManager() |
| 197 ->GetPermissionStatus(PermissionType::NOTIFICATIONS, | 200 ->GetPermissionStatus(PermissionType::NOTIFICATIONS, |
| 198 origin, | 201 origin, |
| 199 origin)); | 202 origin)); |
| 200 } | 203 } |
| 201 | 204 |
| 202 } // namespace content | 205 } // namespace content |
| OLD | NEW |