| Index: chrome/browser/android/download/download_controller.cc
|
| diff --git a/chrome/browser/android/download/download_controller.cc b/chrome/browser/android/download/download_controller.cc
|
| index c77b0f282df2296204a05c8ee2f9d44748d1b436..2d604abea4c7b5d6c778407259b3fd92e182ba46 100644
|
| --- a/chrome/browser/android/download/download_controller.cc
|
| +++ b/chrome/browser/android/download/download_controller.cc
|
| @@ -219,6 +219,57 @@ void DownloadController::AcquireFileAccessPermission(
|
| RequestFileAccess(callback_id);
|
| }
|
|
|
| +void DownloadController::CreateAndroidDownload(
|
| + const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
|
| + const DownloadInfo& info) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| +
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI, FROM_HERE,
|
| + base::Bind(&DownloadController::StartAndroidDownload,
|
| + base::Unretained(this),
|
| + wc_getter, info));
|
| +}
|
| +
|
| +void DownloadController::StartAndroidDownload(
|
| + const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
|
| + const DownloadInfo& info) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + WebContents* web_contents = wc_getter.Run();
|
| + if (!web_contents) {
|
| + // The view went away. Can't proceed.
|
| + LOG(ERROR) << "Tab closed, download failed on URL:" << info.url.spec();
|
| + return;
|
| + }
|
| +
|
| + AcquireFileAccessPermission(
|
| + web_contents,
|
| + base::Bind(&DownloadController::StartAndroidDownloadInternal,
|
| + base::Unretained(this), wc_getter, info));
|
| +}
|
| +
|
| +void DownloadController::StartAndroidDownloadInternal(
|
| + const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
|
| + const DownloadInfo& info, bool allowed) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + if (!allowed)
|
| + return;
|
| +
|
| + WebContents* web_contents = wc_getter.Run();
|
| + if (!web_contents) {
|
| + // The view went away. Can't proceed.
|
| + LOG(ERROR) << "Tab closed, download failed on URL:" << info.url.spec();
|
| + return;
|
| + }
|
| +
|
| + ChromeDownloadDelegate::FromWebContents(web_contents)->
|
| + EnqueueDownloadManagerRequest(
|
| + info.url.spec(), info.user_agent,
|
| + info.content_disposition, info.original_mime_type,
|
| + info.cookie, info.referer);
|
| +}
|
| +
|
| bool DownloadController::HasFileAccessPermission(
|
| ui::WindowAndroid* window_android) {
|
| ScopedJavaLocalRef<jobject> jwindow_android = window_android->GetJavaObject();
|
|
|