Bug 85998 - [GTK] Add webkit_web_view_can_show_mime_type() to WebKit2 GTK+ API
Summary: [GTK] Add webkit_web_view_can_show_mime_type() to WebKit2 GTK+ API
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2012-05-09 08:51 PDT by Carlos Garcia Campos
Modified: 2012-05-29 23:43 PDT (History)
4 users (show)

See Also:


Attachments
Patch (16.80 KB, patch)
2012-05-09 08:56 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch to match wk1 behaviour (17.39 KB, patch)
2012-05-09 09:44 PDT, Carlos Garcia Campos
mrobinson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2012-05-09 08:51:00 PDT
It's useful to know whether a mime type can be displayed in a WebView.
Comment 1 Carlos Garcia Campos 2012-05-09 08:56:16 PDT
Created attachment 140955 [details]
Patch
Comment 2 WebKit Review Bot 2012-05-09 09:01:17 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Martin Robinson 2012-05-09 09:16:47 PDT
Comment on attachment 140955 [details]
Patch

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

> Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp:202
> +    if (decisionType != WEBKIT_POLICY_DECISION_TYPE_RESPONSE) {
> +        webkit_policy_decision_use(decision);
> +        return TRUE;
> +    }
> +
> +    WebKitURIResponse* response = webkit_response_policy_decision_get_response(WEBKIT_RESPONSE_POLICY_DECISION(decision));
> +    if (webkit_web_view_can_show_mime_type(webView, webkit_uri_response_get_mime_type(response)))
> +        webkit_policy_decision_use(decision);
> +    else
> +        webkit_policy_decision_download(decision);
> +

Hrm. It seems odd that a library would write non-cache data to the filesystem without the embedder specifically opting in to that.
Comment 4 Carlos Garcia Campos 2012-05-09 09:24:24 PDT
(In reply to comment #3)
> (From update of attachment 140955 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=140955&action=review
> 
> > Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp:202
> > +    if (decisionType != WEBKIT_POLICY_DECISION_TYPE_RESPONSE) {
> > +        webkit_policy_decision_use(decision);
> > +        return TRUE;
> > +    }
> > +
> > +    WebKitURIResponse* response = webkit_response_policy_decision_get_response(WEBKIT_RESPONSE_POLICY_DECISION(decision));
> > +    if (webkit_web_view_can_show_mime_type(webView, webkit_uri_response_get_mime_type(response)))
> > +        webkit_policy_decision_use(decision);
> > +    else
> > +        webkit_policy_decision_download(decision);
> > +
> 
> Hrm. It seems odd that a library would write non-cache data to the filesystem without the embedder specifically opting in to that.

This is what wk1 does, try to open a binary file in minibrowser, for example, and the data is loaded inot the view as text. That's no expected. Note that download() doesn't download the file, but initiates a download operation. That's how all browsers work when you click on link and the content can't be shown in the web view.
Comment 5 Carlos Garcia Campos 2012-05-09 09:26:25 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > (From update of attachment 140955 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=140955&action=review
> > 
> > > Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp:202
> > > +    if (decisionType != WEBKIT_POLICY_DECISION_TYPE_RESPONSE) {
> > > +        webkit_policy_decision_use(decision);
> > > +        return TRUE;
> > > +    }
> > > +
> > > +    WebKitURIResponse* response = webkit_response_policy_decision_get_response(WEBKIT_RESPONSE_POLICY_DECISION(decision));
> > > +    if (webkit_web_view_can_show_mime_type(webView, webkit_uri_response_get_mime_type(response)))
> > > +        webkit_policy_decision_use(decision);
> > > +    else
> > > +        webkit_policy_decision_download(decision);
> > > +
> > 
> > Hrm. It seems odd that a library would write non-cache data to the filesystem without the embedder specifically opting in to that.
> 
> This is what wk1 does, try to open a binary file in minibrowser, for example, and the data is loaded inot the view as text. That's no expected. Note that download() doesn't download the file, but initiates a download operation. That's how all browsers work when you click on link and the content can't be shown in the web view.

wait, I'm wrong, they ignore it actually, only download it when response has an attachment
Comment 6 Carlos Garcia Campos 2012-05-09 09:44:57 PDT
Created attachment 140961 [details]
Updated patch to match wk1 behaviour
Comment 7 Carlos Garcia Campos 2012-05-29 09:10:05 PDT
Committed r118786: <http://trac.webkit.org/changeset/118786>
Comment 8 Philippe Normand 2012-05-29 12:57:47 PDT
ERROR:../../Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp:715:void testWebViewCanShowMIMEType(WebViewTest*, const void*): assertion failed: (webkit_web_view_can_show_mime_type(test->m_webView, "audio/ogg"))

On the 3 bots. Can you please keep an eye on the bot next time after landing a patch adding new tests? Thanks :)
Comment 9 Carlos Garcia Campos 2012-05-29 23:43:02 PDT
(In reply to comment #8)
> ERROR:../../Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp:715:void testWebViewCanShowMIMEType(WebViewTest*, const void*): assertion failed: (webkit_web_view_can_show_mime_type(test->m_webView, "audio/ogg"))
> 
> On the 3 bots. Can you please keep an eye on the bot next time after landing a patch adding new tests? Thanks :)

This passed locally, sorry, I'll fix it.