Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ozone / ui / webui / select_file_dialog_impl_webui.h
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.
4 //
5 // This file implements select dialog functionality using webview.
6
7 #ifndef UI_SHELL_DIALOGS_WEBUI_SELECT_FILE_DIALOG_IMPL_H_
8 #define UI_SHELL_DIALOGS_WEBUI_SELECT_FILE_DIALOG_IMPL_H_
9
10 #include <set>
11
12 #include "base/compiler_specific.h"
13 #include "base/nix/xdg_util.h"
14 #include "ui/shell_dialogs/select_file_dialog.h"
15
16 namespace ui {
17
18 class SelectFileDialogImplWebUI : public SelectFileDialog {
19  public:
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;
26
27  protected:
28   explicit SelectFileDialogImplWebUI(Listener* listener,
29                                      ui::SelectFilePolicy* policy);
30   virtual ~SelectFileDialogImplWebUI();
31
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,
38                       int file_type_index,
39                       const base::FilePath::StringType& default_extension,
40                       gfx::NativeWindow owning_window,
41                       void* params) override;
42   bool HasMultipleFileTypeChoicesImpl() override;
43
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);
49
50   // The file filters.
51   FileTypeInfo file_types_;
52
53   // The index of the default selected file filter.
54   // Note: This starts from 1, not 0.
55   size_t file_type_index_;
56
57   // The type of dialog we are showing the user.
58   Type type_;
59
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_;
64
65  private:
66   DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImplWebUI);
67 };
68
69 SelectFileDialog* CreateLinuxSelectFileDialog(
70     SelectFileDialog::Listener* listener,
71     SelectFilePolicy* policy);
72
73 }  // namespace ui
74
75 #endif  // UI_SHELL_DIALOGS_WEBUI_SELECT_FILE_DIALOG_IMPL_H_