| 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 <string> | 9 #include <string> |
| 10 #include <type_traits> | 10 #include <type_traits> |
| 11 | 11 |
| 12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
| 14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "chrome/browser/android/download/android_download_manager_overwrite_inf
obar_delegate.h" | 18 #include "chrome/browser/android/download/android_download_manager_overwrite_inf
obar_delegate.h" |
| 19 #include "chrome/browser/android/download/download_controller_base.h" | 19 #include "chrome/browser/android/download/download_controller_base.h" |
| 20 #include "chrome/browser/android/tab_android.h" | 20 #include "chrome/browser/android/tab_android.h" |
| 21 #include "chrome/browser/infobars/infobar_service.h" | 21 #include "chrome/browser/infobars/infobar_service.h" |
| 22 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" | 22 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" |
| 23 #include "chrome/common/safe_browsing/file_type_policies.h" | 23 #include "chrome/common/safe_browsing/file_type_policies.h" |
| 24 #include "chrome/grit/chromium_strings.h" | 24 #include "chrome/grit/chromium_strings.h" |
| 25 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
| 26 #include "jni/ChromeDownloadDelegate_jni.h" | 26 #include "jni/ChromeDownloadDelegate_jni.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 | 28 |
| 29 using base::android::ConvertUTF8ToJavaString; | 29 using base::android::ConvertUTF8ToJavaString; |
| 30 using base::android::JavaParamRef; |
| 30 using base::android::ScopedJavaLocalRef; | 31 using base::android::ScopedJavaLocalRef; |
| 31 using content::WebContents; | 32 using content::WebContents; |
| 32 | 33 |
| 33 // Gets the download warning text for the given file name. | 34 // Gets the download warning text for the given file name. |
| 34 static ScopedJavaLocalRef<jstring> GetDownloadWarningText( | 35 static ScopedJavaLocalRef<jstring> GetDownloadWarningText( |
| 35 JNIEnv* env, | 36 JNIEnv* env, |
| 36 const JavaParamRef<jclass>& clazz, | 37 const JavaParamRef<jclass>& clazz, |
| 37 const JavaParamRef<jstring>& filename) { | 38 const JavaParamRef<jstring>& filename) { |
| 38 return base::android::ConvertUTF8ToJavaString( | 39 return base::android::ConvertUTF8ToJavaString( |
| 39 env, l10n_util::GetStringFUTF8( | 40 env, l10n_util::GetStringFUTF8( |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 auto* web_contents = WebContents::FromJavaWebContents(jweb_contents); | 210 auto* web_contents = WebContents::FromJavaWebContents(jweb_contents); |
| 210 ChromeDownloadDelegate::CreateForWebContents(web_contents); | 211 ChromeDownloadDelegate::CreateForWebContents(web_contents); |
| 211 ChromeDownloadDelegate::FromWebContents(web_contents)->SetJavaRef(env, obj); | 212 ChromeDownloadDelegate::FromWebContents(web_contents)->SetJavaRef(env, obj); |
| 212 } | 213 } |
| 213 | 214 |
| 214 bool RegisterChromeDownloadDelegate(JNIEnv* env) { | 215 bool RegisterChromeDownloadDelegate(JNIEnv* env) { |
| 215 return RegisterNativesImpl(env); | 216 return RegisterNativesImpl(env); |
| 216 } | 217 } |
| 217 | 218 |
| 218 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeDownloadDelegate); | 219 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeDownloadDelegate); |
| OLD | NEW |