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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 permission_map_.clear(); | 60 permission_map_.clear(); |
61 } | 61 } |
62 | 62 |
63 void LayoutTestNotificationManager::DisplayNotification( | 63 void LayoutTestNotificationManager::DisplayNotification( |
64 BrowserContext* browser_context, | 64 BrowserContext* browser_context, |
65 const GURL& origin, | 65 const GURL& origin, |
66 const SkBitmap& icon, | 66 const SkBitmap& icon, |
67 const PlatformNotificationData& notification_data, | 67 const PlatformNotificationData& notification_data, |
68 scoped_ptr<DesktopNotificationDelegate> delegate, | 68 scoped_ptr<DesktopNotificationDelegate> delegate, |
69 int render_process_id, | |
70 base::Closure* cancel_callback) { | 69 base::Closure* cancel_callback) { |
71 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 70 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
72 std::string title = base::UTF16ToUTF8(notification_data.title); | 71 std::string title = base::UTF16ToUTF8(notification_data.title); |
73 | 72 |
74 DCHECK(cancel_callback); | 73 DCHECK(cancel_callback); |
75 *cancel_callback = base::Bind(&LayoutTestNotificationManager::Close, | 74 *cancel_callback = base::Bind(&LayoutTestNotificationManager::Close, |
76 weak_factory_.GetWeakPtr(), | 75 weak_factory_.GetWeakPtr(), |
77 title); | 76 title); |
78 | 77 |
79 ReplaceNotificationIfNeeded(notification_data); | 78 ReplaceNotificationIfNeeded(notification_data); |
80 | 79 |
81 page_notifications_[title] = delegate.release(); | 80 page_notifications_[title] = delegate.release(); |
82 page_notifications_[title]->NotificationDisplayed(); | 81 page_notifications_[title]->NotificationDisplayed(); |
83 } | 82 } |
84 | 83 |
85 void LayoutTestNotificationManager::DisplayPersistentNotification( | 84 void LayoutTestNotificationManager::DisplayPersistentNotification( |
86 BrowserContext* browser_context, | 85 BrowserContext* browser_context, |
87 int64 service_worker_registration_id, | 86 int64 service_worker_registration_id, |
88 const GURL& origin, | 87 const GURL& origin, |
89 const SkBitmap& icon, | 88 const SkBitmap& icon, |
90 const PlatformNotificationData& notification_data, | 89 const PlatformNotificationData& notification_data) { |
91 int render_process_id) { | |
92 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 90 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
93 std::string title = base::UTF16ToUTF8(notification_data.title); | 91 std::string title = base::UTF16ToUTF8(notification_data.title); |
94 | 92 |
95 ReplaceNotificationIfNeeded(notification_data); | 93 ReplaceNotificationIfNeeded(notification_data); |
96 | 94 |
97 PersistentNotification notification; | 95 PersistentNotification notification; |
98 notification.browser_context = browser_context; | 96 notification.browser_context = browser_context; |
99 notification.origin = origin; | 97 notification.origin = origin; |
100 notification.notification_data = notification_data; | 98 notification.notification_data = notification_data; |
101 notification.service_worker_registration_id = service_worker_registration_id; | 99 notification.service_worker_registration_id = service_worker_registration_id; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 const auto& persistent_notification_iter = | 192 const auto& persistent_notification_iter = |
195 persistent_notifications_.find(previous_title); | 193 persistent_notifications_.find(previous_title); |
196 if (persistent_notification_iter != persistent_notifications_.end()) | 194 if (persistent_notification_iter != persistent_notifications_.end()) |
197 persistent_notifications_.erase(persistent_notification_iter); | 195 persistent_notifications_.erase(persistent_notification_iter); |
198 } | 196 } |
199 | 197 |
200 replacements_[replace_id] = base::UTF16ToUTF8(notification_data.title); | 198 replacements_[replace_id] = base::UTF16ToUTF8(notification_data.title); |
201 } | 199 } |
202 | 200 |
203 } // namespace content | 201 } // namespace content |
OLD | NEW |