OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_SHELL_DIALOGS_H_ | 5 #ifndef CHROME_BROWSER_SHELL_DIALOGS_H_ |
6 #define CHROME_BROWSER_SHELL_DIALOGS_H_ | 6 #define CHROME_BROWSER_SHELL_DIALOGS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/gfx/native_widget_types.h" | 12 #include "base/gfx/native_widget_types.h" |
13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class Font; | 17 class Font; |
18 } | 18 } |
19 | 19 |
20 // A base class for shell dialogs. | 20 // A base class for shell dialogs. |
21 class BaseShellDialog { | 21 class BaseShellDialog { |
22 public: | 22 public: |
23 // Returns true if a shell dialog box is currently being shown modally | 23 // Returns true if a shell dialog box is currently being shown modally |
24 // to the specified owner. | 24 // to the specified owner. |
25 virtual bool IsRunning(gfx::NativeWindow owning_window) const = 0; | 25 virtual bool IsRunning(gfx::NativeWindow owning_window) const = 0; |
26 | 26 |
27 // Notifies the dialog box that the listener has been destroyed and it should | 27 // Notifies the dialog box that the listener has been destroyed and it should |
28 // no longer be sent notifications. | 28 // no longer be sent notifications. |
29 virtual void ListenerDestroyed() = 0; | 29 virtual void ListenerDestroyed() = 0; |
30 | |
31 protected: | |
32 ~BaseShellDialog() {} | |
33 }; | 30 }; |
34 | 31 |
35 // Shows a dialog box for selecting a file or a folder. | 32 // Shows a dialog box for selecting a file or a folder. |
36 class SelectFileDialog | 33 class SelectFileDialog |
37 : public base::RefCountedThreadSafe<SelectFileDialog>, | 34 : public base::RefCountedThreadSafe<SelectFileDialog>, |
38 public BaseShellDialog { | 35 public BaseShellDialog { |
39 public: | 36 public: |
40 enum Type { | 37 enum Type { |
41 SELECT_FOLDER, | 38 SELECT_FOLDER, |
42 SELECT_SAVEAS_FILE, | 39 SELECT_SAVEAS_FILE, |
(...skipping 17 matching lines...) Expand all Loading... |
60 | 57 |
61 // Notifies the Listener that many files have been selected. The | 58 // Notifies the Listener that many files have been selected. The |
62 // files are in |files|. |params| is contextual passed to SelectFile. | 59 // files are in |files|. |params| is contextual passed to SelectFile. |
63 virtual void MultiFilesSelected( | 60 virtual void MultiFilesSelected( |
64 const std::vector<FilePath>& files, void* params) {}; | 61 const std::vector<FilePath>& files, void* params) {}; |
65 | 62 |
66 // Notifies the Listener that the file/folder selection was aborted (via | 63 // Notifies the Listener that the file/folder selection was aborted (via |
67 // the user canceling or closing the selection dialog box, for example). | 64 // the user canceling or closing the selection dialog box, for example). |
68 // |params| is contextual passed to SelectFile. | 65 // |params| is contextual passed to SelectFile. |
69 virtual void FileSelectionCanceled(void* params) {}; | 66 virtual void FileSelectionCanceled(void* params) {}; |
70 | |
71 protected: | |
72 ~Listener() {}; | |
73 }; | 67 }; |
74 | 68 |
75 // Creates a dialog box helper. This object is ref-counted, but the returned | 69 // Creates a dialog box helper. This object is ref-counted, but the returned |
76 // object will have no reference (refcount is 0). | 70 // object will have no reference (refcount is 0). |
77 static SelectFileDialog* Create(Listener* listener); | 71 static SelectFileDialog* Create(Listener* listener); |
78 | 72 |
79 // Holds information about allowed extensions on a file save dialog. | 73 // Holds information about allowed extensions on a file save dialog. |
80 // |extensions| is a list of allowed extensions. For example, it might be | 74 // |extensions| is a list of allowed extensions. For example, it might be |
81 // { { "htm", "html" }, { "txt" } }. Only pass more than one extension | 75 // { { "htm", "html" }, { "txt" } }. Only pass more than one extension |
82 // in the inner vector if the extensions are equivalent. Do NOT include | 76 // in the inner vector if the extensions are equivalent. Do NOT include |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 public: | 133 public: |
140 // Notifies the Listener that a font selection has been made. The font | 134 // Notifies the Listener that a font selection has been made. The font |
141 // details are supplied in |font|. |params| is contextual passed to | 135 // details are supplied in |font|. |params| is contextual passed to |
142 // SelectFile. | 136 // SelectFile. |
143 virtual void FontSelected(const gfx::Font& font, void* params) = 0; | 137 virtual void FontSelected(const gfx::Font& font, void* params) = 0; |
144 | 138 |
145 // Notifies the Listener that the font selection was aborted (via the user | 139 // Notifies the Listener that the font selection was aborted (via the user |
146 // canceling or closing the selection dialog box, for example). |params| is | 140 // canceling or closing the selection dialog box, for example). |params| is |
147 // contextual passed to SelectFile. | 141 // contextual passed to SelectFile. |
148 virtual void FontSelectionCanceled(void* params) {}; | 142 virtual void FontSelectionCanceled(void* params) {}; |
149 protected: | |
150 ~Listener() {}; | |
151 }; | 143 }; |
152 | 144 |
153 // Creates a dialog box helper. This object is ref-counted, but the returned | 145 // Creates a dialog box helper. This object is ref-counted, but the returned |
154 // object will have no reference (refcount is 0). | 146 // object will have no reference (refcount is 0). |
155 static SelectFontDialog* Create(Listener* listener); | 147 static SelectFontDialog* Create(Listener* listener); |
156 | 148 |
157 // Selects a font. This will start displaying the dialog box. This will also | 149 // Selects a font. This will start displaying the dialog box. This will also |
158 // block the calling window until the dialog box is complete. The listener | 150 // block the calling window until the dialog box is complete. The listener |
159 // associated with this object will be notified when the selection is | 151 // associated with this object will be notified when the selection is |
160 // complete. | 152 // complete. |
(...skipping 10 matching lines...) Expand all Loading... |
171 | 163 |
172 // Same as above - also support specifying the default font selected in the | 164 // Same as above - also support specifying the default font selected in the |
173 // list when the dialog appears. | 165 // list when the dialog appears. |
174 virtual void SelectFont(gfx::NativeWindow owning_window, | 166 virtual void SelectFont(gfx::NativeWindow owning_window, |
175 void* params, | 167 void* params, |
176 const std::wstring& font_name, | 168 const std::wstring& font_name, |
177 int font_size) = 0; | 169 int font_size) = 0; |
178 }; | 170 }; |
179 | 171 |
180 #endif // CHROME_BROWSER_SHELL_DIALOGS_H_ | 172 #endif // CHROME_BROWSER_SHELL_DIALOGS_H_ |
OLD | NEW |