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