Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/android/download_controller_android_impl.h" | 5 #include "content/browser/android/download_controller_android_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "content/browser/renderer_host/render_view_host_impl.h" | 25 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 26 #include "content/browser/web_contents/web_contents_impl.h" | 26 #include "content/browser/web_contents/web_contents_impl.h" |
| 27 #include "content/public/browser/browser_context.h" | 27 #include "content/public/browser/browser_context.h" |
| 28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/download_url_parameters.h" | 29 #include "content/public/browser/download_url_parameters.h" |
| 30 #include "content/public/browser/global_request_id.h" | 30 #include "content/public/browser/global_request_id.h" |
| 31 #include "content/public/browser/resource_request_info.h" | 31 #include "content/public/browser/resource_request_info.h" |
| 32 #include "content/public/common/content_client.h" | 32 #include "content/public/common/content_client.h" |
| 33 #include "content/public/common/referrer.h" | 33 #include "content/public/common/referrer.h" |
| 34 #include "jni/DownloadController_jni.h" | 34 #include "jni/DownloadController_jni.h" |
| 35 #include "net/base/filename_util.h" | |
| 35 #include "net/cookies/cookie_options.h" | 36 #include "net/cookies/cookie_options.h" |
| 36 #include "net/cookies/cookie_store.h" | 37 #include "net/cookies/cookie_store.h" |
| 37 #include "net/http/http_content_disposition.h" | 38 #include "net/http/http_content_disposition.h" |
| 38 #include "net/http/http_request_headers.h" | 39 #include "net/http/http_request_headers.h" |
| 39 #include "net/http/http_response_headers.h" | 40 #include "net/http/http_response_headers.h" |
| 40 #include "net/url_request/url_request.h" | 41 #include "net/url_request/url_request.h" |
| 41 #include "net/url_request/url_request_context.h" | 42 #include "net/url_request/url_request_context.h" |
| 42 | 43 |
| 43 using base::android::ConvertUTF8ToJavaString; | 44 using base::android::ConvertUTF8ToJavaString; |
| 44 using base::android::ScopedJavaLocalRef; | 45 using base::android::ScopedJavaLocalRef; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 ConvertUTF8ToJavaString(env, info.content_disposition); | 384 ConvertUTF8ToJavaString(env, info.content_disposition); |
| 384 ScopedJavaLocalRef<jstring> jmime_type = | 385 ScopedJavaLocalRef<jstring> jmime_type = |
| 385 ConvertUTF8ToJavaString(env, info.original_mime_type); | 386 ConvertUTF8ToJavaString(env, info.original_mime_type); |
| 386 ScopedJavaLocalRef<jstring> jcookie = | 387 ScopedJavaLocalRef<jstring> jcookie = |
| 387 ConvertUTF8ToJavaString(env, info.cookie); | 388 ConvertUTF8ToJavaString(env, info.cookie); |
| 388 ScopedJavaLocalRef<jstring> jreferer = | 389 ScopedJavaLocalRef<jstring> jreferer = |
| 389 ConvertUTF8ToJavaString(env, info.referer); | 390 ConvertUTF8ToJavaString(env, info.referer); |
| 390 | 391 |
| 391 // Try parsing the content disposition header to get a | 392 // Try parsing the content disposition header to get a |
| 392 // explicitly specified filename if available. | 393 // explicitly specified filename if available. |
| 393 net::HttpContentDisposition header(info.content_disposition, ""); | 394 net::HttpContentDisposition header(info.content_disposition, ""); |
|
asanka
2016/02/22 22:56:08
header is unused.
qinmin
2016/02/22 23:03:36
Done.
| |
| 394 ScopedJavaLocalRef<jstring> jfilename = | 395 ScopedJavaLocalRef<jstring> jfilename = |
| 395 ConvertUTF8ToJavaString(env, header.filename()); | 396 base::android::ConvertUTF16ToJavaString( |
| 397 env, | |
| 398 net::GetSuggestedFilename(info.url, | |
| 399 info.content_disposition, | |
| 400 std::string(), // referrer_charset | |
| 401 std::string(), // suggested_name | |
| 402 info.original_mime_type, | |
| 403 std::string())); // default name | |
|
asanka
2016/02/22 22:56:08
Provide a default name in case one cannot be gener
qinmin
2016/02/22 23:03:36
net::GetSuggestedFilename() will fallback to "down
asanka
2016/02/23 00:05:56
That's not a localized string. See IDS_DEFAULT_DOW
qinmin
2016/02/23 07:23:10
Done. IDS_DEFAULT_DOWNLOAD_FILENAME is defined in
| |
| 396 | 404 |
| 397 Java_DownloadController_newHttpGetDownload( | 405 Java_DownloadController_newHttpGetDownload( |
| 398 env, GetJavaObject()->Controller(env).obj(), view.obj(), jurl.obj(), | 406 env, GetJavaObject()->Controller(env).obj(), view.obj(), jurl.obj(), |
| 399 juser_agent.obj(), jcontent_disposition.obj(), jmime_type.obj(), | 407 juser_agent.obj(), jcontent_disposition.obj(), jmime_type.obj(), |
| 400 jcookie.obj(), jreferer.obj(), info.has_user_gesture, jfilename.obj(), | 408 jcookie.obj(), jreferer.obj(), info.has_user_gesture, jfilename.obj(), |
| 401 info.total_bytes); | 409 info.total_bytes); |
| 402 } | 410 } |
| 403 | 411 |
| 404 void DownloadControllerAndroidImpl::OnDownloadStarted( | 412 void DownloadControllerAndroidImpl::OnDownloadStarted( |
| 405 DownloadItem* download_item) { | 413 DownloadItem* download_item) { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 } | 580 } |
| 573 | 581 |
| 574 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 582 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 575 if (info) | 583 if (info) |
| 576 has_user_gesture = info->HasUserGesture(); | 584 has_user_gesture = info->HasUserGesture(); |
| 577 } | 585 } |
| 578 | 586 |
| 579 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} | 587 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} |
| 580 | 588 |
| 581 } // namespace content | 589 } // namespace content |
| OLD | NEW |