| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 void SelectFileDialogImpl::SelectFileImpl( | 94 void SelectFileDialogImpl::SelectFileImpl( |
| 95 SelectFileDialog::Type type, | 95 SelectFileDialog::Type type, |
| 96 const base::string16& title, | 96 const base::string16& title, |
| 97 const base::FilePath& default_path, | 97 const base::FilePath& default_path, |
| 98 const SelectFileDialog::FileTypeInfo* file_types, | 98 const SelectFileDialog::FileTypeInfo* file_types, |
| 99 int file_type_index, | 99 int file_type_index, |
| 100 const std::string& default_extension, | 100 const std::string& default_extension, |
| 101 gfx::NativeWindow owning_window, | 101 gfx::NativeWindow owning_window, |
| 102 void* params) { | 102 void* params) { |
| 103 assert(false); |
| 104 WindowAndroid* a_owning_window = (WindowAndroid*) owning_window; |
| 105 |
| 103 JNIEnv* env = base::android::AttachCurrentThread(); | 106 JNIEnv* env = base::android::AttachCurrentThread(); |
| 104 | 107 |
| 105 // The first element in the pair is a list of accepted types, the second | 108 // The first element in the pair is a list of accepted types, the second |
| 106 // indicates whether the device's capture capabilities should be used. | 109 // indicates whether the device's capture capabilities should be used. |
| 107 typedef std::pair<std::vector<base::string16>, bool> AcceptTypes; | 110 typedef std::pair<std::vector<base::string16>, bool> AcceptTypes; |
| 108 AcceptTypes accept_types = std::make_pair(std::vector<base::string16>(), | 111 AcceptTypes accept_types = std::make_pair(std::vector<base::string16>(), |
| 109 false); | 112 false); |
| 110 | 113 |
| 111 if (params) | 114 if (params) |
| 112 accept_types = *(reinterpret_cast<AcceptTypes*>(params)); | 115 accept_types = *(reinterpret_cast<AcceptTypes*>(params)); |
| 113 | 116 |
| 114 ScopedJavaLocalRef<jobjectArray> accept_types_java = | 117 ScopedJavaLocalRef<jobjectArray> accept_types_java = |
| 115 base::android::ToJavaArrayOfStrings(env, accept_types.first); | 118 base::android::ToJavaArrayOfStrings(env, accept_types.first); |
| 116 | 119 |
| 117 bool accept_multiple_files = SelectFileDialog::SELECT_OPEN_MULTI_FILE == type; | 120 bool accept_multiple_files = SelectFileDialog::SELECT_OPEN_MULTI_FILE == type; |
| 118 | 121 |
| 119 Java_SelectFileDialog_selectFile(env, java_object_.obj(), | 122 Java_SelectFileDialog_selectFile(env, java_object_.obj(), |
| 120 accept_types_java.obj(), | 123 accept_types_java.obj(), |
| 121 accept_types.second, | 124 accept_types.second, |
| 122 accept_multiple_files, | 125 accept_multiple_files, |
| 123 owning_window->GetJavaObject().obj()); | 126 a_owning_window->GetJavaObject().obj()); |
| 124 } | 127 } |
| 125 | 128 |
| 126 bool SelectFileDialogImpl::RegisterSelectFileDialog(JNIEnv* env) { | 129 bool SelectFileDialogImpl::RegisterSelectFileDialog(JNIEnv* env) { |
| 127 return RegisterNativesImpl(env); | 130 return RegisterNativesImpl(env); |
| 128 } | 131 } |
| 129 | 132 |
| 130 SelectFileDialogImpl::~SelectFileDialogImpl() { | 133 SelectFileDialogImpl::~SelectFileDialogImpl() { |
| 131 } | 134 } |
| 132 | 135 |
| 133 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener, | 136 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener, |
| 134 SelectFilePolicy* policy) | 137 SelectFilePolicy* policy) |
| 135 : SelectFileDialog(listener, policy) { | 138 : SelectFileDialog(listener, policy) { |
| 136 JNIEnv* env = base::android::AttachCurrentThread(); | 139 JNIEnv* env = base::android::AttachCurrentThread(); |
| 137 java_object_.Reset( | 140 java_object_.Reset( |
| 138 Java_SelectFileDialog_create(env, reinterpret_cast<intptr_t>(this))); | 141 Java_SelectFileDialog_create(env, reinterpret_cast<intptr_t>(this))); |
| 139 } | 142 } |
| 140 | 143 |
| 141 bool SelectFileDialogImpl::HasMultipleFileTypeChoicesImpl() { | 144 bool SelectFileDialogImpl::HasMultipleFileTypeChoicesImpl() { |
| 142 NOTIMPLEMENTED(); | 145 NOTIMPLEMENTED(); |
| 143 return false; | 146 return false; |
| 144 } | 147 } |
| 145 | 148 |
| 146 SelectFileDialog* CreateAndroidSelectFileDialog( | 149 SelectFileDialog* CreateAndroidSelectFileDialog( |
| 147 SelectFileDialog::Listener* listener, | 150 SelectFileDialog::Listener* listener, |
| 148 SelectFilePolicy* policy) { | 151 SelectFilePolicy* policy) { |
| 149 return SelectFileDialogImpl::Create(listener, policy); | 152 return SelectFileDialogImpl::Create(listener, policy); |
| 150 } | 153 } |
| 151 | 154 |
| 152 } // namespace ui | 155 } // namespace ui |
| OLD | NEW |