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

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: addressed some comments 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
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/DownloadController.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, "");
+ 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(
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/DownloadController.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698