Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: content/browser/android/download_controller_android_impl.cc

Issue 152683003: Pass the filename obtained from content-disposition header for download (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/android/download_controller_android_impl.cc
diff --git a/content/browser/android/download_controller_android_impl.cc b/content/browser/android/download_controller_android_impl.cc
index f3a274a3ef4a7e043597cf53ab9cc59d81bdc4cb..16864ab4ab38455e3daed4a30eebed30cf02aac5 100644
--- a/content/browser/android/download_controller_android_impl.cc
+++ b/content/browser/android/download_controller_android_impl.cc
@@ -27,6 +27,7 @@
#include "jni/DownloadController_jni.h"
#include "net/cookies/cookie_options.h"
#include "net/cookies/cookie_store.h"
+#include "net/http/http_content_disposition.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
@@ -221,10 +222,16 @@ void DownloadControllerAndroidImpl::StartAndroidDownload(
ScopedJavaLocalRef<jstring> jreferer =
ConvertUTF8ToJavaString(env, info.referer);
+ // Try parsing the content disposition header to get a
+ // explicitly specified filename if available.
+ net::HttpContentDisposition header(info.content_disposition, "");
boliu 2014/02/07 18:11:47 Hmm... If we use the full blown GetSuggestedFilen
shashi 2014/02/07 18:59:12 I agree with Bo, that should be the best way and e
Jinsuk Kim 2014/02/08 02:49:28 I'd like to upstream the filename decision logic e
Jinsuk Kim 2014/02/08 02:49:28 I was not aware of GetSuggestedFilename and it is
boliu 2014/02/08 02:51:23 sgtm, yaron already gave lgtm, which is all you ne
+ ScopedJavaLocalRef<jstring> jfilename =
+ ConvertUTF8ToJavaString(env, header.filename());
+
Java_DownloadController_newHttpGetDownload(
env, GetJavaObject()->Controller(env).obj(), view.obj(), jurl.obj(),
juser_agent.obj(), jcontent_disposition.obj(), jmime_type.obj(),
- jcookie.obj(), jreferer.obj(), info.total_bytes);
+ jcookie.obj(), jreferer.obj(), jfilename.obj(), info.total_bytes);
}
void DownloadControllerAndroidImpl::OnDownloadStarted(

Powered by Google App Engine
This is Rietveld 408576698