OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "select_file_dialog_android.h" | 5 #include "select_file_dialog_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ui::SelectFileDialog::Type type, | 55 ui::SelectFileDialog::Type type, |
56 const string16& title, | 56 const string16& title, |
57 const base::FilePath& default_path, | 57 const base::FilePath& default_path, |
58 const SelectFileDialog::FileTypeInfo* file_types, | 58 const SelectFileDialog::FileTypeInfo* file_types, |
59 int file_type_index, | 59 int file_type_index, |
60 const std::string& default_extension, | 60 const std::string& default_extension, |
61 gfx::NativeWindow owning_window, | 61 gfx::NativeWindow owning_window, |
62 void* params) { | 62 void* params) { |
63 JNIEnv* env = base::android::AttachCurrentThread(); | 63 JNIEnv* env = base::android::AttachCurrentThread(); |
64 | 64 |
65 std::vector<string16> accept_types = | 65 ScopedJavaLocalRef<jstring> capture_value; |
66 *(reinterpret_cast<std::vector<string16>*>(params)); | 66 std::vector<string16> accept_types; |
| 67 if (params) { |
| 68 accept_types = *(reinterpret_cast<std::vector<string16>*>(params)); |
67 | 69 |
68 // The last string in params is expected to be the string with capture value. | 70 // The last string in params is expected to be the string |
69 ScopedJavaLocalRef<jstring> capture_value = | 71 // with capture value. |
70 base::android::ConvertUTF16ToJavaString(env, | 72 capture_value = base::android::ConvertUTF16ToJavaString(env, |
71 StringToLowerASCII(accept_types.back())); | 73 StringToLowerASCII(accept_types.back())); |
72 base::android::CheckException(env); | 74 base::android::CheckException(env); |
73 accept_types.pop_back(); | 75 accept_types.pop_back(); |
| 76 } else { |
| 77 capture_value = base::android::ConvertUTF8ToJavaString(env, "filesystem"); |
| 78 } |
74 | 79 |
75 // The rest params elements are expected to be accept_types. | 80 // The rest params elements are expected to be accept_types. |
76 ScopedJavaLocalRef<jobjectArray> accept_types_java = | 81 ScopedJavaLocalRef<jobjectArray> accept_types_java = |
77 base::android::ToJavaArrayOfStrings(env, accept_types); | 82 base::android::ToJavaArrayOfStrings(env, accept_types); |
78 | 83 |
79 Java_SelectFileDialog_selectFile(env, java_object_.obj(), | 84 Java_SelectFileDialog_selectFile(env, java_object_.obj(), |
80 accept_types_java.obj(), | 85 accept_types_java.obj(), |
81 capture_value.obj(), | 86 capture_value.obj(), |
82 owning_window->GetJavaObject().obj()); | 87 owning_window->GetJavaObject().obj()); |
83 is_running_ = true; | 88 is_running_ = true; |
(...skipping 20 matching lines...) Expand all Loading... |
104 return false; | 109 return false; |
105 } | 110 } |
106 | 111 |
107 SelectFileDialog* CreateAndroidSelectFileDialog( | 112 SelectFileDialog* CreateAndroidSelectFileDialog( |
108 SelectFileDialog::Listener* listener, | 113 SelectFileDialog::Listener* listener, |
109 SelectFilePolicy* policy) { | 114 SelectFilePolicy* policy) { |
110 return SelectFileDialogImpl::Create(listener, policy); | 115 return SelectFileDialogImpl::Create(listener, policy); |
111 } | 116 } |
112 | 117 |
113 } // namespace ui | 118 } // namespace ui |
OLD | NEW |