Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: chrome/browser/android/download/chrome_download_delegate.cc

Issue 2886403005: Remove chrome_download_delegate.cc (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/download/chrome_download_delegate.h"
6
7 #include <jni.h>
8
9 #include <string>
10 #include <type_traits>
11
12 #include "base/android/jni_android.h"
13 #include "base/android/jni_string.h"
14 #include "base/android/scoped_java_ref.h"
15 #include "base/bind.h"
16 #include "base/callback.h"
17 #include "base/files/file_path.h"
18 #include "chrome/browser/android/download/download_controller_base.h"
19 #include "chrome/browser/android/tab_android.h"
20 #include "chrome/browser/infobars/infobar_service.h"
21 #include "chrome/common/safe_browsing/file_type_policies.h"
22 #include "chrome/grit/generated_resources.h"
23 #include "jni/ChromeDownloadDelegate_jni.h"
24 #include "ui/base/l10n/l10n_util.h"
25
26 using base::android::ConvertUTF8ToJavaString;
27 using base::android::JavaParamRef;
28 using base::android::ScopedJavaLocalRef;
29 using content::WebContents;
30
31 // Gets the download warning text for the given file name.
32 static ScopedJavaLocalRef<jstring> GetDownloadWarningText(
33 JNIEnv* env,
34 const JavaParamRef<jclass>& clazz,
35 const JavaParamRef<jstring>& filename) {
36 return base::android::ConvertUTF8ToJavaString(
37 env, l10n_util::GetStringFUTF8(
38 IDS_PROMPT_DANGEROUS_DOWNLOAD,
39 base::android::ConvertJavaStringToUTF16(env, filename)));
40 }
41
42 // static
43 bool ChromeDownloadDelegate::EnqueueDownloadManagerRequest(
44 jobject chrome_download_delegate,
45 bool overwrite,
46 jobject download_info) {
47 JNIEnv* env = base::android::AttachCurrentThread();
48
49 return Java_ChromeDownloadDelegate_enqueueDownloadManagerRequestFromNative(
50 env, chrome_download_delegate, overwrite, download_info);
51 }
52
53 ChromeDownloadDelegate::ChromeDownloadDelegate(
54 WebContents* web_contents) {}
55
56 ChromeDownloadDelegate::~ChromeDownloadDelegate() {
57 JNIEnv* env = base::android::AttachCurrentThread();
58 env->DeleteGlobalRef(java_ref_);
59 }
60
61 void ChromeDownloadDelegate::SetJavaRef(JNIEnv* env, jobject jobj) {
62 java_ref_ = env->NewGlobalRef(jobj);
63 }
64
65 void Init(JNIEnv* env,
66 const JavaParamRef<jobject>& obj,
67 const JavaParamRef<jobject>& jweb_contents) {
68 auto* web_contents = WebContents::FromJavaWebContents(jweb_contents);
69 ChromeDownloadDelegate::CreateForWebContents(web_contents);
70 ChromeDownloadDelegate::FromWebContents(web_contents)->SetJavaRef(env, obj);
71 }
72
73 bool RegisterChromeDownloadDelegate(JNIEnv* env) {
74 return RegisterNativesImpl(env);
75 }
76
77 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeDownloadDelegate);
OLDNEW
« no previous file with comments | « chrome/browser/android/download/chrome_download_delegate.h ('k') | chrome/browser/android/download/download_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698