Merge lp:~abreu-alexandre/oxide/mimetype-from-suggested-filename into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Alexandre Abreu
Status: Merged
Merged at revision: 1108
Proposed branch: lp:~abreu-alexandre/oxide/mimetype-from-suggested-filename
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Prerequisite: lp:~abreu-alexandre/oxide/add-ua-to-downloadrequested
Diff against target: 50 lines (+10/-2)
3 files modified
qt/tests/qmltests/api/tst_WebView_downloadRequested.qml (+2/-1)
qt/tests/qmltests/api/tst_WebView_downloadRequestedAnchor.html (+1/-1)
shared/browser/oxide_resource_dispatcher_host_delegate.cc (+7/-0)
To merge this branch: bzr merge lp:~abreu-alexandre/oxide/mimetype-from-suggested-filename
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+260602@code.launchpad.net

Commit message

Guess mimetype based on suggested filename when available

Description of the change

Guess mimetype based on suggested filename when available

To post a comment you must log in.
1104. By Alexandre Abreu

Expose user agent as part of downloadRequest

1105. By Alexandre Abreu

Guess mimetype based on suggested filename when available

Revision history for this message
Chris Coulson (chrisccoulson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qt/tests/qmltests/api/tst_WebView_downloadRequested.qml'
2--- qt/tests/qmltests/api/tst_WebView_downloadRequested.qml 2015-05-29 18:10:18 +0000
3+++ qt/tests/qmltests/api/tst_WebView_downloadRequested.qml 2015-05-29 18:10:19 +0000
4@@ -86,7 +86,8 @@
5 spy.wait();
6
7 compare(spy.count, 1)
8- compare(webView.latestSuggestedFilename, "MyDownload")
9+ compare(webView.latestSuggestedFilename, "MyDownload.html")
10+ compare(webView.latestMimeType, "text/html")
11 }
12
13 function test_WebView_downloadRequestUnhandledMimeType() {
14
15=== modified file 'qt/tests/qmltests/api/tst_WebView_downloadRequestedAnchor.html'
16--- qt/tests/qmltests/api/tst_WebView_downloadRequestedAnchor.html 2015-05-29 18:10:18 +0000
17+++ qt/tests/qmltests/api/tst_WebView_downloadRequestedAnchor.html 2015-05-29 18:10:19 +0000
18@@ -2,6 +2,6 @@
19 <body>
20 </body>
21 <div>
22-<a id="content" href="http://testsuite/empty.html" download="MyDownload">download me</a>
23+<a id="content" href="http://testsuite/empty.html" download="MyDownload.html">download me</a>
24 </div>
25 </html>
26
27=== modified file 'shared/browser/oxide_resource_dispatcher_host_delegate.cc'
28--- shared/browser/oxide_resource_dispatcher_host_delegate.cc 2015-05-29 18:10:18 +0000
29+++ shared/browser/oxide_resource_dispatcher_host_delegate.cc 2015-05-29 18:10:19 +0000
30@@ -25,6 +25,7 @@
31 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/resource_context.h"
33 #include "content/public/common/referrer.h"
34+#include "net/base/mime_util.h"
35 #include "net/cookies/cookie_monster.h"
36 #include "net/http/http_content_disposition.h"
37 #include "net/http/http_request_headers.h"
38@@ -80,6 +81,12 @@
39 }
40 request->Cancel();
41
42+ if (!suggested_name.empty() && mime_type.empty()) {
43+ net::GetMimeTypeFromExtension(
44+ base::FilePath(suggested_name).Extension(),
45+ &mime_type);
46+ }
47+
48 // POST request cannot be repeated in general, so prevent client from
49 // retrying the same request, even if it is with a GET.
50 if ("GET" == request->method()) {

Subscribers

People subscribed via source and target branches