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

Unified Diff: chrome/browser/android/download/chrome_download_delegate.cc

Issue 580043002: [Android] Prompt with infobar on filename conflict (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed function order according to headers Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/download/chrome_download_delegate.cc
diff --git a/chrome/browser/android/download/chrome_download_delegate.cc b/chrome/browser/android/download/chrome_download_delegate.cc
index 96382979204d6b734040d2aa7980d67d80ed6d4c..6f731f5a107660d75aa4e83750c52de9cfaa4df0 100644
--- a/chrome/browser/android/download/chrome_download_delegate.cc
+++ b/chrome/browser/android/download/chrome_download_delegate.cc
@@ -9,18 +9,19 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
+#include "base/bind.h"
+#include "base/callback.h"
#include "base/files/file_path.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/android/download/android_download_manager_overwrite_infobar_delegate.h"
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/download/download_extensions.h"
+#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/android/download_controller_android.h"
#include "jni/ChromeDownloadDelegate_jni.h"
#include "ui/base/l10n/l10n_util.h"
-bool RegisterChromeDownloadDeleagte(JNIEnv* env) {
- return RegisterNativesImpl(env);
-}
-
// Gets the download warning text for the given file name.
static jstring GetDownloadWarningText(
JNIEnv* env, jclass clazz, jstring filename) {
@@ -45,3 +46,41 @@ static void DangerousDownloadValidated(
content::DownloadControllerAndroid::Get()->DangerousDownloadValidated(
tab_android->web_contents(), download_id, accept);
}
+
+// static
+void ChromeDownloadDelegate::EnqueueDownloadManagerRequest(
+ jobject chrome_download_delegate,
+ bool overwrite,
+ jobject download_info) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+
+ Java_ChromeDownloadDelegate_enqueueDownloadManagerRequestFromNative(
+ env, chrome_download_delegate, overwrite, download_info);
+}
+
+// Called when we need to interrupt download and ask users whether to overwrite
+// an existing file.
+static void LaunchDownloadOverwriteInfoBar(JNIEnv* env,
+ jclass clazz,
+ jobject delegate,
+ jobject tab,
+ jobject download_info,
+ jstring jfile_name,
+ jstring jdir_name,
+ jstring jdir_full_path) {
+ TabAndroid* tab_android = TabAndroid::GetNativeTab(env, tab);
+
+ std::string file_name =
+ base::android::ConvertJavaStringToUTF8(env, jfile_name);
+ std::string dir_name = base::android::ConvertJavaStringToUTF8(env, jdir_name);
+ std::string dir_full_path =
+ base::android::ConvertJavaStringToUTF8(env, jdir_full_path);
+
+ chrome::android::AndroidDownloadManagerOverwriteInfoBarDelegate::Create(
+ InfoBarService::FromWebContents(tab_android->web_contents()), file_name,
+ dir_name, dir_full_path, delegate, download_info);
+}
+
+bool RegisterChromeDownloadDelegate(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}

Powered by Google App Engine
This is Rietveld 408576698