| 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/nullable_string16.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/desktop_notification_delegate.h" | 11 #include "content/public/browser/desktop_notification_delegate.h" |
| 11 #include "content/public/browser/notification_event_dispatcher.h" | 12 #include "content/public/browser/notification_event_dispatcher.h" |
| 12 #include "content/public/browser/permission_type.h" | 13 #include "content/public/browser/permission_type.h" |
| 13 #include "content/public/common/persistent_notification_status.h" | 14 #include "content/public/common/persistent_notification_status.h" |
| 14 #include "content/public/common/platform_notification_data.h" | 15 #include "content/public/common/platform_notification_data.h" |
| 15 #include "content/shell/browser/layout_test/layout_test_browser_context.h" | 16 #include "content/shell/browser/layout_test/layout_test_browser_context.h" |
| 16 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h
" | 17 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h
" |
| 17 #include "content/shell/browser/layout_test/layout_test_permission_manager.h" | 18 #include "content/shell/browser/layout_test/layout_test_permission_manager.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 105 |
| 105 const auto persistent_iter = persistent_notifications_.find(notification_id); | 106 const auto persistent_iter = persistent_notifications_.find(notification_id); |
| 106 const auto non_persistent_iter = | 107 const auto non_persistent_iter = |
| 107 non_persistent_notifications_.find(notification_id); | 108 non_persistent_notifications_.find(notification_id); |
| 108 | 109 |
| 109 if (persistent_iter != persistent_notifications_.end()) { | 110 if (persistent_iter != persistent_notifications_.end()) { |
| 110 DCHECK(non_persistent_iter == non_persistent_notifications_.end()); | 111 DCHECK(non_persistent_iter == non_persistent_notifications_.end()); |
| 111 | 112 |
| 112 const PersistentNotification& notification = persistent_iter->second; | 113 const PersistentNotification& notification = persistent_iter->second; |
| 113 content::NotificationEventDispatcher::GetInstance() | 114 content::NotificationEventDispatcher::GetInstance() |
| 114 ->DispatchNotificationClickEvent( | 115 ->DispatchNotificationClickEvent(notification.browser_context, |
| 115 notification.browser_context, notification_id, notification.origin, | 116 notification_id, notification.origin, |
| 116 action_index, base::Bind(&OnEventDispatchComplete)); | 117 action_index, base::NullableString16(), |
| 118 base::Bind(&OnEventDispatchComplete)); |
| 117 } else if (non_persistent_iter != non_persistent_notifications_.end()) { | 119 } else if (non_persistent_iter != non_persistent_notifications_.end()) { |
| 118 DCHECK_EQ(action_index, -1) << "Action buttons are only supported for " | 120 DCHECK_EQ(action_index, -1) << "Action buttons are only supported for " |
| 119 "persistent notifications"; | 121 "persistent notifications"; |
| 120 | 122 |
| 121 non_persistent_iter->second->NotificationClick(); | 123 non_persistent_iter->second->NotificationClick(); |
| 122 } | 124 } |
| 123 } | 125 } |
| 124 | 126 |
| 125 void LayoutTestNotificationManager::SimulateClose(const std::string& title, | 127 void LayoutTestNotificationManager::SimulateClose(const std::string& title, |
| 126 bool by_user) { | 128 bool by_user) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 LayoutTestNotificationManager::CheckPermission(const GURL& origin) { | 191 LayoutTestNotificationManager::CheckPermission(const GURL& origin) { |
| 190 return LayoutTestContentBrowserClient::Get() | 192 return LayoutTestContentBrowserClient::Get() |
| 191 ->GetLayoutTestBrowserContext() | 193 ->GetLayoutTestBrowserContext() |
| 192 ->GetLayoutTestPermissionManager() | 194 ->GetLayoutTestPermissionManager() |
| 193 ->GetPermissionStatus(PermissionType::NOTIFICATIONS, | 195 ->GetPermissionStatus(PermissionType::NOTIFICATIONS, |
| 194 origin, | 196 origin, |
| 195 origin); | 197 origin); |
| 196 } | 198 } |
| 197 | 199 |
| 198 } // namespace content | 200 } // namespace content |
| OLD | NEW |