| 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/context_utils.h" | 9 #include "base/android/context_utils.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 ScopedJavaLocalRef<jstring> origin = ConvertUTF8ToJavaString( | 125 ScopedJavaLocalRef<jstring> origin = ConvertUTF8ToJavaString( |
| 126 env, origin_url.spec()); | 126 env, origin_url.spec()); |
| 127 ScopedJavaLocalRef<jstring> tag = | 127 ScopedJavaLocalRef<jstring> tag = |
| 128 ConvertUTF8ToJavaString(env, notification.tag()); | 128 ConvertUTF8ToJavaString(env, notification.tag()); |
| 129 ScopedJavaLocalRef<jstring> title = ConvertUTF16ToJavaString( | 129 ScopedJavaLocalRef<jstring> title = ConvertUTF16ToJavaString( |
| 130 env, notification.title()); | 130 env, notification.title()); |
| 131 ScopedJavaLocalRef<jstring> body = ConvertUTF16ToJavaString( | 131 ScopedJavaLocalRef<jstring> body = ConvertUTF16ToJavaString( |
| 132 env, notification.message()); | 132 env, notification.message()); |
| 133 | 133 |
| 134 ScopedJavaLocalRef<jobject> icon; | 134 ScopedJavaLocalRef<jobject> notification_icon; |
| 135 | 135 SkBitmap notification_icon_bitmap = notification.icon().AsBitmap(); |
| 136 SkBitmap icon_bitmap = notification.icon().AsBitmap(); | 136 if (!notification_icon_bitmap.isNull()) |
| 137 if (!icon_bitmap.isNull()) | 137 notification_icon = gfx::ConvertToJavaBitmap(¬ification_icon_bitmap); |
| 138 icon = gfx::ConvertToJavaBitmap(&icon_bitmap); | |
| 139 | 138 |
| 140 std::vector<base::string16> action_titles_vector; | 139 std::vector<base::string16> action_titles_vector; |
| 141 for (const message_center::ButtonInfo& button : notification.buttons()) | 140 for (const message_center::ButtonInfo& button : notification.buttons()) |
| 142 action_titles_vector.push_back(button.title); | 141 action_titles_vector.push_back(button.title); |
| 143 ScopedJavaLocalRef<jobjectArray> action_titles = | 142 ScopedJavaLocalRef<jobjectArray> action_titles = |
| 144 base::android::ToJavaArrayOfStrings(env, action_titles_vector); | 143 base::android::ToJavaArrayOfStrings(env, action_titles_vector); |
| 145 | 144 |
| 145 std::vector<SkBitmap> action_icons_vector; |
| 146 for (const message_center::ButtonInfo& button : notification.buttons()) |
| 147 action_icons_vector.push_back(button.icon.AsBitmap()); |
| 148 ScopedJavaLocalRef<jobjectArray> action_icons = |
| 149 gfx::ConvertToJavaBitmaps(action_icons_vector); |
| 150 |
| 146 ScopedJavaLocalRef<jintArray> vibration_pattern = | 151 ScopedJavaLocalRef<jintArray> vibration_pattern = |
| 147 base::android::ToJavaIntArray(env, notification.vibration_pattern()); | 152 base::android::ToJavaIntArray(env, notification.vibration_pattern()); |
| 148 | 153 |
| 149 ScopedJavaLocalRef<jstring> profile_id = | 154 ScopedJavaLocalRef<jstring> profile_id = |
| 150 ConvertUTF8ToJavaString(env, profile->GetPath().BaseName().value()); | 155 ConvertUTF8ToJavaString(env, profile->GetPath().BaseName().value()); |
| 151 | 156 |
| 152 Java_NotificationUIManager_displayNotification( | 157 Java_NotificationUIManager_displayNotification( |
| 153 env, java_object_.obj(), persistent_notification_id, origin.obj(), | 158 env, java_object_.obj(), persistent_notification_id, origin.obj(), |
| 154 profile_id.obj(), profile->IsOffTheRecord(), tag.obj(), title.obj(), | 159 profile_id.obj(), profile->IsOffTheRecord(), tag.obj(), title.obj(), |
| 155 body.obj(), icon.obj(), vibration_pattern.obj(), notification.silent(), | 160 body.obj(), notification_icon.obj(), vibration_pattern.obj(), |
| 156 action_titles.obj()); | 161 notification.silent(), action_titles.obj(), action_icons.obj()); |
| 157 | 162 |
| 158 regenerated_notification_infos_[persistent_notification_id] = | 163 regenerated_notification_infos_[persistent_notification_id] = |
| 159 std::make_pair(origin_url.spec(), notification.tag()); | 164 std::make_pair(origin_url.spec(), notification.tag()); |
| 160 | 165 |
| 161 notification.delegate()->Display(); | 166 notification.delegate()->Display(); |
| 162 } | 167 } |
| 163 | 168 |
| 164 bool NotificationUIManagerAndroid::Update(const Notification& notification, | 169 bool NotificationUIManagerAndroid::Update(const Notification& notification, |
| 165 Profile* profile) { | 170 Profile* profile) { |
| 166 NOTREACHED(); | 171 NOTREACHED(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 return false; | 237 return false; |
| 233 } | 238 } |
| 234 | 239 |
| 235 void NotificationUIManagerAndroid::CancelAll() { | 240 void NotificationUIManagerAndroid::CancelAll() { |
| 236 NOTREACHED(); | 241 NOTREACHED(); |
| 237 } | 242 } |
| 238 | 243 |
| 239 bool NotificationUIManagerAndroid::RegisterNotificationUIManager(JNIEnv* env) { | 244 bool NotificationUIManagerAndroid::RegisterNotificationUIManager(JNIEnv* env) { |
| 240 return RegisterNativesImpl(env); | 245 return RegisterNativesImpl(env); |
| 241 } | 246 } |
| OLD | NEW |