It's useful to know whether a mime type can be displayed in a WebView.
Created attachment 140955 [details] Patch
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 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.
(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.
(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
Created attachment 140961 [details] Updated patch to match wk1 behaviour
Committed r118786: <http://trac.webkit.org/changeset/118786>
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 :)
(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.