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

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: fix gn and gyp files for chromeos 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 (c) 2012 The Chromium Authors. All rights reserved.
sky 2015/11/06 21:04:09 no (c) and 2015
joone 2015/11/09 20:50:06 Done.
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 friend class FilePicker;
sky 2015/11/06 21:04:09 move friend declaration into private section and i
joone 2015/11/09 20:50:06 Done.
20 public:
21 explicit SelectFileDialogImplGTK(Listener* listener,
sky 2015/11/06 21:04:09 no explicit.
joone 2015/11/09 20:50:06 Done.
22 ui::SelectFilePolicy* policy);
23
24 protected:
25 ~SelectFileDialogImplGTK() override;
26
27 // BaseShellDialog implementation:
28 bool IsRunning(gfx::NativeWindow parent_window) const override;
29
30 // SelectFileDialog implementation.
31 // |params| is user data we pass back via the Listener interface.
32 void SelectFileImpl(Type type,
33 const base::string16& title,
34 const base::FilePath& default_path,
35 const FileTypeInfo* file_types,
36 int file_type_index,
37 const base::FilePath::StringType& default_extension,
38 gfx::NativeWindow owning_window,
39 void* params) override;
40
41 private:
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