1 // Copyright (c) 2014 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.
5 // This file implements select dialog functionality using webview.
7 #ifndef UI_SHELL_DIALOGS_WEBUI_SELECT_FILE_DIALOG_IMPL_H_
8 #define UI_SHELL_DIALOGS_WEBUI_SELECT_FILE_DIALOG_IMPL_H_
12 #include "base/compiler_specific.h"
13 #include "base/nix/xdg_util.h"
14 #include "ui/shell_dialogs/select_file_dialog.h"
18 class SelectFileDialogImplWebUI : public SelectFileDialog {
20 // Main factory method which returns correct type.
21 static ui::SelectFileDialog* Create(Listener* listener,
22 ui::SelectFilePolicy* policy);
23 // BaseShellDialog implementation.
24 bool IsRunning(gfx::NativeWindow parent_window) const override;
25 void ListenerDestroyed() override;
28 explicit SelectFileDialogImplWebUI(Listener* listener,
29 ui::SelectFilePolicy* policy);
30 virtual ~SelectFileDialogImplWebUI();
32 // SelectFileDialog implementation.
33 // |params| is user data we pass back via the Listener interface.
34 void SelectFileImpl(Type type,
35 const base::string16& title,
36 const base::FilePath& default_path,
37 const FileTypeInfo* file_types,
39 const base::FilePath::StringType& default_extension,
40 gfx::NativeWindow owning_window,
41 void* params) override;
42 bool HasMultipleFileTypeChoicesImpl() override;
44 // Wrapper for base::DirectoryExists() that allow access on the UI
45 // thread. Use this only in the file dialog functions, where it's ok
46 // because the file dialog has to do many stats anyway. One more won't
47 // hurt too badly and it's likely already cached.
48 bool CallDirectoryExistsOnUIThread(const base::FilePath& path);
51 FileTypeInfo file_types_;
53 // The index of the default selected file filter.
54 // Note: This starts from 1, not 0.
55 size_t file_type_index_;
57 // The type of dialog we are showing the user.
60 // These two variables track where the user last saved a file or opened a
61 // file so that we can display future dialogs with the same starting path.
62 static base::FilePath* last_saved_path_;
63 static base::FilePath* last_opened_path_;
66 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImplWebUI);
69 SelectFileDialog* CreateLinuxSelectFileDialog(
70 SelectFileDialog::Listener* listener,
71 SelectFilePolicy* policy);
75 #endif // UI_SHELL_DIALOGS_WEBUI_SELECT_FILE_DIALOG_IMPL_H_