OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_SELECT_FILE_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_UI_SELECT_FILE_DIALOG_H_ |
6 #define CHROME_BROWSER_UI_SELECT_FILE_DIALOG_H_ | 6 #define CHROME_BROWSER_UI_SELECT_FILE_DIALOG_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/callback_forward.h" |
12 #include "base/file_path.h" | 14 #include "base/file_path.h" |
13 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" |
14 #include "base/string16.h" | 17 #include "base/string16.h" |
15 #include "ui/base/dialogs/base_shell_dialog.h" | 18 #include "ui/base/dialogs/base_shell_dialog.h" |
16 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
17 | 20 |
| 21 namespace ui { |
| 22 class SelectFilePolicy; |
| 23 } |
| 24 |
18 namespace content { | 25 namespace content { |
19 class WebContents; | 26 class WebContents; |
20 } | 27 } |
21 | 28 |
22 namespace ui { | 29 namespace ui { |
23 struct SelectedFileInfo; | 30 struct SelectedFileInfo; |
24 } | 31 } |
25 | 32 |
26 // This function is declared extern such that it is accessible for unit tests | 33 // This function is declared extern such that it is accessible for unit tests |
27 // in /chrome/browser/ui/views/select_file_dialog_win_unittest.cc | 34 // in /chrome/browser/ui/views/select_file_dialog_win_unittest.cc |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // Notifies the Listener that the file/folder selection was aborted (via | 86 // Notifies the Listener that the file/folder selection was aborted (via |
80 // the user canceling or closing the selection dialog box, for example). | 87 // the user canceling or closing the selection dialog box, for example). |
81 // |params| is contextual passed to SelectFile. | 88 // |params| is contextual passed to SelectFile. |
82 virtual void FileSelectionCanceled(void* params) {} | 89 virtual void FileSelectionCanceled(void* params) {} |
83 | 90 |
84 protected: | 91 protected: |
85 virtual ~Listener() {} | 92 virtual ~Listener() {} |
86 }; | 93 }; |
87 | 94 |
88 // Creates a dialog box helper. This object is ref-counted, but the returned | 95 // Creates a dialog box helper. This object is ref-counted, but the returned |
89 // object will have no reference (refcount is 0). | 96 // object will have no reference (refcount is 0). |policy| is an optional |
90 static SelectFileDialog* Create(Listener* listener); | 97 // class that can prevent showing a dialog. |
| 98 static SelectFileDialog* Create(Listener* listener, |
| 99 ui::SelectFilePolicy* policy); |
91 | 100 |
92 // Holds information about allowed extensions on a file save dialog. | 101 // Holds information about allowed extensions on a file save dialog. |
93 // |extensions| is a list of allowed extensions. For example, it might be | 102 // |extensions| is a list of allowed extensions. For example, it might be |
94 // { { "htm", "html" }, { "txt" } }. Only pass more than one extension | 103 // { { "htm", "html" }, { "txt" } }. Only pass more than one extension |
95 // in the inner vector if the extensions are equivalent. Do NOT include | 104 // in the inner vector if the extensions are equivalent. Do NOT include |
96 // leading periods. | 105 // leading periods. |
97 // |extension_description_overrides| overrides the system descriptions of the | 106 // |extension_description_overrides| overrides the system descriptions of the |
98 // specified extensions. Entries correspond to |extensions|; if left blank | 107 // specified extensions. Entries correspond to |extensions|; if left blank |
99 // the system descriptions will be used. | 108 // the system descriptions will be used. |
100 // |include_all_files| specifies whether there will be a filter added for all | 109 // |include_all_files| specifies whether there will be a filter added for all |
(...skipping 21 matching lines...) Expand all Loading... |
122 // |default_path| is the default path and suggested file name to be shown in | 131 // |default_path| is the default path and suggested file name to be shown in |
123 // the dialog. This only works for SELECT_SAVEAS_FILE and SELECT_OPEN_FILE. | 132 // the dialog. This only works for SELECT_SAVEAS_FILE and SELECT_OPEN_FILE. |
124 // Can be an empty string to indicate the platform default. | 133 // Can be an empty string to indicate the platform default. |
125 // |file_types| holds the information about the file types allowed. Pass NULL | 134 // |file_types| holds the information about the file types allowed. Pass NULL |
126 // to get no special behavior | 135 // to get no special behavior |
127 // |file_type_index| is the 1-based index into the file type list in | 136 // |file_type_index| is the 1-based index into the file type list in |
128 // |file_types|. Specify 0 if you don't need to specify extension behavior. | 137 // |file_types|. Specify 0 if you don't need to specify extension behavior. |
129 // |default_extension| is the default extension to add to the file if the | 138 // |default_extension| is the default extension to add to the file if the |
130 // user doesn't type one. This should NOT include the '.'. On Windows, if | 139 // user doesn't type one. This should NOT include the '.'. On Windows, if |
131 // you specify this you must also specify |file_types|. | 140 // you specify this you must also specify |file_types|. |
132 // |source_contents| is the WebContents the call is originating from, i.e. | |
133 // where the InfoBar should be shown in case file-selection dialogs are | |
134 // forbidden by policy, or NULL if no InfoBar should be shown. | |
135 // |owning_window| is the window the dialog is modal to, or NULL for a | 141 // |owning_window| is the window the dialog is modal to, or NULL for a |
136 // modeless dialog. | 142 // modeless dialog. |
137 // |params| is data from the calling context which will be passed through to | 143 // |params| is data from the calling context which will be passed through to |
138 // the listener. Can be NULL. | 144 // the listener. Can be NULL. |
139 // NOTE: only one instance of any shell dialog can be shown per owning_window | 145 // NOTE: only one instance of any shell dialog can be shown per owning_window |
140 // at a time (for obvious reasons). | 146 // at a time (for obvious reasons). |
141 void SelectFile(Type type, | 147 void SelectFile(Type type, |
142 const string16& title, | 148 const string16& title, |
143 const FilePath& default_path, | 149 const FilePath& default_path, |
144 const FileTypeInfo* file_types, | 150 const FileTypeInfo* file_types, |
145 int file_type_index, | 151 int file_type_index, |
146 const FilePath::StringType& default_extension, | 152 const FilePath::StringType& default_extension, |
147 content::WebContents* source_contents, | |
148 gfx::NativeWindow owning_window, | 153 gfx::NativeWindow owning_window, |
149 void* params); | 154 void* params); |
150 bool HasMultipleFileTypeChoices(); | 155 bool HasMultipleFileTypeChoices(); |
151 | 156 |
152 protected: | 157 protected: |
153 friend class base::RefCountedThreadSafe<SelectFileDialog>; | 158 friend class base::RefCountedThreadSafe<SelectFileDialog>; |
154 explicit SelectFileDialog(Listener* listener); | 159 explicit SelectFileDialog(Listener* listener, |
| 160 ui::SelectFilePolicy* policy); |
155 virtual ~SelectFileDialog(); | 161 virtual ~SelectFileDialog(); |
156 | 162 |
157 // Displays the actual file-selection dialog. | 163 // Displays the actual file-selection dialog. |
158 // This is overridden in the platform-specific descendants of FileSelectDialog | 164 // This is overridden in the platform-specific descendants of FileSelectDialog |
159 // and gets called from SelectFile after testing the | 165 // and gets called from SelectFile after testing the |
160 // AllowFileSelectionDialogs-Policy. | 166 // AllowFileSelectionDialogs-Policy. |
161 virtual void SelectFileImpl(Type type, | 167 virtual void SelectFileImpl(Type type, |
162 const string16& title, | 168 const string16& title, |
163 const FilePath& default_path, | 169 const FilePath& default_path, |
164 const FileTypeInfo* file_types, | 170 const FileTypeInfo* file_types, |
(...skipping 10 matching lines...) Expand all Loading... |
175 // testing if the AllowFileSelectionDialogs-Policy is | 181 // testing if the AllowFileSelectionDialogs-Policy is |
176 // either unset or set to true. | 182 // either unset or set to true. |
177 bool CanOpenSelectFileDialog(); | 183 bool CanOpenSelectFileDialog(); |
178 | 184 |
179 // Informs the |listener_| that the file selection dialog was canceled. Moved | 185 // Informs the |listener_| that the file selection dialog was canceled. Moved |
180 // to a function for being able to post it to the message loop. | 186 // to a function for being able to post it to the message loop. |
181 void CancelFileSelection(void* params); | 187 void CancelFileSelection(void* params); |
182 | 188 |
183 // Returns true if the dialog has multiple file type choices. | 189 // Returns true if the dialog has multiple file type choices. |
184 virtual bool HasMultipleFileTypeChoicesImpl() = 0; | 190 virtual bool HasMultipleFileTypeChoicesImpl() = 0; |
| 191 |
| 192 scoped_ptr<ui::SelectFilePolicy> select_file_policy_; |
| 193 |
| 194 DISALLOW_COPY_AND_ASSIGN(SelectFileDialog); |
185 }; | 195 }; |
186 | 196 |
187 #endif // CHROME_BROWSER_UI_SELECT_FILE_DIALOG_H_ | 197 #endif // CHROME_BROWSER_UI_SELECT_FILE_DIALOG_H_ |
OLD | NEW |