OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 common select dialog functionality between GTK and KDE. | |
6 | |
7 #ifndef CHROME_BROWSER_UI_GTK_SELECT_FILE_DIALOG_IMPL_H_ | |
8 #define CHROME_BROWSER_UI_GTK_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 "chrome/browser/ui/select_file_dialog.h" | |
15 | |
16 // Shared implementation SelectFileDialog used by SelectFileDialogImplGTK | |
17 class SelectFileDialogImpl : public SelectFileDialog { | |
18 public: | |
19 // Factory method for creating a GTK-styled SelectFileDialogImpl | |
20 static SelectFileDialogImpl* NewSelectFileDialogImplGTK( | |
21 Listener* listener, | |
22 ui::SelectFilePolicy* policy); | |
23 // Factory method for creating a KDE-styled SelectFileDialogImpl | |
24 static SelectFileDialogImpl* NewSelectFileDialogImplKDE( | |
25 Listener* listener, | |
26 ui::SelectFilePolicy* policy, | |
27 base::nix::DesktopEnvironment desktop); | |
28 | |
29 // Returns true if the SelectFileDialog class returned by | |
30 // NewSelectFileDialogImplKDE will actually work. | |
31 static bool CheckKDEDialogWorksOnUIThread(); | |
32 | |
33 // BaseShellDialog implementation. | |
34 virtual bool IsRunning(gfx::NativeWindow parent_window) const OVERRIDE; | |
35 virtual void ListenerDestroyed() OVERRIDE; | |
36 | |
37 protected: | |
38 explicit SelectFileDialogImpl(Listener* listener, | |
39 ui::SelectFilePolicy* policy); | |
40 virtual ~SelectFileDialogImpl(); | |
41 | |
42 // SelectFileDialog implementation. | |
43 // |params| is user data we pass back via the Listener interface. | |
44 virtual void SelectFileImpl(Type type, | |
45 const string16& title, | |
46 const FilePath& default_path, | |
47 const FileTypeInfo* file_types, | |
48 int file_type_index, | |
49 const FilePath::StringType& default_extension, | |
50 gfx::NativeWindow owning_window, | |
51 void* params) = 0; | |
52 | |
53 // Wrapper for file_util::DirectoryExists() that allow access on the UI | |
54 // thread. Use this only in the file dialog functions, where it's ok | |
55 // because the file dialog has to do many stats anyway. One more won't | |
56 // hurt too badly and it's likely already cached. | |
57 bool CallDirectoryExistsOnUIThread(const FilePath& path); | |
58 | |
59 // The file filters. | |
60 FileTypeInfo file_types_; | |
61 | |
62 // The index of the default selected file filter. | |
63 // Note: This starts from 1, not 0. | |
64 size_t file_type_index_; | |
65 | |
66 // The set of all parent windows for which we are currently running dialogs. | |
67 std::set<GtkWindow*> parents_; | |
68 | |
69 // The type of dialog we are showing the user. | |
70 Type type_; | |
71 | |
72 // These two variables track where the user last saved a file or opened a | |
73 // file so that we can display future dialogs with the same starting path. | |
74 static FilePath* last_saved_path_; | |
75 static FilePath* last_opened_path_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl); | |
78 }; | |
79 | |
80 #endif // CHROME_BROWSER_UI_GTK_SELECT_FILE_DIALOG_IMPL_H_ | |
OLD | NEW |