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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 173 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
174 return CheckPermission(origin); | 174 return CheckPermission(origin); |
175 } | 175 } |
176 | 176 |
177 void LayoutTestNotificationManager::Close(const std::string& title) { | 177 void LayoutTestNotificationManager::Close(const std::string& title) { |
178 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 178 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
179 auto iterator = page_notifications_.find(title); | 179 auto iterator = page_notifications_.find(title); |
180 if (iterator == page_notifications_.end()) | 180 if (iterator == page_notifications_.end()) |
181 return; | 181 return; |
182 | 182 |
183 iterator->second->NotificationClosed(false); | 183 iterator->second->NotificationClosed(); |
184 } | 184 } |
185 | 185 |
186 void LayoutTestNotificationManager::ReplaceNotificationIfNeeded( | 186 void LayoutTestNotificationManager::ReplaceNotificationIfNeeded( |
187 const PlatformNotificationData& notification_data) { | 187 const PlatformNotificationData& notification_data) { |
188 if (!notification_data.tag.length()) | 188 if (!notification_data.tag.length()) |
189 return; | 189 return; |
190 | 190 |
191 std::string tag = notification_data.tag; | 191 std::string tag = notification_data.tag; |
192 const auto& replace_iter = replacements_.find(tag); | 192 const auto& replace_iter = replacements_.find(tag); |
193 if (replace_iter != replacements_.end()) { | 193 if (replace_iter != replacements_.end()) { |
194 const std::string& previous_title = replace_iter->second; | 194 const std::string& previous_title = replace_iter->second; |
195 | 195 |
196 const auto& page_notification_iter = | 196 const auto& page_notification_iter = |
197 page_notifications_.find(previous_title); | 197 page_notifications_.find(previous_title); |
198 if (page_notification_iter != page_notifications_.end()) { | 198 if (page_notification_iter != page_notifications_.end()) { |
199 DesktopNotificationDelegate* previous_delegate = | 199 DesktopNotificationDelegate* previous_delegate = |
200 page_notification_iter->second; | 200 page_notification_iter->second; |
201 | 201 |
202 previous_delegate->NotificationClosed(false); | 202 previous_delegate->NotificationClosed(); |
203 | 203 |
204 page_notifications_.erase(page_notification_iter); | 204 page_notifications_.erase(page_notification_iter); |
205 delete previous_delegate; | 205 delete previous_delegate; |
206 } | 206 } |
207 | 207 |
208 const auto& persistent_notification_iter = | 208 const auto& persistent_notification_iter = |
209 persistent_notifications_.find(previous_title); | 209 persistent_notifications_.find(previous_title); |
210 if (persistent_notification_iter != persistent_notifications_.end()) | 210 if (persistent_notification_iter != persistent_notifications_.end()) |
211 persistent_notifications_.erase(persistent_notification_iter); | 211 persistent_notifications_.erase(persistent_notification_iter); |
212 } | 212 } |
213 | 213 |
214 replacements_[tag] = base::UTF16ToUTF8(notification_data.title); | 214 replacements_[tag] = base::UTF16ToUTF8(notification_data.title); |
215 } | 215 } |
216 | 216 |
217 } // namespace content | 217 } // namespace content |
OLD | NEW |