| 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_platform_bridge_android.h" | 5 #include "chrome/browser/notifications/notification_platform_bridge_android.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const std::string& notification_id, | 174 const std::string& notification_id, |
| 175 const std::string& profile_id, | 175 const std::string& profile_id, |
| 176 bool incognito, | 176 bool incognito, |
| 177 const Notification& notification) { | 177 const Notification& notification) { |
| 178 JNIEnv* env = AttachCurrentThread(); | 178 JNIEnv* env = AttachCurrentThread(); |
| 179 // TODO(miguelg): Store the notification type in java instead of assuming it's | 179 // TODO(miguelg): Store the notification type in java instead of assuming it's |
| 180 // persistent once/if non persistent notifications are ever implemented on | 180 // persistent once/if non persistent notifications are ever implemented on |
| 181 // Android. | 181 // Android. |
| 182 DCHECK_EQ(notification_type, NotificationCommon::PERSISTENT); | 182 DCHECK_EQ(notification_type, NotificationCommon::PERSISTENT); |
| 183 | 183 |
| 184 GURL origin_url(notification.origin_url().GetOrigin()); | |
| 185 | |
| 186 ScopedJavaLocalRef<jstring> origin = | |
| 187 ConvertUTF8ToJavaString(env, origin_url.spec()); | |
| 188 | |
| 189 ScopedJavaLocalRef<jstring> webapk_package; | 184 ScopedJavaLocalRef<jstring> webapk_package; |
| 190 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 185 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 191 switches::kEnableWebApk)) { | 186 switches::kEnableWebApk)) { |
| 187 ScopedJavaLocalRef<jstring> scope = |
| 188 ConvertUTF8ToJavaString(env, notification.scope_url().spec()); |
| 192 webapk_package = Java_NotificationPlatformBridge_queryWebApkPackage( | 189 webapk_package = Java_NotificationPlatformBridge_queryWebApkPackage( |
| 193 env, java_object_.obj(), origin.obj()); | 190 env, java_object_.obj(), scope.obj()); |
| 194 } else { | 191 } else { |
| 195 webapk_package = ConvertUTF8ToJavaString(env, ""); | 192 webapk_package = ConvertUTF8ToJavaString(env, ""); |
| 196 } | 193 } |
| 197 | 194 |
| 198 ScopedJavaLocalRef<jstring> j_notification_id = | 195 ScopedJavaLocalRef<jstring> j_notification_id = |
| 199 ConvertUTF8ToJavaString(env, notification_id); | 196 ConvertUTF8ToJavaString(env, notification_id); |
| 197 GURL origin_url = notification.origin_url().GetOrigin(); |
| 198 ScopedJavaLocalRef<jstring> origin = |
| 199 ConvertUTF8ToJavaString(env, origin_url.spec()); |
| 200 ScopedJavaLocalRef<jstring> tag = | 200 ScopedJavaLocalRef<jstring> tag = |
| 201 ConvertUTF8ToJavaString(env, notification.tag()); | 201 ConvertUTF8ToJavaString(env, notification.tag()); |
| 202 ScopedJavaLocalRef<jstring> title = | 202 ScopedJavaLocalRef<jstring> title = |
| 203 ConvertUTF16ToJavaString(env, notification.title()); | 203 ConvertUTF16ToJavaString(env, notification.title()); |
| 204 ScopedJavaLocalRef<jstring> body = | 204 ScopedJavaLocalRef<jstring> body = |
| 205 ConvertUTF16ToJavaString(env, notification.message()); | 205 ConvertUTF16ToJavaString(env, notification.message()); |
| 206 | 206 |
| 207 ScopedJavaLocalRef<jobject> notification_icon; | 207 ScopedJavaLocalRef<jobject> notification_icon; |
| 208 SkBitmap notification_icon_bitmap = notification.icon().AsBitmap(); | 208 SkBitmap notification_icon_bitmap = notification.icon().AsBitmap(); |
| 209 if (!notification_icon_bitmap.drawsNothing()) | 209 if (!notification_icon_bitmap.drawsNothing()) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 RegeneratedNotificationInfo() {} | 300 RegeneratedNotificationInfo() {} |
| 301 | 301 |
| 302 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 302 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
| 303 RegeneratedNotificationInfo(const std::string& origin, | 303 RegeneratedNotificationInfo(const std::string& origin, |
| 304 const std::string& tag, | 304 const std::string& tag, |
| 305 const std::string& webapk_package) | 305 const std::string& webapk_package) |
| 306 : origin(origin), tag(tag), webapk_package(webapk_package) {} | 306 : origin(origin), tag(tag), webapk_package(webapk_package) {} |
| 307 | 307 |
| 308 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: | 308 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: |
| 309 ~RegeneratedNotificationInfo() {} | 309 ~RegeneratedNotificationInfo() {} |
| OLD | NEW |