Bug 55473 - [GTK] Add support for external protocol handlers
Summary: [GTK] Add support for external protocol handlers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-01 08:42 PST by Sergio Villar Senin
Modified: 2011-03-02 22:42 PST (History)
4 users (show)

See Also:


Attachments
Patch (7.31 KB, patch)
2011-03-01 08:51 PST, Sergio Villar Senin
abarth: review-
Details | Formatted Diff | Diff
Patch (1.66 KB, patch)
2011-03-02 02:21 PST, Sergio Villar Senin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Villar Senin 2011-03-01 08:42:06 PST
In order to do that we need:
   * Some way to disable the default  handling of about: protocols in webcore (by default about: means empty document)
   * WebKitGtk+ API to disable the about: default behaviour commented above
Comment 1 Sergio Villar Senin 2011-03-01 08:51:06 PST
Created attachment 84235 [details]
Patch
Comment 2 Martin Robinson 2011-03-01 09:21:52 PST
Comment on attachment 84235 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=84235&action=review

Instead of adding new API (though perhaps we still want to), would it make sense to just query soup for an installed "about:" handler while handling a request. If the handler is installed then remove it from the empty document schemas.

What does Chromium do to get around the empty document scheme issue?

> Source/WebKit/gtk/webkit/webkitglobals.cpp:220
> +void webkit_register_url_scheme_as_local (const gchar* scheme)
> +{
> +    webkitInit();
> +    SchemeRegistry::registerURLSchemeAsLocal(String::fromUTF8(scheme));
> +}
> +
> +void webkit_remove_url_scheme_registered_as_local (const gchar* scheme)
> +{
> +    webkitInit();
> +    SchemeRegistry::removeURLSchemeRegisteredAsLocal(String::fromUTF8(scheme));
> +}
> +
> +void webkit_register_url_scheme_as_empty_document (const gchar* scheme)
> +{
> +    webkitInit();
> +    SchemeRegistry::registerURLSchemeAsEmptyDocument(String::fromUTF8(scheme));
> +}
> +
> +void webkit_remove_url_scheme_registered_as_empty_document (const gchar* scheme)
> +{
> +    webkitInit();
> +    SchemeRegistry::removeURLSchemeRegisteredAsEmptyDocument(String::fromUTF8(scheme));
> +}

extra space after the function names.
Comment 3 Sergio Villar Senin 2011-03-01 10:15:49 PST
(In reply to comment #2)
> (From update of attachment 84235 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=84235&action=review
> 
> Instead of adding new API (though perhaps we still want to), would it make sense to just query soup for an installed "about:" handler while handling a request. If the handler is installed then remove it from the empty document schemas.

That's indeed possible. I went for the new API approach because all the other ports offer that API, so I thought it'd be sensible to have it also in WebKitGtk+.

> What does Chromium do to get around the empty document scheme issue?

I didn't check that but Dan commented once that they just don't issue the request to webkit and handle it all at browser's level.
Comment 4 Eric Seidel (no email) 2011-03-01 11:53:48 PST
I'm really not the protocol expert.
Comment 5 Sergio Villar Senin 2011-03-01 12:39:46 PST
(In reply to comment #2)
> (From update of attachment 84235 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=84235&action=review
> 
> Instead of adding new API (though perhaps we still want to), would it make sense to just query soup for an installed "about:" handler while handling a request. If the handler is installed then remove it from the empty document schemas.

BTW forget about my answer, I missunderstood what you meant. What you suggest isn't possible because the request does not even reach the platform network layer as it's handled internally by WebCore.
Comment 6 Martin Robinson 2011-03-01 12:40:44 PST
(In reply to comment #5)
> > Instead of adding new API (though perhaps we still want to), would it make sense to just query soup for an installed "about:" handler while handling a request. If the handler is installed then remove it from the empty document schemas.
> BTW forget about my answer, I missunderstood what you meant. What you suggest isn't possible because the request does not even reach the platform network layer as it's handled internally by WebCore.

I guess this could be handled in the WebKit layer. Perhaps FrameLoaderClient allows some access.
Comment 7 Adam Barth 2011-03-01 13:37:12 PST
Comment on attachment 84235 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=84235&action=review

> Source/WebCore/platform/SchemeRegistry.cpp:82
> +    DEFINE_STATIC_LOCAL(bool, firstTime, (true));

I don't think this is needed for primitive types.
Comment 8 Adam Barth 2011-03-01 13:39:39 PST
Comment on attachment 84235 [details]
Patch

This isn't really a good idea.  That about scheme is super magical.  Putting non-empty documents in the about scheme doesn't really work.

The about:blah URLs in Chrome are handled by the embedder.  Typically, they're either translated to a data URL for WebKit or to another internal URL in the "chrome" scheme.
Comment 9 Sergio Villar Senin 2011-03-02 02:17:24 PST
(In reply to comment #8)
> (From update of attachment 84235 [details])
> This isn't really a good idea.  That about scheme is super magical.  Putting non-empty documents in the about scheme doesn't really work.

Just for the sake of knowing a bit more about WebCore guts, what is special about the "about:" protocol? What kind of tricky stuff does it?

> The about:blah URLs in Chrome are handled by the embedder.  Typically, they're either translated to a data URL for WebKit or to another internal URL in the "chrome" scheme.

Ok, I'll follow that approach then. Thanks for reviewing.
Comment 10 Sergio Villar Senin 2011-03-02 02:19:32 PST
Renaming the bug title. We're not going to change the "about:" behaviour but we still need to allow external protocol handlers. In order to do that we have to allow clients to create their own SoupRequesters that will be used to register new protocols.
Comment 11 Sergio Villar Senin 2011-03-02 02:21:07 PST
Created attachment 84384 [details]
Patch

I just kept the ResourceHandleSoup part of the original patch.
Comment 12 Sergio Villar Senin 2011-03-02 10:03:27 PST
Comment on attachment 84384 [details]
Patch

Clearing flags on attachment: 84384

Committed r80143: <http://trac.webkit.org/changeset/80143>
Comment 13 Sergio Villar Senin 2011-03-02 10:03:36 PST
All reviewed patches have been landed.  Closing bug.
Comment 14 Adam Barth 2011-03-02 22:42:51 PST
> Just for the sake of knowing a bit more about WebCore guts, what is special about the "about:" protocol? What kind of tricky stuff does it?

Some examples:

1) Loads of about: URLs are synchronous instead of asynchronous.
2) about: URLs inherit the security context of their parent (or opener if there isn't a parent).
3) about: URLs are used internally by the WebKit in various situations where having a non-empty document would be problematic (e.g., frame initialization and in the XSS filter).

(2) is really scary if about: URLs start containing anything besides the empty document.