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