Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: chrome/browser/notifications/notification_platform_bridge_android.cc

Issue 2151993002: [WebAPKs] Plumb service worker scope to notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into notification_scope Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()); 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; 185 ScopedJavaLocalRef<jstring> webapk_package;
190 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 186 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
191 switches::kEnableWebApk)) { 187 switches::kEnableWebApk)) {
188 GURL scope_url(notification.service_worker_scope());
189 if (!scope_url.is_valid())
190 scope_url = origin_url;
191 ScopedJavaLocalRef<jstring> j_scope_url =
192 ConvertUTF8ToJavaString(env, scope_url.spec());
192 webapk_package = Java_NotificationPlatformBridge_queryWebApkPackage( 193 webapk_package = Java_NotificationPlatformBridge_queryWebApkPackage(
193 env, java_object_.obj(), origin.obj()); 194 env, java_object_.obj(), j_scope_url.obj());
194 } else { 195 } else {
195 webapk_package = ConvertUTF8ToJavaString(env, ""); 196 webapk_package = ConvertUTF8ToJavaString(env, "");
196 } 197 }
197 198
198 ScopedJavaLocalRef<jstring> j_notification_id = 199 ScopedJavaLocalRef<jstring> j_notification_id =
199 ConvertUTF8ToJavaString(env, notification_id); 200 ConvertUTF8ToJavaString(env, notification_id);
201 ScopedJavaLocalRef<jstring> j_origin =
202 ConvertUTF8ToJavaString(env, origin_url.spec());
200 ScopedJavaLocalRef<jstring> tag = 203 ScopedJavaLocalRef<jstring> tag =
201 ConvertUTF8ToJavaString(env, notification.tag()); 204 ConvertUTF8ToJavaString(env, notification.tag());
202 ScopedJavaLocalRef<jstring> title = 205 ScopedJavaLocalRef<jstring> title =
203 ConvertUTF16ToJavaString(env, notification.title()); 206 ConvertUTF16ToJavaString(env, notification.title());
204 ScopedJavaLocalRef<jstring> body = 207 ScopedJavaLocalRef<jstring> body =
205 ConvertUTF16ToJavaString(env, notification.message()); 208 ConvertUTF16ToJavaString(env, notification.message());
206 209
207 ScopedJavaLocalRef<jobject> notification_icon; 210 ScopedJavaLocalRef<jobject> notification_icon;
208 SkBitmap notification_icon_bitmap = notification.icon().AsBitmap(); 211 SkBitmap notification_icon_bitmap = notification.icon().AsBitmap();
209 if (!notification_icon_bitmap.drawsNothing()) 212 if (!notification_icon_bitmap.drawsNothing())
(...skipping 13 matching lines...) Expand all
223 ScopedJavaLocalRef<jobjectArray> action_icons = 226 ScopedJavaLocalRef<jobjectArray> action_icons =
224 ConvertToJavaBitmaps(notification.buttons()); 227 ConvertToJavaBitmaps(notification.buttons());
225 228
226 ScopedJavaLocalRef<jintArray> vibration_pattern = 229 ScopedJavaLocalRef<jintArray> vibration_pattern =
227 base::android::ToJavaIntArray(env, notification.vibration_pattern()); 230 base::android::ToJavaIntArray(env, notification.vibration_pattern());
228 231
229 ScopedJavaLocalRef<jstring> j_profile_id = 232 ScopedJavaLocalRef<jstring> j_profile_id =
230 ConvertUTF8ToJavaString(env, profile_id); 233 ConvertUTF8ToJavaString(env, profile_id);
231 234
232 Java_NotificationPlatformBridge_displayNotification( 235 Java_NotificationPlatformBridge_displayNotification(
233 env, java_object_.obj(), j_notification_id.obj(), origin.obj(), 236 env, java_object_.obj(), j_notification_id.obj(), j_origin.obj(),
234 j_profile_id.obj(), incognito, tag.obj(), webapk_package.obj(), 237 j_profile_id.obj(), incognito, tag.obj(), webapk_package.obj(),
235 title.obj(), body.obj(), notification_icon.obj(), badge.obj(), 238 title.obj(), body.obj(), notification_icon.obj(), badge.obj(),
236 vibration_pattern.obj(), notification.timestamp().ToJavaTime(), 239 vibration_pattern.obj(), notification.timestamp().ToJavaTime(),
237 notification.renotify(), notification.silent(), action_titles.obj(), 240 notification.renotify(), notification.silent(), action_titles.obj(),
238 action_icons.obj()); 241 action_icons.obj());
239 242
240 regenerated_notification_infos_[notification_id] = 243 regenerated_notification_infos_[notification_id] =
241 RegeneratedNotificationInfo(origin_url.spec(), notification.tag(), 244 RegeneratedNotificationInfo(origin_url.spec(), notification.tag(),
242 ConvertJavaStringToUTF8(env, webapk_package)); 245 ConvertJavaStringToUTF8(env, webapk_package));
243 } 246 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 RegeneratedNotificationInfo() {} 303 RegeneratedNotificationInfo() {}
301 304
302 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: 305 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo::
303 RegeneratedNotificationInfo(const std::string& origin, 306 RegeneratedNotificationInfo(const std::string& origin,
304 const std::string& tag, 307 const std::string& tag,
305 const std::string& webapk_package) 308 const std::string& webapk_package)
306 : origin(origin), tag(tag), webapk_package(webapk_package) {} 309 : origin(origin), tag(tag), webapk_package(webapk_package) {}
307 310
308 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo:: 311 NotificationPlatformBridgeAndroid::RegeneratedNotificationInfo::
309 ~RegeneratedNotificationInfo() {} 312 ~RegeneratedNotificationInfo() {}
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification.cc ('k') | chrome/browser/notifications/platform_notification_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698