Import Notifications - Service Worker issue

178 views
Skip to first unread message

Andi

unread,
Jun 24, 2020, 4:54:10 PM6/24/20
to Chromium-dev
Hello,

I can import Notifications from standard chrome, but they don't seem to be triggered because the matching service worker is not present chrome://serviceworker-internals/

Is there any way to bypass that, without needing to re-visit the page? Shouldn't the service workers also be imported when notifications are imported?

Regards,
Andi

PhistucK

unread,
Jun 24, 2020, 6:22:52 PM6/24/20
to l33t...@gmail.com, Chromium-dev
What does "import Notifications from standard chrome" mean?

(This group is for discussing Chromium build issues and general C++/Python and internal Chromium scripts ("Web UI") in Chromium, not JavaScript or websites/web applications, so you might have reached the wrong place)

PhistucK


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/aa63ace7-2142-429c-97b4-cfa98954b3b2o%40chromium.org.

Andi

unread,
Jun 25, 2020, 4:11:42 AM6/25/20
to Chromium-dev, PhistucK, Chromium-dev
@PhistucK
I played with code inside:
chrome/browser/importer/importer_list.cc and 
- chrome/browser/importer/in_process_importer_bridge.cc 
so I can import some of notification settings you see here: chrome://settings/content/notifications 

The problem is that even if I succeed importing those notifications settings, I assume I still won't be able to receive notifications, because they are sent by each website using service workers (some .js files which are pushed by the page you enable notifications on)

The question was: do you think there is a way to also import those service workers specific to each website and add them here: chrome://serviceworker-internals/ ? I don't fully understand importing and service workers mechanisms. Do you know if that import is technically possible?

I might have landed on the wrong place, but import code is chromium cpp code and the group is called chromium-dev. So I thought I could present my idea here.

PhistucK

unread,
Jun 25, 2020, 4:21:33 AM6/25/20
to Andi, Chromium-dev
Yes, it is the right place.
I am not sure you can import notifications caused by push notifications (I think most of the use cases of notifications coming from service workers are using push notifications), since they require the Google infrastructure of push notifications and probably a particular key/secret, which is probably not available to non-Google distributions...

Anyway, maybe someone else can help regarding importing service workers.

PhistucK

Andi

unread,
Jan 7, 2021, 6:52:36 AM1/7/21
to Chromium-dev, PhistucK, Chromium-dev
Hello, I opened https://bugs.chromium.org/p/chromium/issues/detail?id=1135974 related to this a while ago. Do you think this feature can be implemented?

Peter Beverloo

unread,
Jan 7, 2021, 12:29:54 PM1/7/21
to l33t...@gmail.com, PhistucK, Chromium-dev
Hi Andi,

By doing this, you're importing notification permission status rather than the actual ability for sites to send you notifications. Registering the necessary service worker is very specific to an individual website, as some require you to log in to an account before offering the ability to get notified. It's not impossible, but really hard to get right and not something we're focused on right now.

Thanks,
Peter


Andi

unread,
Jan 8, 2021, 3:41:17 AM1/8/21
to Chromium-dev, Peter Beverloo, Chromium-dev
Hi Peter,

Unless I'm mistaken, the login state of the user is saved inside cookies. So in order to import service worker for a specific website the already existing cookies should also be imported (assuming we don't want the user to manually open website and login). But the cookies are NOT enough I think. The user still needs to navigate to the website so the correct service worker is registered. 

Do you have any idea if the service worker (which is a .js script) can be imported (as bookmarks are imported for example) to enable notifications and then "tied" to the website? Or navigating to specific website is mandatory? Can you point me to the source code where service worker is added to the browser (maybe it is in blink code)?

Thank you,
Andi
Reply all
Reply to author
Forward
0 new messages