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 "chrome/browser/notifications/notification_ui_manager_android.h" | 5 #include "chrome/browser/notifications/notification_ui_manager_android.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 int64 service_worker_registration_id) { | 52 int64 service_worker_registration_id) { |
53 scoped_ptr<Pickle> pickle(new Pickle); | 53 scoped_ptr<Pickle> pickle(new Pickle); |
54 | 54 |
55 // content::PlatformNotificationData | 55 // content::PlatformNotificationData |
56 pickle->WriteString16(notification_data.title); | 56 pickle->WriteString16(notification_data.title); |
57 pickle->WriteInt(static_cast<int>(notification_data.direction)); | 57 pickle->WriteInt(static_cast<int>(notification_data.direction)); |
58 pickle->WriteString(notification_data.lang); | 58 pickle->WriteString(notification_data.lang); |
59 pickle->WriteString16(notification_data.body); | 59 pickle->WriteString16(notification_data.body); |
60 pickle->WriteString16(notification_data.tag); | 60 pickle->WriteString16(notification_data.tag); |
61 pickle->WriteString(notification_data.icon.spec()); | 61 pickle->WriteString(notification_data.icon.spec()); |
| 62 pickle->WriteBool(notification_data.silent); |
62 | 63 |
63 // The origin which is displaying the notification. | 64 // The origin which is displaying the notification. |
64 pickle->WriteString(origin.spec()); | 65 pickle->WriteString(origin.spec()); |
65 | 66 |
66 // The Service Worker registration this notification is associated with. | 67 // The Service Worker registration this notification is associated with. |
67 pickle->WriteInt64(service_worker_registration_id); | 68 pickle->WriteInt64(service_worker_registration_id); |
68 | 69 |
69 if (pickle->size() > kMaximumSerializedNotificationSizeBytes) | 70 if (pickle->size() > kMaximumSerializedNotificationSizeBytes) |
70 return nullptr; | 71 return nullptr; |
71 | 72 |
(...skipping 10 matching lines...) Expand all Loading... |
82 | 83 |
83 std::string icon_url, origin_url; | 84 std::string icon_url, origin_url; |
84 int direction_value; | 85 int direction_value; |
85 | 86 |
86 // Unpack content::PlatformNotificationData. | 87 // Unpack content::PlatformNotificationData. |
87 if (!iterator.ReadString16(¬ification_data->title) || | 88 if (!iterator.ReadString16(¬ification_data->title) || |
88 !iterator.ReadInt(&direction_value) || | 89 !iterator.ReadInt(&direction_value) || |
89 !iterator.ReadString(¬ification_data->lang) || | 90 !iterator.ReadString(¬ification_data->lang) || |
90 !iterator.ReadString16(¬ification_data->body) || | 91 !iterator.ReadString16(¬ification_data->body) || |
91 !iterator.ReadString16(¬ification_data->tag) || | 92 !iterator.ReadString16(¬ification_data->tag) || |
92 !iterator.ReadString(&icon_url)) { | 93 !iterator.ReadString(&icon_url) || |
| 94 !iterator.ReadBool(¬ification_data->silent)) { |
93 return false; | 95 return false; |
94 } | 96 } |
95 | 97 |
96 notification_data->direction = | 98 notification_data->direction = |
97 static_cast<content::PlatformNotificationData::NotificationDirection>( | 99 static_cast<content::PlatformNotificationData::NotificationDirection>( |
98 direction_value); | 100 direction_value); |
99 notification_data->icon = GURL(icon_url); | 101 notification_data->icon = GURL(icon_url); |
100 | 102 |
101 // Unpack the origin which displayed this notification. | 103 // Unpack the origin which displayed this notification. |
102 if (!iterator.ReadString(&origin_url)) | 104 if (!iterator.ReadString(&origin_url)) |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 "Unable to serialize the notification, payload too large (max 1MB)."; | 269 "Unable to serialize the notification, payload too large (max 1MB)."; |
268 RemoveProfileNotification(profile_notification); | 270 RemoveProfileNotification(profile_notification); |
269 return; | 271 return; |
270 } | 272 } |
271 | 273 |
272 notification_data = base::android::ToJavaByteArray( | 274 notification_data = base::android::ToJavaByteArray( |
273 env, static_cast<const uint8*>(pickle->data()), pickle->size()); | 275 env, static_cast<const uint8*>(pickle->data()), pickle->size()); |
274 } | 276 } |
275 | 277 |
276 int platform_id = Java_NotificationUIManager_displayNotification( | 278 int platform_id = Java_NotificationUIManager_displayNotification( |
277 env, java_object_.obj(), tag.obj(), id.obj(), title.obj(), body.obj(), | 279 env, |
278 icon.obj(), origin.obj(), notification_data.obj()); | 280 java_object_.obj(), |
| 281 tag.obj(), |
| 282 id.obj(), |
| 283 title.obj(), |
| 284 body.obj(), |
| 285 icon.obj(), |
| 286 origin.obj(), |
| 287 notification.silent(), |
| 288 notification_data.obj()); |
279 | 289 |
280 RegeneratedNotificationInfo notification_info( | 290 RegeneratedNotificationInfo notification_info( |
281 notification.replace_id(), platform_id, | 291 notification.replace_id(), platform_id, |
282 notification.origin_url().GetOrigin().spec()); | 292 notification.origin_url().GetOrigin().spec()); |
283 regenerated_notification_infos_.insert(std::make_pair( | 293 regenerated_notification_infos_.insert(std::make_pair( |
284 profile_notification->notification().id(), notification_info)); | 294 profile_notification->notification().id(), notification_info)); |
285 | 295 |
286 notification.delegate()->Display(); | 296 notification.delegate()->Display(); |
287 } | 297 } |
288 | 298 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 466 |
457 ProfileNotification* NotificationUIManagerAndroid::FindProfileNotification( | 467 ProfileNotification* NotificationUIManagerAndroid::FindProfileNotification( |
458 const std::string& id) const { | 468 const std::string& id) const { |
459 auto iter = profile_notifications_.find(id); | 469 auto iter = profile_notifications_.find(id); |
460 if (iter == profile_notifications_.end()) | 470 if (iter == profile_notifications_.end()) |
461 return nullptr; | 471 return nullptr; |
462 | 472 |
463 return iter->second; | 473 return iter->second; |
464 } | 474 } |
465 | 475 |
OLD | NEW |