| 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_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 SelectFileDialogImpl* SelectFileDialogImpl::Create(Listener* listener, | 21 SelectFileDialogImpl* SelectFileDialogImpl::Create(Listener* listener, |
| 22 ui::SelectFilePolicy* policy) { | 22 ui::SelectFilePolicy* policy) { |
| 23 return new SelectFileDialogImpl(listener, policy); | 23 return new SelectFileDialogImpl(listener, policy); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void SelectFileDialogImpl::OnFileSelected(JNIEnv* env, | 26 void SelectFileDialogImpl::OnFileSelected(JNIEnv* env, |
| 27 jobject java_object, | 27 jobject java_object, |
| 28 jstring filepath) { | 28 jstring filepath) { |
| 29 if (listener_) { | 29 if (listener_) { |
| 30 std::string path = base::android::ConvertJavaStringToUTF8(env, filepath); | 30 std::string path = base::android::ConvertJavaStringToUTF8(env, filepath); |
| 31 listener_->FileSelected(FilePath(path), 0, NULL); | 31 listener_->FileSelected(base::FilePath(path), 0, NULL); |
| 32 } | 32 } |
| 33 | 33 |
| 34 is_running_ = false; | 34 is_running_ = false; |
| 35 } | 35 } |
| 36 | 36 |
| 37 void SelectFileDialogImpl::OnFileNotSelected( | 37 void SelectFileDialogImpl::OnFileNotSelected( |
| 38 JNIEnv* env, | 38 JNIEnv* env, |
| 39 jobject java_object) { | 39 jobject java_object) { |
| 40 if (listener_) | 40 if (listener_) |
| 41 listener_->FileSelectionCanceled(NULL); | 41 listener_->FileSelectionCanceled(NULL); |
| 42 | 42 |
| 43 is_running_ = false; | 43 is_running_ = false; |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow) const { | 46 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow) const { |
| 47 return is_running_; | 47 return is_running_; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void SelectFileDialogImpl::ListenerDestroyed() { | 50 void SelectFileDialogImpl::ListenerDestroyed() { |
| 51 listener_ = NULL; | 51 listener_ = NULL; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void SelectFileDialogImpl::SelectFileImpl( | 54 void SelectFileDialogImpl::SelectFileImpl( |
| 55 ui::SelectFileDialog::Type type, | 55 ui::SelectFileDialog::Type type, |
| 56 const string16& title, | 56 const string16& title, |
| 57 const 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 std::vector<string16> accept_types = |
| 66 *(reinterpret_cast<std::vector<string16>*>(params)); | 66 *(reinterpret_cast<std::vector<string16>*>(params)); |
| 67 | 67 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 return false; | 104 return false; |
| 105 } | 105 } |
| 106 | 106 |
| 107 SelectFileDialog* CreateAndroidSelectFileDialog( | 107 SelectFileDialog* CreateAndroidSelectFileDialog( |
| 108 SelectFileDialog::Listener* listener, | 108 SelectFileDialog::Listener* listener, |
| 109 SelectFilePolicy* policy) { | 109 SelectFilePolicy* policy) { |
| 110 return SelectFileDialogImpl::Create(listener, policy); | 110 return SelectFileDialogImpl::Create(listener, policy); |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace ui | 113 } // namespace ui |
| OLD | NEW |