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 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/android/context_utils.h" | 10 #include "base/android/context_utils.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 ScopedJavaLocalRef<jstring> title = ConvertUTF16ToJavaString( | 158 ScopedJavaLocalRef<jstring> title = ConvertUTF16ToJavaString( |
159 env, notification.title()); | 159 env, notification.title()); |
160 ScopedJavaLocalRef<jstring> body = ConvertUTF16ToJavaString( | 160 ScopedJavaLocalRef<jstring> body = ConvertUTF16ToJavaString( |
161 env, notification.message()); | 161 env, notification.message()); |
162 | 162 |
163 ScopedJavaLocalRef<jobject> notification_icon; | 163 ScopedJavaLocalRef<jobject> notification_icon; |
164 SkBitmap notification_icon_bitmap = notification.icon().AsBitmap(); | 164 SkBitmap notification_icon_bitmap = notification.icon().AsBitmap(); |
165 if (!notification_icon_bitmap.drawsNothing()) | 165 if (!notification_icon_bitmap.drawsNothing()) |
166 notification_icon = gfx::ConvertToJavaBitmap(¬ification_icon_bitmap); | 166 notification_icon = gfx::ConvertToJavaBitmap(¬ification_icon_bitmap); |
167 | 167 |
| 168 ScopedJavaLocalRef<jobject> badge; |
| 169 SkBitmap badge_bitmap = notification.small_image().AsBitmap(); |
| 170 if (!badge_bitmap.drawsNothing()) |
| 171 badge = gfx::ConvertToJavaBitmap(&badge_bitmap); |
| 172 |
168 std::vector<base::string16> action_titles_vector; | 173 std::vector<base::string16> action_titles_vector; |
169 for (const message_center::ButtonInfo& button : notification.buttons()) | 174 for (const message_center::ButtonInfo& button : notification.buttons()) |
170 action_titles_vector.push_back(button.title); | 175 action_titles_vector.push_back(button.title); |
171 ScopedJavaLocalRef<jobjectArray> action_titles = | 176 ScopedJavaLocalRef<jobjectArray> action_titles = |
172 base::android::ToJavaArrayOfStrings(env, action_titles_vector); | 177 base::android::ToJavaArrayOfStrings(env, action_titles_vector); |
173 | 178 |
174 ScopedJavaLocalRef<jobjectArray> action_icons = | 179 ScopedJavaLocalRef<jobjectArray> action_icons = |
175 ConvertToJavaBitmaps(notification.buttons()); | 180 ConvertToJavaBitmaps(notification.buttons()); |
176 | 181 |
177 ScopedJavaLocalRef<jintArray> vibration_pattern = | 182 ScopedJavaLocalRef<jintArray> vibration_pattern = |
178 base::android::ToJavaIntArray(env, notification.vibration_pattern()); | 183 base::android::ToJavaIntArray(env, notification.vibration_pattern()); |
179 | 184 |
180 ScopedJavaLocalRef<jstring> profile_id = | 185 ScopedJavaLocalRef<jstring> profile_id = |
181 ConvertUTF8ToJavaString(env, profile->GetPath().BaseName().value()); | 186 ConvertUTF8ToJavaString(env, profile->GetPath().BaseName().value()); |
182 | 187 |
183 Java_NotificationUIManager_displayNotification( | 188 Java_NotificationUIManager_displayNotification( |
184 env, java_object_.obj(), persistent_notification_id, origin.obj(), | 189 env, java_object_.obj(), persistent_notification_id, origin.obj(), |
185 profile_id.obj(), profile->IsOffTheRecord(), tag.obj(), title.obj(), | 190 profile_id.obj(), profile->IsOffTheRecord(), tag.obj(), title.obj(), |
186 body.obj(), notification_icon.obj(), vibration_pattern.obj(), | 191 body.obj(), notification_icon.obj(), badge.obj(), vibration_pattern.obj(), |
187 notification.timestamp().ToJavaTime(), notification.renotify(), | 192 notification.timestamp().ToJavaTime(), notification.renotify(), |
188 notification.silent(), action_titles.obj(), action_icons.obj()); | 193 notification.silent(), action_titles.obj(), action_icons.obj()); |
189 | 194 |
190 regenerated_notification_infos_[persistent_notification_id] = | 195 regenerated_notification_infos_[persistent_notification_id] = |
191 std::make_pair(origin_url.spec(), notification.tag()); | 196 std::make_pair(origin_url.spec(), notification.tag()); |
192 | 197 |
193 notification.delegate()->Display(); | 198 notification.delegate()->Display(); |
194 } | 199 } |
195 | 200 |
196 bool NotificationUIManagerAndroid::Update(const Notification& notification, | 201 bool NotificationUIManagerAndroid::Update(const Notification& notification, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 return false; | 269 return false; |
265 } | 270 } |
266 | 271 |
267 void NotificationUIManagerAndroid::CancelAll() { | 272 void NotificationUIManagerAndroid::CancelAll() { |
268 NOTREACHED(); | 273 NOTREACHED(); |
269 } | 274 } |
270 | 275 |
271 bool NotificationUIManagerAndroid::RegisterNotificationUIManager(JNIEnv* env) { | 276 bool NotificationUIManagerAndroid::RegisterNotificationUIManager(JNIEnv* env) { |
272 return RegisterNativesImpl(env); | 277 return RegisterNativesImpl(env); |
273 } | 278 } |
OLD | NEW |