| 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/test/mock_platform_notification_service.h" | 5 #include "content/test/mock_platform_notification_service.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/strings/nullable_string16.h" | 8 #include "base/strings/nullable_string16.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 ResourceContext* resource_context, | 157 ResourceContext* resource_context, |
| 158 const GURL& origin, | 158 const GURL& origin, |
| 159 int render_process_id) { | 159 int render_process_id) { |
| 160 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 160 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 161 return CheckPermission(origin); | 161 return CheckPermission(origin); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void MockPlatformNotificationService::Close( | 164 void MockPlatformNotificationService::Close( |
| 165 const std::string& notification_id) { | 165 const std::string& notification_id) { |
| 166 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 166 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 167 NotificationEventDispatcher::GetInstance()->DispatchNonPersistentCloseEvent( | 167 const auto non_persistent_iter = |
| 168 notification_id); | 168 non_persistent_notifications_.find(notification_id); |
| 169 non_persistent_notifications_.erase(notification_id); | 169 if (non_persistent_iter == non_persistent_notifications_.end()) { |
| 170 NotificationEventDispatcher::GetInstance()->DispatchNonPersistentCloseEvent( |
| 171 notification_id); |
| 172 non_persistent_notifications_.erase(non_persistent_iter); |
| 173 } |
| 170 } | 174 } |
| 171 | 175 |
| 172 void MockPlatformNotificationService::ReplaceNotificationIfNeeded( | 176 void MockPlatformNotificationService::ReplaceNotificationIfNeeded( |
| 173 const std::string& notification_id) { | 177 const std::string& notification_id) { |
| 174 persistent_notifications_.erase(notification_id); | 178 persistent_notifications_.erase(notification_id); |
| 175 non_persistent_notifications_.erase(notification_id); | 179 non_persistent_notifications_.erase(notification_id); |
| 176 } | 180 } |
| 177 | 181 |
| 178 blink::mojom::PermissionStatus MockPlatformNotificationService::CheckPermission( | 182 blink::mojom::PermissionStatus MockPlatformNotificationService::CheckPermission( |
| 179 const GURL& origin) { | 183 const GURL& origin) { |
| 180 return blink::mojom::PermissionStatus::GRANTED; | 184 return blink::mojom::PermissionStatus::GRANTED; |
| 181 } | 185 } |
| 182 | 186 |
| 183 } // namespace content | 187 } // namespace content |
| OLD | NEW |