| 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/child/notifications/notification_manager.h" | 5 #include "content/child/notifications/notification_manager.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 void NotificationManager::OnWorkerRunLoopStopped() { | 66 void NotificationManager::OnWorkerRunLoopStopped() { |
| 67 delete this; | 67 delete this; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void NotificationManager::show( | 70 void NotificationManager::show( |
| 71 const blink::WebSerializedOrigin& origin, | 71 const blink::WebSerializedOrigin& origin, |
| 72 const blink::WebNotificationData& notification_data, | 72 const blink::WebNotificationData& notification_data, |
| 73 blink::WebNotificationDelegate* delegate) { | 73 blink::WebNotificationDelegate* delegate) { |
| 74 if (notification_data.icon.isEmpty()) { | 74 if (notification_data.icon.isEmpty() && notification_data.sound.isEmpty()) { |
| 75 DisplayPageNotification(origin, notification_data, delegate, SkBitmap()); | 75 DisplayPageNotification(origin, notification_data, delegate, SkBitmap()); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 | 78 |
| 79 pending_notifications_.FetchPageNotificationResources( | 79 pending_notifications_.FetchPageNotificationResources( |
| 80 notification_data, | 80 notification_data, |
| 81 delegate, | 81 delegate, |
| 82 base::Bind(&NotificationManager::DisplayPageNotification, | 82 base::Bind(&NotificationManager::DisplayPageNotification, |
| 83 base::Unretained(this), // this owns |pending_notifications_| | 83 base::Unretained(this), // this owns |pending_notifications_| |
| 84 origin, | 84 origin, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 108 // an indication that something has gone wrong. | 108 // an indication that something has gone wrong. |
| 109 size_t author_data_size = notification_data.data.size(); | 109 size_t author_data_size = notification_data.data.size(); |
| 110 UMA_HISTOGRAM_MEMORY_KB("Notifications.AuthorDataSizeKB", | 110 UMA_HISTOGRAM_MEMORY_KB("Notifications.AuthorDataSizeKB", |
| 111 static_cast<int>(ceil(author_data_size / 1024.0))); | 111 static_cast<int>(ceil(author_data_size / 1024.0))); |
| 112 | 112 |
| 113 if (author_data_size > PlatformNotificationData::kMaximumDeveloperDataSize) { | 113 if (author_data_size > PlatformNotificationData::kMaximumDeveloperDataSize) { |
| 114 owned_callbacks->onError(); | 114 owned_callbacks->onError(); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 | 117 |
| 118 if (notification_data.icon.isEmpty()) { | 118 if (notification_data.icon.isEmpty() && notification_data.sound.isEmpty()) { |
| 119 DisplayPersistentNotification(origin, | 119 DisplayPersistentNotification(origin, |
| 120 notification_data, | 120 notification_data, |
| 121 service_worker_registration_id, | 121 service_worker_registration_id, |
| 122 owned_callbacks.Pass(), | 122 owned_callbacks.Pass(), |
| 123 SkBitmap()); | 123 SkBitmap()); |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 | 126 |
| 127 pending_notifications_.FetchPersistentNotificationResources( | 127 pending_notifications_.FetchPersistentNotificationResources( |
| 128 notification_data, | 128 notification_data, |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 thread_safe_sender_->Send( | 333 thread_safe_sender_->Send( |
| 334 new PlatformNotificationHostMsg_ShowPersistent( | 334 new PlatformNotificationHostMsg_ShowPersistent( |
| 335 request_id, | 335 request_id, |
| 336 service_worker_registration_id, | 336 service_worker_registration_id, |
| 337 GURL(origin.string()), | 337 GURL(origin.string()), |
| 338 icon, | 338 icon, |
| 339 ToPlatformNotificationData(notification_data))); | 339 ToPlatformNotificationData(notification_data))); |
| 340 } | 340 } |
| 341 | 341 |
| 342 } // namespace content | 342 } // namespace content |
| OLD | NEW |