Support "registerProtocolHandler" in WebKit2

# Gyuyoung Kim (5 years ago)

Hello,

I would like to listen what do you think to support 'registerProtocolHandler' in WebKit2.

This feature is to execute web content through registered custom protocol.

  • For example, web content can register "mailto" custom protocol using this feature,

    <script> navigator.registerProtocolHandler("mailto", "mail.naver.com", "Web Mail"); </script>

    <html> <head> <title>Web Protocol Handler Sample - Test</title> </head> <body> <p>Send an email : this !</p> </body> </html>

Besides this feature has been supported by Mozilla and Chromium (From Mozilla 3.0, Chromium 13). - developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler

The feature is included in the W3C recommendation 28 released on Oct. 2014.

IIRC, some WebKit1 ports supported this feature though, those ports were deprecated. Now WebKit port supports this feature no more.

There is a very old bug to support this feature though, it wasn't maintained so far. Recently I updated it based on latest WebKit.

Feel free to give me any feedback about this feature.

Gyuyoung.

Contact us to advertise here
# Benjamin Poulain (5 years ago)

Looks llke nobody objects. Please make sure to #ifdef everything and disable the feature on OS X and iOS.

What is your plan for testing?

# Gyuyoung Kim (5 years ago)

Looks llke nobody objects. Please make sure to #ifdef everything and

disable the feature on OS X and iOS.

Ok, let me add #ifdef guard for WK2 ports which don't use this feature.

There are already basic test cases for this feature. But I think this isn't enough to test all use cases. - trac.webkit.org/browser/trunk/LayoutTests/fast/dom/NavigatorContentUtils

After landing WK2 implementation, I'm going to improve the test cases or add new tests for some use cases.

Thanks, Gyuyoung.

On Thu, May 21, 2015 at 3:32 PM, Benjamin Poulain <benjamin at webkit.org>

wrote:

# Anders Carlsson (5 years ago)

On May 20, 2015, at 11:32 PM, Benjamin Poulain <benjamin at webkit.org> wrote:

Looks llke nobody objects.

That’s not true. From the bug:

Sam Weinig <mailto:sam at webkit.org> 2015-05-15 10:12:54 PDT

Support for navigator.registerProtocolHandler/unregisterProtocolHandler is not something we want to support in WebKit2 at this time as we are not confident it is a good Web API. This might be a good conversation for webkit-dev.

I agree with Sam.

# Gyuyoung Kim (5 years ago)

yes, Sam didn't like to support this feature. However, as I said, I think this feature has been shipped by Firefox and Chrome browsers. Besides It seems to me that web application will need to use this feature in near future. However I know we can't support new feature without WK2 owner's agreement.

I wonder if it is impossible to add new feature to WK2 as an experimental feature with #ifdef guard or other better method.

Gyuyoung.

# Anne van Kesteren (5 years ago)

On Fri, May 22, 2015 at 1:25 AM, Anders Carlsson <andersca at apple.com> wrote:

Sam Weinig 2015-05-15 10:12:54 PDT:

Support for navigator.registerProtocolHandler/unregisterProtocolHandler is not something we want to support in WebKit2 at this time as we are not confident it is a good Web API. This might be a good conversation for webkit-dev.

I agree with Sam.

So what else should web-based email or IRC clients or some such use to integrate with sites that offer mailto and irc URLs? Especially for email it seems like a worthwhile thing to solve. And that there's no cross-browser way to do it in 2015 is somewhat of a shame.

# Maciej Stachowiak (5 years ago)

On May 21, 2015, at 7:38 PM, Anne van Kesteren <annevk at annevk.nl> wrote:

On Fri, May 22, 2015 at 1:25 AM, Anders Carlsson <andersca at apple.com> wrote:

Sam Weinig 2015-05-15 10:12:54 PDT:

Support for navigator.registerProtocolHandler/unregisterProtocolHandler is not something we want to support in WebKit2 at this time as we are not confident it is a good Web API. This might be a good conversation for webkit-dev.

I agree with Sam.

So what else should web-based email or IRC clients or some such use to integrate with sites that offer mailto and irc URLs? Especially for email it seems like a worthwhile thing to solve. And that there's no cross-browser way to do it in 2015 is somewhat of a shame.

I think it’s useful to have an API for the "mailto" use case. A lot of people use webmail as their default mail client, and it seems nice to make mailto: links do the right thing for them. We do allow changing the default Mail reader to a native app, at least on Mac. I would almost consider having navigator.registerProtocolHandler just for that use case.

On the face of it, the registerProtocolHandler API seems more general than necessary, but the actual spec for it has a whitelist of specific schemes, most of which seem reasonable for this kind of purpose: html.spec.whatwg.org/#custom-handlers, html.spec.whatwg.org/#custom-handlers

I am curious what Sam and Anders dislike about this API, and whether it might be something we’d want to support at least with a more restricted set of schemes.

(I am more dubious of the content handler aspect.)

# Anne van Kesteren (5 years ago)

On Fri, May 22, 2015 at 12:26 PM, Maciej Stachowiak <mjs at apple.com> wrote:

(I am more dubious of the content handler aspect.)

Agreed, especially as it requires the service to download the resource again. For that use case we need something smarter where you can pass along an object/stream of sorts I think.

# Gyuyoung Kim (5 years ago)

On the face of it, the registerProtocolHandler API seems more general than

necessary, but the actual spec for it has a whitelist of specific schemes, most of which seem reasonable for this kind of >purpose:

html.spec.whatwg.org/#custom-handlers

Yes, the custom-handlers specification only allows us to use specific schemes, and current WebCore implementation was implemented based on the spec. Current supported schemes are only below,

    "bitcoin", "geo", "im", "irc", "ircs", "magnet", "mailto", "mms",

"news", "nntp", "sip", "sms", "smsto", "ssh", "tel", "urn", "webcal", "wtai", "xmpp"

(I am more dubious of the content handler aspect.)

Agreed, especially as it requires the service to download the resource again. For that use case we need something smarter where you can pass along an object/stream of sorts I think.

I also don't want to support the "content handler" feature at the moment. The feature might be more clear and mature. The patch of Bug 92749 only supports registerProtocolHandler, and unregisterProtocolHandler and isProtocolHandlerRegistered are supported as optional.

bugs.webkit.org/show_bug.cgi?id=92749

Gyuyoung.

On Fri, May 22, 2015 at 12:50 PM, Anne van Kesteren <annevk at annevk.nl>

wrote:

# Anne van Kesteren (5 years ago)

On Fri, May 22, 2015 at 1:50 PM, Gyuyoung Kim <gyuyoung.kim at webkit.org> wrote:

I also don't want to support the "content handler" feature at the moment. The feature might be more clear and mature. The patch of Bug 92749 only supports registerProtocolHandler, and unregisterProtocolHandler and isProtocolHandlerRegistered are supported as optional.

bugs.webkit.org/show_bug.cgi?id=92749

Quickly scanning the bug I couldn't figure out whether you added hooks to HTML's navigate algorithm or Fetch' fetch algorithm. In particular, see the discussion in this bug:

www.w3.org/Bugs/Public/show_bug.cgi?id=24091

My personal opinion is that these schemes should only have an effect if you navigate to them, not if you fetch them (the latter should result in a network error in my opinion).

# Gyuyoung Kim (5 years ago)

Quickly scanning the bug I couldn't figure out whether you added hooks to HTML's navigate algorithm or Fetch' fetch algorithm. In particular, see the discussion in this bug:

www.w3.org/Bugs/Public/show_bug.cgi?id=24091

My personal opinion is that these schemes should only have an effect if you navigate to them, not if you fetch them (the latter should result in a network error in my opinion).

Current implementation doesn't hook to HTML's navigation directly. We delegate the html navigation(or call native application) to application. Application is able to decide to navigate the given html page or execute native application through the patch. As far as I know, Chrome also has similar implementation.

If this feature can be landed, I have a plan to test this scenario based on mock implementation.

Gyuyoung.

# Gyuyoung Kim (5 years ago)

Quickly scanning the bug I couldn't figure out whether you added hooks to HTML's navigate algorithm or Fetch' fetch algorithm. In particular, see the discussion in this bug:

www.w3.org/Bugs/Public/show_bug.cgi?id=24091

My personal opinion is that these schemes should only have an effect if you navigate to them, not if you fetch them (the latter should result in a network error in my opinion).

Current implementation doesn't hook to HTML's navigation directly. We delegate the html navigation(or call native application) to application. Application is able to decide to navigate the given html page or execute native application through the patch. As far as I know, Chrome also has similar implementation.

If this feature can be landed, I have a plan to test this scenario based on mock implementation.

Gyuyoung.

# Anne van Kesteren (5 years ago)

On Fri, May 22, 2015 at 6:43 PM, Gyuyoung Kim <gyuyoung.kim at webkit.org> wrote:

Current implementation doesn't hook to HTML's navigation directly. We delegate the html navigation(or call native application) to application. Application is able to decide to navigate the given html page or execute native application through the patch. As far as I know, Chrome also has similar implementation.

Okay, so

<img src=mailto:...>

results in a network error and not a fetch to the registered URL?

# Gyuyoung Kim (5 years ago)

I need to verify the behaviour using the patch though, I think the registered URL isn't fetched under current patch of Bug 92749. However I need to check if the registered URL is passed to application under the patch's implementation. If this feature will be landed to WK2, it would be good if we add a test to check it. Let me do it.

Gyuyoung.

# Gyuyoung Kim (5 years ago)

It seem to me there are both agreements and objections to support this feature in WebKit2. It looks many web contents have already used some custom schemes as 'mailto://', and In my humble opinion, the feature will be able to improve the usage of the custom scheme. Besides we can control the supported custom schemes because the feature only supports pre-defined custom schemes. Web content is only able to use the pre-defined custom schemes. In my opinion, it would be good if the feature is supported by WebKit2 although it is added as an experimental feature using #ifdef.

However If WK2 owners still think this feature needs to be more stable, I will wait until they agree it.

Gyuyoung.

On Sat, May 23, 2015 at 12:36 PM, Gyuyoung Kim <gyuyoung.kim at webkit.org>

wrote:

# Michael Catanzaro (5 years ago)

On Wed, 2015-05-20 at 10:31 +0900, Gyuyoung Kim wrote:

I would like to listen what do you think to support 'registerProtocolHandler' in WebKit2.

This feature is to execute web content through registered custom protocol.

Hi,

I think this would be useful for GNOME. One of our goals is for the user to be able to set GMail as the default mail application in System Settings. If the user visits gmail.com and it attempts to register itself as a mailto:// handler, I envision the WebKitGTK+ would fire a signal that would trigger Epiphany to display an info bar to ask the user for approval. If the user approves the registration, we would go one step further: we'd create a new web application for GMail and in the desktop file indicate support for the MIME type x-scheme -handler/mailto (or if the user already has a GMail web application, modify the desktop file to add that MIME type). The user would then be able to set the GMail web app as the default mail application systemwide.

We would restrict this functionality to HTTPS sites only. I'd greatly prefer that restriction to be enforced by WebKit rather than implementing that policy in Epiphany.

Michael

# Gyuyoung Kim (5 years ago)

In order to support the use case on Epiphany browser, we need to support this feature on WK2 first. Besides, as far as I know, EFL browser will have similar use-case by using this feature. Thus, in my humble opinion, similar use cases can be more required in near future.

Gyuyoung.

On Tue, Jun 2, 2015 at 9:21 PM, Michael Catanzaro <mcatanzaro at igalia.com>

wrote:

# Darin Adler (5 years ago)

Are we making progress in this discussion?

Maciej stated that he thinks this is useful for mailto and I think that Gyuyoung Kim and Michael Catanzaro stated that they want to do this.

As one next step in the discussion, is there anyone that wants to present a use case for a protocol other than mailto?

Sam, Anders, you haven’t replied to the thread since Maciej made his remarks two weeks ago. He asked what you dislike about the API.

— Darin

# Michael Catanzaro (5 years ago)

On Sun, 2015-06-07 at 17:39 -0700, Darin Adler wrote:

As one next step in the discussion, is there anyone that wants to present a use case for a protocol other than mailto?

irc:// would be useful for those who don't like desktop clients.

# Gyuyoung Kim (5 years ago)

On Mon, Jun 8, 2015 at 12:02 PM, Michael Catanzaro <mcatanzaro at igalia.com>

wrote:

On Sun, 2015-06-07 at 17:39 -0700, Darin Adler wrote:

As one next step in the discussion, is there anyone that wants to present a use case for a protocol other than mailto?

irc:// would be useful for those who don't like desktop clients.

"geo:" would be useful for people who want to use map application as well.

Gyuyoung.

# Gyuyoung Kim (5 years ago)

On Mon, Jun 8, 2015 at 9:39 AM, Darin Adler <darin at apple.com> wrote:

Sam, Anders, you haven’t replied to the thread since Maciej made his remarks two weeks ago. He asked what you dislike about the API.

It seems that some people hope to listen why you guys dislike about this API as well as I want.

Gyuyoung.

On Thu, Jun 11, 2015 at 10:06 AM, Gyuyoung Kim <gyuyoung.kim at webkit.org>

wrote:

# Gyuyoung Kim (5 years ago)

WebKit2 already has a similar feature, which is so-called custom protocol enabled by Mac, Gtk and EFL ports. However the custom protocol feature supports to register custom scheme through API layer instead of JavaScript. The registerProtocolHandler() is to support to register the custom scheme by means of JavaScript. I don't know yet why we can't support to register it from JavaScript.

Gyuyoung.

On Tue, Jun 16, 2015 at 10:43 AM, Gyuyoung Kim <gyuyoung.kim at webkit.org>

wrote:

# Sam Weinig (5 years ago)

(Sorry, had this sitting in my drafts).

My concern with the registerProtocolHandler() API is that it complicates an already the very complicated area of custom protocols and a good implementation requires configuration UI (to choose which of potentially multiple apps/websites you want a specific protocol to go to) that I am not sure users are in the position make.

That, coupled with the small existing usage on the web and very few (if any) reports from developers that they want this, leads me to think it isn’t a good API for us to support.

From an implementation perspective I also have concerns. How is this should the registration data be managed? Can it fit in the WebSiteData model we are using for other data? Does it account for non-persistent sessions? And lastly, can we get the code size of supporting a feature like this to be smaller?

# Brady Eidson (5 years ago)

On Jul 1, 2015, at 7:42 PM, Gyuyoung Kim <gyuyoung.kim at webkit.org> wrote:

WebKit2 already has a similar feature, which is so-called custom protocol enabled by Mac, Gtk and EFL ports. However the custom protocol feature supports to register custom scheme through API layer instead of JavaScript. The registerProtocolHandler() is to support to register the custom scheme by means of JavaScript. I don't know yet why we can't support to register it from JavaScript.

The custom protocol handler feature of the WebKit2 API is for the embedding native application to provide raw data to resource loads directly.

While tangentially related to how registerProtocolHandler would work for some uses, there’s numerous differences.

One key example: Since it was implemented for the native embedding application (which is, of course, trusted) none of the normal web security concerns have been taken into account.

Also, since they’re for special-use native apps instead of a general web browser, none of Sam’s concerns had to be accounted for:

On Jul 4, 2015, at 10:24 AM, Sam Weinig <weinig at apple.com> wrote:

My concern with the registerProtocolHandler() API is that it complicates an already the very complicated area of custom protocols and a good implementation requires configuration UI (to choose which of potentially multiple apps/websites you want a specific protocol to go to) that I am not sure users are in the position make.
... From an implementation perspective I also have concerns. How is this should the registration data be managed? Can it fit in the WebSiteData model we are using for other data? Does it account for non-persistent sessions? And lastly, can we get the code size of supporting a feature like this to be smaller?

I’m not crafting this reply as an argument against registerProtocolHandler, but rather to dispel the notion that exposing "WK2 custom protocols” to JS is all we need to do to get registerProtocolHandler.

~Brady

# Gyuyoung Kim (5 years ago)

The custom protocol handler feature of the WebKit2 API is for the

embedding native application to provide raw data to resource loads directly.

While tangentially related to how registerProtocolHandler would work for

some uses, there’s numerous differences.

If so, custom protocol handler feature is different with role of registerProtocolHandler. Thank you for your explanation about it.

One key example: Since it was implemented for the native embedding

application (which is, of course, trusted) none of the normal web security concerns have been taken into account.

Also, since they’re for special-use native apps instead of a general web

browser, none of Sam’s concerns had to be accounted for:

For more detailed scenario in addition to Brady's explanation, I consider below call sequence to use registerProtocolHandler.

  1. Custom scheme is registered by "registeredProtocolHandler()" in JS
  2. The registered scheme will be filtering in WebCore. (If unsupported scheme is requested, security error happens.)
  3. Filtered scheme will be passed to application side (of course, which is web browser or similar things)
  4. The application will register passed custom scheme and a callback to call the native embedding application to WK2's network using "custom protocol handler feature", which was implemented in WebKit2."

Thus, in my humble opinion, registerProtocolHandler will use the custom protocol instead of complicating it.

Gyuyoung.

# Frédéric Wang (14 hours ago)

I'm just bumping this old thread, not because I plan to implement it but because I was mentioning it on slack the other day and realized not everybody is #standards:

webkit.slack.com/archives/CTY7Z24RZ/p1587142539064000

In particular, my question was related to safelist VS blocklist discussion from whatwg/html#3998

From the slack replies as well as lists.webkit.org/pipermail/webkit-dev/2019-November/030967.html it seems a complete switch to blocklist is not the option preferred for WebKit (if we ever decide to implement this API) so that's what I commented on the spec / blink-dev discussions.

# Maciej Stachowiak (6 hours ago)

Looking at my old email, I think it’s worth supporting for Mail clients for example, but I think it would require some OS-level engineering as well to have it work on macOS. (Other Apple platforms currently don’t support customizing the default mail client).

And I do still think that allow list is safer than block list.

Want more features?

Request early access to our private beta of readable email premium.