OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef UI_SHELL_DIALOGS_ANDROID_SELECT_FILE_DIALOG_ANDROID_H_ | 5 #ifndef UI_SHELL_DIALOGS_ANDROID_SELECT_FILE_DIALOG_ANDROID_H_ |
6 #define UI_SHELL_DIALOGS_ANDROID_SELECT_FILE_DIALOG_ANDROID_H_ | 6 #define UI_SHELL_DIALOGS_ANDROID_SELECT_FILE_DIALOG_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "ui/shell_dialogs/select_file_dialog.h" | 12 #include "ui/shell_dialogs/select_file_dialog.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 | 15 |
16 class SelectFileDialogImpl : public ui::SelectFileDialog { | 16 class SelectFileDialogImpl : public SelectFileDialog { |
17 public: | 17 public: |
18 static SelectFileDialogImpl* Create( | 18 static SelectFileDialogImpl* Create(Listener* listener, |
19 Listener* listener, | 19 SelectFilePolicy* policy); |
20 ui::SelectFilePolicy* policy); | |
21 | 20 |
22 void OnFileSelected(JNIEnv* env, jobject java_object, jstring filepath); | 21 void OnFileSelected(JNIEnv* env, jobject java_object, jstring filepath); |
23 void OnFileNotSelected(JNIEnv* env, jobject java_object); | 22 void OnFileNotSelected(JNIEnv* env, jobject java_object); |
24 | 23 |
25 // From SelectFileDialog | 24 // From SelectFileDialog |
26 virtual bool IsRunning(gfx::NativeWindow) const OVERRIDE; | 25 virtual bool IsRunning(gfx::NativeWindow) const OVERRIDE; |
27 virtual void ListenerDestroyed() OVERRIDE; | 26 virtual void ListenerDestroyed() OVERRIDE; |
28 | 27 |
29 // Called when it is time to display the file picker. | 28 // Called when it is time to display the file picker. |
30 // params is expected to be a Vector<string16> with accept_types first and | 29 // params is expected to be a vector<string16> with accept_types first and |
31 // the capture value as the last element of the vector. | 30 // the capture value as the last element of the vector. |
32 virtual void SelectFileImpl( | 31 virtual void SelectFileImpl( |
33 ui::SelectFileDialog::Type type, | 32 SelectFileDialog::Type type, |
34 const string16& title, | 33 const base::string16& title, |
35 const base::FilePath& default_path, | 34 const base::FilePath& default_path, |
36 const ui::SelectFileDialog::FileTypeInfo* file_types, | 35 const SelectFileDialog::FileTypeInfo* file_types, |
37 int file_type_index, | 36 int file_type_index, |
38 const std::string& default_extension, | 37 const std::string& default_extension, |
39 gfx::NativeWindow owning_window, | 38 gfx::NativeWindow owning_window, |
40 void* params) OVERRIDE; | 39 void* params) OVERRIDE; |
41 | 40 |
42 static bool RegisterSelectFileDialog(JNIEnv* env); | 41 static bool RegisterSelectFileDialog(JNIEnv* env); |
43 | 42 |
44 protected: | 43 protected: |
45 virtual ~SelectFileDialogImpl(); | 44 virtual ~SelectFileDialogImpl(); |
46 | 45 |
47 private: | 46 private: |
48 SelectFileDialogImpl(Listener* listener, ui::SelectFilePolicy* policy); | 47 SelectFileDialogImpl(Listener* listener, SelectFilePolicy* policy); |
49 | 48 |
50 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE; | 49 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE; |
51 | 50 |
52 base::android::ScopedJavaGlobalRef<jobject> java_object_; | 51 base::android::ScopedJavaGlobalRef<jobject> java_object_; |
53 | 52 |
54 // Stores the state whether select_file_dialog is running. | 53 // Stores the state whether select_file_dialog is running. |
55 bool is_running_; | 54 bool is_running_; |
56 | 55 |
57 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl); | 56 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl); |
58 }; | 57 }; |
59 | 58 |
60 SelectFileDialog* CreateAndroidSelectFileDialog( | 59 SelectFileDialog* CreateAndroidSelectFileDialog( |
61 SelectFileDialog::Listener* listener, | 60 SelectFileDialog::Listener* listener, |
62 SelectFilePolicy* policy); | 61 SelectFilePolicy* policy); |
63 | 62 |
64 } // namespace ui | 63 } // namespace ui |
65 | 64 |
66 #endif // UI_SHELL_DIALOGS_ANDROID_SELECT_FILE_DIALOG_ANDROID_H_ | 65 #endif // UI_SHELL_DIALOGS_ANDROID_SELECT_FILE_DIALOG_ANDROID_H_ |
67 | 66 |
OLD | NEW |