Pass service worker origin to NotificationPlatformBridge#Display() |
||||||
Issue descriptionCurrently we check whether a notifications's Notification::origin_url() falls with a WebAPK's scope to determine whether a notification should be shown as coming from the WebAPK in the Android UI. The scope of the WebAPK may be a sub origin. (e.g. www.google.com/maps vs www.google.com) The WebAPK's scope is taken from the Web App Manifest (https://www.w3.org/TR/appmanifest/#scope-member) Unfortunately Notification::origin_url() gives the top level scope. This means notifications are not attributed to a WebAPK unless the WebAPK's scope is also a top level scope
,
Jul 13 2016
Assigning to Peter Beverloo for implementation advice
,
Jul 13 2016
It sounds like you'd want to know the URL that displayed the notification, which could be either a page or a Service Worker. (The ExecutionContext's complete URL.) That would have to be plumbed up all the way from Blink. Today we pass the origin in a WebSecurityOrigin that doesn't hold the data either, so you'd have to change that to a WebURL. Two options: (1) Change the WebSecurityOrigin arguments to a WebURL, make sure we call GURL::GetOrigin() when doing the necessary permission checks. I don't know if this is OK given that SecurityOrigins are distinct entities throughout Blink. (2) Pass the displaying WebURL separately in the WebNotificationData/PlatformNotificationData object, figure out some way to teach the message_center::Notification about this. Intuitively I'd opt for (2), but maybe Miguel has other ideas?
,
Jul 13 2016
For WebAPKs we only need to know the service worker origin for persistent notifications only PlatformNotificationServiceImpl::DisplayPersistentNotification(). My understanding is that non-persistent notifications created via Notification::create() are disabled on Android. I am not sure if that makes the implementation simpler.' We plumb the service worker ID all the way up to PushMessagingNotificationManager::CheckForMissedNotification()
,
Jul 13 2016
For WebAPKs we only need to know the service worker scope for persistent notifications only (PlatformNotificationServiceImpl::DisplayPersistentNotification()). My understanding is that non-persistent notifications created via Notification::create() are disabled on Android. I am not sure if that makes the implementation simpler. We plumb the service worker ID all the way up to PushMessagingNotificationManager::CheckForMissedNotification()
,
Jul 13 2016
If the URL of the Service Worker scope is sufficient for you, as opposed to the document which may have shown the notification, you could add code in NotificationMessageFilter::OnShowPersistentNotification() which runs on the right thread and has the necessary information. (The class you're looking at is largely unrelated to any of this, as it exists to display a default notification in case the developer forgets, which, fortunately, is very rare.) It still leaves passing it to Android undefined— my suggestion would be to add it to //chrome/browser/notifications/notification.h for now. In the near term, we'd like to remove the dependency on the message center for Android and other platforms that don't use it, thus move to a data-only structure instead of the Notification class, but it makes no sense to block you on that :-).
,
Jul 13 2016
Just to make sure that I understand: On Android are there ways to show a notification other than via a service worker? Is there a "document which has shown the notification" for notifications which were shown by a service worker? My understanding is that there isn't one because a service worker can receive push messages (and send a notification as a result of the push message) even when Chrome is not running
,
Jul 14 2016
Not right now but we are planning (at some point) to enable in page notifications as toasts. I agree with Peter that the easiest would be to pass it to the notification.h object. You still need to do all the java plumbing though since we don't keep that object during JNI
,
Jul 14 2016
Assigning to myself given that I am going to implement this :)
,
Jul 18 2016
,
Jul 20 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/1f71208bc7377d187085071782ca34c6de8e2c1e commit 1f71208bc7377d187085071782ca34c6de8e2c1e Author: pkotwicz <pkotwicz@chromium.org> Date: Wed Jul 20 16:09:39 2016 This CL plumbs the service worker scope to PlatformNotificationServiceImpl::DisplayPersistentNotification() The service worker scope is used to determine whether the notification should be displayed using a WebAPK as the source or using Chrome as the source. On Android, the notification source is displayed when a user long-presses on a notification. A WebAPK is used as the source of the notification if the "service worker scope" falls within the "WebAPK scope". The "WebAPK scope" is determined by the "scope" attribute in the WebAPK's Web Manifest (http://html5doctor.com/web-manifest-specification/) BUG= 627842 TEST=PlatformNotificationServiceBrowserTest.PersistentNotificationServiceWorkerScope Review-Url: https://codereview.chromium.org/2151993002 Cr-Commit-Position: refs/heads/master@{#406570} [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/chrome/browser/notifications/notification.cc [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/chrome/browser/notifications/notification.h [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/chrome/browser/notifications/notification_platform_bridge_android.cc [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/chrome/browser/notifications/platform_notification_service_impl.cc [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/chrome/browser/notifications/platform_notification_service_impl.h [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/chrome/browser/notifications/platform_notification_service_unittest.cc [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/chrome/browser/push_messaging/push_messaging_notification_manager.cc [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/content/browser/notifications/notification_message_filter.cc [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/content/browser/notifications/notification_message_filter.h [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/content/browser/renderer_host/render_process_host_impl.cc [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/content/public/browser/platform_notification_service.h [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/content/shell/browser/layout_test/layout_test_notification_manager.cc [modify] https://crrev.com/1f71208bc7377d187085071782ca34c6de8e2c1e/content/shell/browser/layout_test/layout_test_notification_manager.h
,
Jul 21 2016
|
||||||
►
Sign in to add a comment |
||||||
Comment 1 by pkotw...@chromium.org
, Jul 13 2016Components: Mobile>WebAPKs
Labels: OS-Android