| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/android/download/download_controller.h" | 5 #include "chrome/browser/android/download/download_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/context_utils.h" | 10 #include "base/android/context_utils.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 if (!allowed) | 260 if (!allowed) |
| 261 return; | 261 return; |
| 262 | 262 |
| 263 WebContents* web_contents = wc_getter.Run(); | 263 WebContents* web_contents = wc_getter.Run(); |
| 264 if (!web_contents) { | 264 if (!web_contents) { |
| 265 // The view went away. Can't proceed. | 265 // The view went away. Can't proceed. |
| 266 LOG(ERROR) << "Tab closed, download failed on URL:" << info.url.spec(); | 266 LOG(ERROR) << "Tab closed, download failed on URL:" << info.url.spec(); |
| 267 return; | 267 return; |
| 268 } | 268 } |
| 269 | 269 |
| 270 ChromeDownloadDelegate::FromWebContents(web_contents)-> | 270 base::string16 filename = |
| 271 EnqueueDownloadManagerRequest( | 271 net::GetSuggestedFilename(info.url, info.content_disposition, |
| 272 info.url.spec(), info.user_agent, | 272 std::string(), // referrer_charset |
| 273 info.content_disposition, info.original_mime_type, | 273 std::string(), // suggested_name |
| 274 info.cookie, info.referer); | 274 info.original_mime_type, default_file_name_); |
| 275 ChromeDownloadDelegate::FromWebContents(web_contents) |
| 276 ->EnqueueDownloadManagerRequest(info.url.spec(), info.user_agent, |
| 277 filename, info.original_mime_type, |
| 278 info.cookie, info.referer); |
| 275 } | 279 } |
| 276 | 280 |
| 277 bool DownloadController::HasFileAccessPermission( | 281 bool DownloadController::HasFileAccessPermission( |
| 278 ui::WindowAndroid* window_android) { | 282 ui::WindowAndroid* window_android) { |
| 279 ScopedJavaLocalRef<jobject> jwindow_android = window_android->GetJavaObject(); | 283 ScopedJavaLocalRef<jobject> jwindow_android = window_android->GetJavaObject(); |
| 280 | 284 |
| 281 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 285 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 282 DCHECK(!jwindow_android.is_null()); | 286 DCHECK(!jwindow_android.is_null()); |
| 283 | 287 |
| 284 JNIEnv* env = base::android::AttachCurrentThread(); | 288 JNIEnv* env = base::android::AttachCurrentThread(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 void DownloadController::StartContextMenuDownload( | 388 void DownloadController::StartContextMenuDownload( |
| 385 const ContextMenuParams& params, WebContents* web_contents, bool is_link, | 389 const ContextMenuParams& params, WebContents* web_contents, bool is_link, |
| 386 const std::string& extra_headers) { | 390 const std::string& extra_headers) { |
| 387 int process_id = web_contents->GetRenderProcessHost()->GetID(); | 391 int process_id = web_contents->GetRenderProcessHost()->GetID(); |
| 388 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 392 int routing_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| 389 AcquireFileAccessPermission( | 393 AcquireFileAccessPermission( |
| 390 web_contents, base::Bind(&CreateContextMenuDownload, process_id, | 394 web_contents, base::Bind(&CreateContextMenuDownload, process_id, |
| 391 routing_id, params, is_link, extra_headers)); | 395 routing_id, params, is_link, extra_headers)); |
| 392 } | 396 } |
| 393 | 397 |
| OLD | NEW |