Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h

Issue 1363093004: Add BrowserSelectFileDialogTest.OpenCloseFileDialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not run the test-server Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 CHROME_BROWSER_UI_LIBGTK2UI_SELECT_FILE_DIALOG_IMPL_GTK2_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_SELECT_FILE_DIALOG_IMPL_GTK2_H_
7
8 #include "base/macros.h"
9 #include "chrome/browser/ui/libgtk2ui/gtk2_signal.h"
10 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
11 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h"
12
13 namespace libgtk2ui {
14
15 // Implementation of SelectFileDialog that shows a Gtk common dialog for
16 // choosing a file or folder. This acts as a modal dialog.
17 class SelectFileDialogImplGTK : public SelectFileDialogImpl,
18 public aura::WindowObserver {
19 public:
20 SelectFileDialogImplGTK(Listener* listener,
21 ui::SelectFilePolicy* policy);
22
23 protected:
24 ~SelectFileDialogImplGTK() override;
25
26 // BaseShellDialog implementation:
27 bool IsRunning(gfx::NativeWindow parent_window) const override;
28
29 // SelectFileDialog implementation.
30 // |params| is user data we pass back via the Listener interface.
31 void SelectFileImpl(Type type,
32 const base::string16& title,
33 const base::FilePath& default_path,
34 const FileTypeInfo* file_types,
35 int file_type_index,
36 const base::FilePath::StringType& default_extension,
37 gfx::NativeWindow owning_window,
38 void* params) override;
39
40 private:
41 friend class FilePicker;
42 bool HasMultipleFileTypeChoicesImpl() override;
43
44 // Overridden from aura::WindowObserver:
45 void OnWindowDestroying(aura::Window* window) override;
46
47 // Add the filters from |file_types_| to |chooser|.
48 void AddFilters(GtkFileChooser* chooser);
49
50 // Notifies the listener that a single file was chosen.
51 void FileSelected(GtkWidget* dialog, const base::FilePath& path);
52
53 // Notifies the listener that multiple files were chosen.
54 void MultiFilesSelected(GtkWidget* dialog,
55 const std::vector<base::FilePath>& files);
56
57 // Notifies the listener that no file was chosen (the action was canceled).
58 // Dialog is passed so we can find that |params| pointer that was passed to
59 // us when we were told to show the dialog.
60 void FileNotSelected(GtkWidget* dialog);
61
62 GtkWidget* CreateSelectFolderDialog(
63 Type type,
64 const std::string& title,
65 const base::FilePath& default_path,
66 gfx::NativeWindow parent);
67
68 GtkWidget* CreateFileOpenDialog(const std::string& title,
69 const base::FilePath& default_path, gfx::NativeWindow parent);
70
71 GtkWidget* CreateMultiFileOpenDialog(const std::string& title,
72 const base::FilePath& default_path, gfx::NativeWindow parent);
73
74 GtkWidget* CreateSaveAsDialog(const std::string& title,
75 const base::FilePath& default_path, gfx::NativeWindow parent);
76
77 // Removes and returns the |params| associated with |dialog| from
78 // |params_map_|.
79 void* PopParamsForDialog(GtkWidget* dialog);
80
81 // Take care of internal data structures when a file dialog is destroyed.
82 void FileDialogDestroyed(GtkWidget* dialog);
83
84 // Check whether response_id corresponds to the user cancelling/closing the
85 // dialog. Used as a helper for the below callbacks.
86 bool IsCancelResponse(gint response_id);
87
88 // Common function for OnSelectSingleFileDialogResponse and
89 // OnSelectSingleFolderDialogResponse.
90 void SelectSingleFileHelper(GtkWidget* dialog,
91 gint response_id,
92 bool allow_folder);
93
94 // Common function for CreateFileOpenDialog and CreateMultiFileOpenDialog.
95 GtkWidget* CreateFileOpenHelper(const std::string& title,
96 const base::FilePath& default_path,
97 gfx::NativeWindow parent);
98
99 // Callback for when the user responds to a Save As or Open File dialog.
100 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void,
101 OnSelectSingleFileDialogResponse, int);
102
103 // Callback for when the user responds to a Select Folder dialog.
104 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void,
105 OnSelectSingleFolderDialogResponse, int);
106
107 // Callback for when the user responds to a Open Multiple Files dialog.
108 CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void,
109 OnSelectMultiFileDialogResponse, int);
110
111 // Callback for when the file chooser gets destroyed.
112 CHROMEGTK_CALLBACK_0(SelectFileDialogImplGTK, void, OnFileChooserDestroy);
113
114 // Callback for when we update the preview for the selection.
115 CHROMEGTK_CALLBACK_0(SelectFileDialogImplGTK, void, OnUpdatePreview);
116
117 // A map from dialog windows to the |params| user data associated with them.
118 std::map<GtkWidget*, void*> params_map_;
119
120 // The GtkImage widget for showing previews of selected images.
121 GtkWidget* preview_;
122
123 // All our dialogs.
124 std::set<GtkWidget*> dialogs_;
125
126 // The set of all parent windows for which we are currently running dialogs.
127 std::set<aura::Window*> parents_;
128
129 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImplGTK);
130 };
131
132 } // namespace libgtk2ui
133
134 #endif // CHROME_BROWSER_UI_LIBGTK2UI_SELECT_FILE_DIALOG_IMPL_GTK2_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698