| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 BrowserThread::UI, FROM_HERE, base::Bind(cb, true)); | 210 BrowserThread::UI, FROM_HERE, base::Bind(cb, true)); |
| 211 return; | 211 return; |
| 212 } | 212 } |
| 213 // Make copy on the heap so we can pass the pointer through JNI. | 213 // Make copy on the heap so we can pass the pointer through JNI. |
| 214 intptr_t callback_id = reinterpret_cast<intptr_t>( | 214 intptr_t callback_id = reinterpret_cast<intptr_t>( |
| 215 new DownloadControllerBase::AcquireFileAccessPermissionCallback(cb)); | 215 new DownloadControllerBase::AcquireFileAccessPermissionCallback(cb)); |
| 216 ChromeDownloadDelegate::FromWebContents(web_contents)-> | 216 ChromeDownloadDelegate::FromWebContents(web_contents)-> |
| 217 RequestFileAccess(callback_id); | 217 RequestFileAccess(callback_id); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void DownloadController::SetDefaultDownloadFileName( | |
| 221 const std::string& file_name) { | |
| 222 default_file_name_ = file_name; | |
| 223 } | |
| 224 | |
| 225 bool DownloadController::HasFileAccessPermission( | 220 bool DownloadController::HasFileAccessPermission( |
| 226 ui::WindowAndroid* window_android) { | 221 ui::WindowAndroid* window_android) { |
| 227 ScopedJavaLocalRef<jobject> jwindow_android = window_android->GetJavaObject(); | 222 ScopedJavaLocalRef<jobject> jwindow_android = window_android->GetJavaObject(); |
| 228 | 223 |
| 229 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 224 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 230 DCHECK(!jwindow_android.is_null()); | 225 DCHECK(!jwindow_android.is_null()); |
| 231 | 226 |
| 232 JNIEnv* env = base::android::AttachCurrentThread(); | 227 JNIEnv* env = base::android::AttachCurrentThread(); |
| 233 return Java_DownloadController_hasFileAccess( | 228 return Java_DownloadController_hasFileAccess( |
| 234 env, GetJavaObject()->Controller(env), jwindow_android); | 229 env, GetJavaObject()->Controller(env), jwindow_android); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 if (!item) | 362 if (!item) |
| 368 return; | 363 return; |
| 369 if (accept) { | 364 if (accept) { |
| 370 item->ValidateDangerousDownload(); | 365 item->ValidateDangerousDownload(); |
| 371 } else { | 366 } else { |
| 372 DownloadController::RecordDownloadCancelReason( | 367 DownloadController::RecordDownloadCancelReason( |
| 373 DownloadController::CANCEL_REASON_DANGEROUS_DOWNLOAD_INFOBAR_DISMISSED); | 368 DownloadController::CANCEL_REASON_DANGEROUS_DOWNLOAD_INFOBAR_DISMISSED); |
| 374 item->Remove(); | 369 item->Remove(); |
| 375 } | 370 } |
| 376 } | 371 } |
| OLD | NEW |