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

Unified Diff: ui/shell_dialogs/select_file_dialog_android.cc

Issue 580043002: [Android] Prompt with infobar on filename conflict (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed ted's comments and added dismiss listener Created 6 years, 3 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: ui/shell_dialogs/select_file_dialog_android.cc
diff --git a/ui/shell_dialogs/select_file_dialog_android.cc b/ui/shell_dialogs/select_file_dialog_android.cc
index 86c4b18d077dfd58d63be0bceebd3e8ed696c745..5873039656dd33a8a69dc5074dfdcb747492203c 100644
--- a/ui/shell_dialogs/select_file_dialog_android.cc
+++ b/ui/shell_dialogs/select_file_dialog_android.cc
@@ -8,15 +8,18 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
+#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "jni/SelectFileDialog_jni.h"
#include "ui/base/android/window_android.h"
#include "ui/shell_dialogs/selected_file_info.h"
using base::android::ConvertJavaStringToUTF8;
+using base::android::ConvertUTF8ToJavaString;
namespace ui {
@@ -91,6 +94,25 @@ void SelectFileDialogImpl::ListenerDestroyed() {
listener_ = NULL;
}
+ScopedJavaLocalRef<jstring> SelectFileDialogImpl::GetUniqueFilePath(
+ JNIEnv* env, jobject java_object, jstring path) {
+ base::FilePath file_path(ConvertJavaStringToUTF8(env, path));
+
+ ScopedJavaLocalRef<jstring> result;
+
+ // TODO(changwan): use GetUniquePath() instead once
+ // https://codereview.chromium.org/493363003/ lands.
+ int uniquifier = base::GetUniquePathNumber(file_path,
+ base::FilePath::StringType());
+ if (uniquifier > 0) {
+ file_path = file_path.InsertBeforeExtensionASCII(
+ base::StringPrintf(" (%d)", uniquifier));
+ result = ConvertUTF8ToJavaString(env, file_path.value());
+ return ScopedJavaLocalRef<jstring>(result);
+ }
+ return result;
+}
+
void SelectFileDialogImpl::SelectFileImpl(
SelectFileDialog::Type type,
const base::string16& title,
@@ -102,6 +124,15 @@ void SelectFileDialogImpl::SelectFileImpl(
void* params) {
JNIEnv* env = base::android::AttachCurrentThread();
+ if (type == SelectFileDialog::SELECT_SAVEAS_FILE) {
+ ScopedJavaLocalRef<jstring> jdefault_path =
Ted C 2014/09/19 22:31:40 this block is indented 2 too many
Changwan Ryu 2014/09/22 14:02:37 Done.
Changwan Ryu 2014/09/22 14:02:37 Done.
+ ConvertUTF8ToJavaString(env, default_path.value());
+ Java_SelectFileDialog_showOverwriteDialog(
+ env, java_object_.obj(), jdefault_path.obj(),
+ owning_window->GetJavaObject().obj());
+ return;
+ }
+
// The first element in the pair is a list of accepted types, the second
// indicates whether the device's capture capabilities should be used.
typedef std::pair<std::vector<base::string16>, bool> AcceptTypes;

Powered by Google App Engine
This is Rietveld 408576698