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

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

Issue 1982723002: Use FileTypePolicies for download danger classifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use_policies
Patch Set: Fix bad rebase Created 4 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
« no previous file with comments | « no previous file | chrome/browser/download/chrome_download_manager_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "chrome/browser/android/download/android_download_manager_overwrite_inf obar_delegate.h" 19 #include "chrome/browser/android/download/android_download_manager_overwrite_inf obar_delegate.h"
20 #include "chrome/browser/android/tab_android.h" 20 #include "chrome/browser/android/tab_android.h"
21 #include "chrome/browser/download/download_extensions.h"
22 #include "chrome/browser/infobars/infobar_service.h" 21 #include "chrome/browser/infobars/infobar_service.h"
23 #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"
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 "content/public/browser/android/download_controller_android.h" 26 #include "content/public/browser/android/download_controller_android.h"
27 #include "jni/ChromeDownloadDelegate_jni.h" 27 #include "jni/ChromeDownloadDelegate_jni.h"
28 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
29 29
30 using content::DownloadControllerAndroid; 30 using content::DownloadControllerAndroid;
31 31
32 // Gets the download warning text for the given file name. 32 // Gets the download warning text for the given file name.
33 static ScopedJavaLocalRef<jstring> GetDownloadWarningText( 33 static ScopedJavaLocalRef<jstring> GetDownloadWarningText(
34 JNIEnv* env, 34 JNIEnv* env,
35 const JavaParamRef<jclass>& clazz, 35 const JavaParamRef<jclass>& clazz,
36 const JavaParamRef<jstring>& filename) { 36 const JavaParamRef<jstring>& filename) {
37 return base::android::ConvertUTF8ToJavaString( 37 return base::android::ConvertUTF8ToJavaString(
38 env, l10n_util::GetStringFUTF8( 38 env, l10n_util::GetStringFUTF8(
39 IDS_PROMPT_DANGEROUS_DOWNLOAD, 39 IDS_PROMPT_DANGEROUS_DOWNLOAD,
40 base::android::ConvertJavaStringToUTF16(env, filename))); 40 base::android::ConvertJavaStringToUTF16(env, filename)));
41 } 41 }
42 42
43 // Returns true if a file name is dangerous, or false otherwise. 43 // Returns true if a file name is dangerous, or false otherwise.
44 static jboolean IsDownloadDangerous(JNIEnv* env, 44 static jboolean IsDownloadDangerous(JNIEnv* env,
45 const JavaParamRef<jclass>& clazz, 45 const JavaParamRef<jclass>& clazz,
46 const JavaParamRef<jstring>& filename) { 46 const JavaParamRef<jstring>& filename) {
47 base::FilePath path(base::android::ConvertJavaStringToUTF8(env, filename)); 47 base::FilePath path(base::android::ConvertJavaStringToUTF8(env, filename));
48 return download_util::GetFileDangerLevel(path) != 48 return safe_browsing::FileTypePolicies::GetInstance()->GetFileDangerLevel(
49 download_util::NOT_DANGEROUS; 49 path) != safe_browsing::DownloadFileType::NOT_DANGEROUS;
50 } 50 }
51 51
52 // Called when a dangerous download is validated. 52 // Called when a dangerous download is validated.
53 static void DangerousDownloadValidated( 53 static void DangerousDownloadValidated(
54 JNIEnv* env, 54 JNIEnv* env,
55 const JavaParamRef<jclass>& clazz, 55 const JavaParamRef<jclass>& clazz,
56 const JavaParamRef<jobject>& tab, 56 const JavaParamRef<jobject>& tab,
57 const JavaParamRef<jstring>& jdownload_guid, 57 const JavaParamRef<jstring>& jdownload_guid,
58 jboolean accept) { 58 jboolean accept) {
59 std::string download_guid = 59 std::string download_guid =
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 PermissionUpdateInfoBarDelegate::Create( 124 PermissionUpdateInfoBarDelegate::Create(
125 tab_android->web_contents(), 125 tab_android->web_contents(),
126 permissions, 126 permissions,
127 IDS_MISSING_STORAGE_PERMISSION_DOWNLOAD_EDUCATION_TEXT, 127 IDS_MISSING_STORAGE_PERMISSION_DOWNLOAD_EDUCATION_TEXT,
128 *cb); 128 *cb);
129 } 129 }
130 130
131 bool RegisterChromeDownloadDelegate(JNIEnv* env) { 131 bool RegisterChromeDownloadDelegate(JNIEnv* env) {
132 return RegisterNativesImpl(env); 132 return RegisterNativesImpl(env);
133 } 133 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/chrome_download_manager_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698