| 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> small_icon; |
| 169 SkBitmap small_icon_bitmap = notification.small_image().AsBitmap(); |
| 170 if (!small_icon_bitmap.drawsNothing()) |
| 171 small_icon = gfx::ConvertToJavaBitmap(&small_icon_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(), small_icon.obj(), |
| 187 notification.timestamp().ToJavaTime(), notification.renotify(), | 192 vibration_pattern.obj(), notification.timestamp().ToJavaTime(), |
| 188 notification.silent(), action_titles.obj(), action_icons.obj()); | 193 notification.renotify(), notification.silent(), action_titles.obj(), |
| 194 action_icons.obj()); |
| 189 | 195 |
| 190 regenerated_notification_infos_[persistent_notification_id] = | 196 regenerated_notification_infos_[persistent_notification_id] = |
| 191 std::make_pair(origin_url.spec(), notification.tag()); | 197 std::make_pair(origin_url.spec(), notification.tag()); |
| 192 | 198 |
| 193 notification.delegate()->Display(); | 199 notification.delegate()->Display(); |
| 194 } | 200 } |
| 195 | 201 |
| 196 bool NotificationUIManagerAndroid::Update(const Notification& notification, | 202 bool NotificationUIManagerAndroid::Update(const Notification& notification, |
| 197 Profile* profile) { | 203 Profile* profile) { |
| 198 NOTREACHED(); | 204 NOTREACHED(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 return false; | 270 return false; |
| 265 } | 271 } |
| 266 | 272 |
| 267 void NotificationUIManagerAndroid::CancelAll() { | 273 void NotificationUIManagerAndroid::CancelAll() { |
| 268 NOTREACHED(); | 274 NOTREACHED(); |
| 269 } | 275 } |
| 270 | 276 |
| 271 bool NotificationUIManagerAndroid::RegisterNotificationUIManager(JNIEnv* env) { | 277 bool NotificationUIManagerAndroid::RegisterNotificationUIManager(JNIEnv* env) { |
| 272 return RegisterNativesImpl(env); | 278 return RegisterNativesImpl(env); |
| 273 } | 279 } |
| OLD | NEW |