| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chrome_download_delegate.h" | 5 #include "chrome/browser/android/download/chrome_download_delegate.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // Returns true if a file name is dangerous, or false otherwise. | 41 // Returns true if a file name is dangerous, or false otherwise. |
| 42 static jboolean IsDownloadDangerous(JNIEnv* env, | 42 static jboolean IsDownloadDangerous(JNIEnv* env, |
| 43 const JavaParamRef<jclass>& clazz, | 43 const JavaParamRef<jclass>& clazz, |
| 44 const JavaParamRef<jstring>& filename) { | 44 const JavaParamRef<jstring>& filename) { |
| 45 base::FilePath path(base::android::ConvertJavaStringToUTF8(env, filename)); | 45 base::FilePath path(base::android::ConvertJavaStringToUTF8(env, filename)); |
| 46 return download_util::GetFileDangerLevel(path) != | 46 return download_util::GetFileDangerLevel(path) != |
| 47 download_util::NOT_DANGEROUS; | 47 download_util::NOT_DANGEROUS; |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Called when a dangerous download is validated. | 50 // Called when a dangerous download is validated. |
| 51 static void DangerousDownloadValidated(JNIEnv* env, | 51 static void DangerousDownloadValidated( |
| 52 const JavaParamRef<jclass>& clazz, | 52 JNIEnv* env, |
| 53 const JavaParamRef<jobject>& tab, | 53 const JavaParamRef<jclass>& clazz, |
| 54 jint download_id, | 54 const JavaParamRef<jobject>& tab, |
| 55 jboolean accept) { | 55 const JavaParamRef<jstring>& jdownload_guid, |
| 56 jboolean accept) { |
| 57 std::string download_guid = |
| 58 base::android::ConvertJavaStringToUTF8(env, jdownload_guid); |
| 56 TabAndroid* tab_android = TabAndroid::GetNativeTab(env, tab); | 59 TabAndroid* tab_android = TabAndroid::GetNativeTab(env, tab); |
| 57 DownloadControllerAndroid::Get()->DangerousDownloadValidated( | 60 DownloadControllerAndroid::Get()->DangerousDownloadValidated( |
| 58 tab_android->web_contents(), download_id, accept); | 61 tab_android->web_contents(), download_guid, accept); |
| 59 } | 62 } |
| 60 | 63 |
| 61 // static | 64 // static |
| 62 bool ChromeDownloadDelegate::EnqueueDownloadManagerRequest( | 65 bool ChromeDownloadDelegate::EnqueueDownloadManagerRequest( |
| 63 jobject chrome_download_delegate, | 66 jobject chrome_download_delegate, |
| 64 bool overwrite, | 67 bool overwrite, |
| 65 jobject download_info) { | 68 jobject download_info) { |
| 66 JNIEnv* env = base::android::AttachCurrentThread(); | 69 JNIEnv* env = base::android::AttachCurrentThread(); |
| 67 | 70 |
| 68 return Java_ChromeDownloadDelegate_enqueueDownloadManagerRequestFromNative( | 71 return Java_ChromeDownloadDelegate_enqueueDownloadManagerRequestFromNative( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 PermissionUpdateInfoBarDelegate::Create( | 119 PermissionUpdateInfoBarDelegate::Create( |
| 117 tab_android->web_contents(), | 120 tab_android->web_contents(), |
| 118 permissions, | 121 permissions, |
| 119 IDS_MISSING_STORAGE_PERMISSION_DOWNLOAD_EDUCATION_TEXT, | 122 IDS_MISSING_STORAGE_PERMISSION_DOWNLOAD_EDUCATION_TEXT, |
| 120 *cb); | 123 *cb); |
| 121 } | 124 } |
| 122 | 125 |
| 123 bool RegisterChromeDownloadDelegate(JNIEnv* env) { | 126 bool RegisterChromeDownloadDelegate(JNIEnv* env) { |
| 124 return RegisterNativesImpl(env); | 127 return RegisterNativesImpl(env); |
| 125 } | 128 } |
| OLD | NEW |