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 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "chrome/browser/android/download/android_download_manager_overwrite_inf
obar_delegate.h" | 16 #include "chrome/browser/android/download/android_download_manager_overwrite_inf
obar_delegate.h" |
17 #include "chrome/browser/android/tab_android.h" | 17 #include "chrome/browser/android/tab_android.h" |
18 #include "chrome/browser/download/download_extensions.h" | 18 #include "chrome/browser/download/download_extensions.h" |
19 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
20 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
21 #include "content/public/browser/android/download_controller_android.h" | 21 #include "content/public/browser/android/download_controller_android.h" |
22 #include "jni/ChromeDownloadDelegate_jni.h" | 22 #include "jni/ChromeDownloadDelegate_jni.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 | 24 |
25 // Gets the download warning text for the given file name. | 25 // Gets the download warning text for the given file name. |
26 static jstring GetDownloadWarningText( | 26 static ScopedJavaLocalRef<jstring> GetDownloadWarningText(JNIEnv* env, |
27 JNIEnv* env, jclass clazz, jstring filename) { | 27 jclass clazz, |
| 28 jstring filename) { |
28 return base::android::ConvertUTF8ToJavaString( | 29 return base::android::ConvertUTF8ToJavaString( |
29 env, l10n_util::GetStringFUTF8( | 30 env, l10n_util::GetStringFUTF8( |
30 IDS_PROMPT_DANGEROUS_DOWNLOAD, | 31 IDS_PROMPT_DANGEROUS_DOWNLOAD, |
31 base::android::ConvertJavaStringToUTF16(env, filename))).Release(); | 32 base::android::ConvertJavaStringToUTF16(env, filename))); |
32 } | 33 } |
33 | 34 |
34 // Returns true if a file name is dangerous, or false otherwise. | 35 // Returns true if a file name is dangerous, or false otherwise. |
35 static jboolean IsDownloadDangerous( | 36 static jboolean IsDownloadDangerous( |
36 JNIEnv* env, jclass clazz, jstring filename) { | 37 JNIEnv* env, jclass clazz, jstring filename) { |
37 base::FilePath path(base::android::ConvertJavaStringToUTF8(env, filename)); | 38 base::FilePath path(base::android::ConvertJavaStringToUTF8(env, filename)); |
38 return download_util::GetFileDangerLevel(path) != | 39 return download_util::GetFileDangerLevel(path) != |
39 download_util::NOT_DANGEROUS; | 40 download_util::NOT_DANGEROUS; |
40 } | 41 } |
41 | 42 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 base::android::ConvertJavaStringToUTF8(env, jdir_full_path); | 78 base::android::ConvertJavaStringToUTF8(env, jdir_full_path); |
78 | 79 |
79 chrome::android::AndroidDownloadManagerOverwriteInfoBarDelegate::Create( | 80 chrome::android::AndroidDownloadManagerOverwriteInfoBarDelegate::Create( |
80 InfoBarService::FromWebContents(tab_android->web_contents()), file_name, | 81 InfoBarService::FromWebContents(tab_android->web_contents()), file_name, |
81 dir_name, dir_full_path, delegate, download_info); | 82 dir_name, dir_full_path, delegate, download_info); |
82 } | 83 } |
83 | 84 |
84 bool RegisterChromeDownloadDelegate(JNIEnv* env) { | 85 bool RegisterChromeDownloadDelegate(JNIEnv* env) { |
85 return RegisterNativesImpl(env); | 86 return RegisterNativesImpl(env); |
86 } | 87 } |
OLD | NEW |