| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 virtual ~SelectFileDialog() {} | 43 virtual ~SelectFileDialog() {} |
| 44 | 44 |
| 45 // An interface implemented by a Listener object wishing to know about the | 45 // An interface implemented by a Listener object wishing to know about the |
| 46 // the result of the Select File/Folder action. These callbacks must be | 46 // the result of the Select File/Folder action. These callbacks must be |
| 47 // re-entrant. | 47 // re-entrant. |
| 48 class Listener { | 48 class Listener { |
| 49 public: | 49 public: |
| 50 // Notifies the Listener that a file/folder selection has been made. The | 50 // Notifies the Listener that a file/folder selection has been made. The |
| 51 // file/folder path is in |selected_path|. |params| is contextual passed to | 51 // file/folder path is in |path|. |params| is contextual passed to |
| 52 // SelectFile. | 52 // SelectFile. |index| specifies the index of the filter passed to the |
| 53 virtual void FileSelected(const std::wstring& path, void* params) = 0; | 53 // the initial call to SelectFile. |
| 54 virtual void FileSelected(const std::wstring& path, |
| 55 int index, void* params) = 0; |
| 54 | 56 |
| 55 // Notifies the Listener that many files have been selected. The | 57 // Notifies the Listener that many files have been selected. The |
| 56 // files are in |files|. |params| is contextual passed to SelectFile. | 58 // files are in |files|. |params| is contextual passed to SelectFile. |
| 57 virtual void MultiFilesSelected( | 59 virtual void MultiFilesSelected( |
| 58 const std::vector<std::wstring>& files, void* params) {}; | 60 const std::vector<std::wstring>& files, void* params) {}; |
| 59 | 61 |
| 60 // Notifies the Listener that the file/folder selection was aborted (via | 62 // Notifies the Listener that the file/folder selection was aborted (via |
| 61 // the user canceling or closing the selection dialog box, for example). | 63 // the user canceling or closing the selection dialog box, for example). |
| 62 // |params| is contextual passed to SelectFile. | 64 // |params| is contextual passed to SelectFile. |
| 63 virtual void FileSelectionCanceled(void* params) {}; | 65 virtual void FileSelectionCanceled(void* params) {}; |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 // Creates a dialog box helper. This object is ref-counted, but the returned | 68 // Creates a dialog box helper. This object is ref-counted, but the returned |
| 67 // object will have no reference (refcount is 0). | 69 // object will have no reference (refcount is 0). |
| 68 static SelectFileDialog* Create(Listener* listener); | 70 static SelectFileDialog* Create(Listener* listener); |
| 69 | 71 |
| 70 // Selects a file. This will start displaying the dialog box. This will also | 72 // Selects a file. This will start displaying the dialog box. This will also |
| 71 // block the calling window until the dialog box is complete. The listener | 73 // block the calling window until the dialog box is complete. The listener |
| 72 // associated with this object will be notified when the selection is | 74 // associated with this object will be notified when the selection is |
| 73 // complete. | 75 // complete. |
| 74 // |type| is the type of file dialog to be shown, see Type enumeration above. | 76 // |type| is the type of file dialog to be shown, see Type enumeration above. |
| 75 // |title| is the title to be displayed in the dialog. If this string is | 77 // |title| is the title to be displayed in the dialog. If this string is |
| 76 // empty, the default title is used. | 78 // empty, the default title is used. |
| 77 // |default_path| is the default path and suggested file name to be shown in | 79 // |default_path| is the default path and suggested file name to be shown in |
| 78 // the dialog. This only works for SELECT_SAVEAS_FILE and SELECT_OPEN_FILE. | 80 // the dialog. This only works for SELECT_SAVEAS_FILE and SELECT_OPEN_FILE. |
| 79 // Can be an empty string to indicate Windows should choose the default to | 81 // Can be an empty string to indicate Windows should choose the default to |
| 80 // show. | 82 // show. |
| 81 // |filter| is a null (\0) separated list of alternating filter description | 83 // |filter| is a null (\0) separated list of alternating filter description |
| 82 // and filters and terminated with two nulls. | 84 // and filters and terminated with two nulls. |
| 85 // |filter_index| is the 1-based index into the filter list in |filter|. |
| 86 // Specify 0 if you don't need filters, or if you only need the default |
| 87 // (first filter) behavior. |
| 83 // |owning_window| is the window the dialog is modal to, or NULL for a | 88 // |owning_window| is the window the dialog is modal to, or NULL for a |
| 84 // modeless dialog. | 89 // modeless dialog. |
| 85 // |default_extension| is the default extension to add to the file if the | 90 // |default_extension| is the default extension to add to the file if the |
| 86 // user doesn't type one. This should NOT include the '.'. If you specify | 91 // user doesn't type one. This should NOT include the '.'. If you specify |
| 87 // this you must also specify a filter. | 92 // this you must also specify a filter. |
| 88 // |params| is data from the calling context which will be passed through to | 93 // |params| is data from the calling context which will be passed through to |
| 89 // the listener. Can be NULL. | 94 // the listener. Can be NULL. |
| 90 // NOTE: only one instance of any shell dialog can be shown per owning_window | 95 // NOTE: only one instance of any shell dialog can be shown per owning_window |
| 91 // at a time (for obvious reasons). | 96 // at a time (for obvious reasons). |
| 92 virtual void SelectFile(Type type, | 97 virtual void SelectFile(Type type, |
| 93 const std::wstring& title, | 98 const std::wstring& title, |
| 94 const std::wstring& default_path, | 99 const std::wstring& default_path, |
| 95 const std::wstring& filter, | 100 const std::wstring& filter, |
| 101 int filter_index, |
| 96 const std::wstring& default_extension, | 102 const std::wstring& default_extension, |
| 97 gfx::NativeWindow owning_window, | 103 gfx::NativeWindow owning_window, |
| 98 void* params) = 0; | 104 void* params) = 0; |
| 99 }; | 105 }; |
| 100 | 106 |
| 101 // Shows a dialog box for selecting a font. | 107 // Shows a dialog box for selecting a font. |
| 102 class SelectFontDialog | 108 class SelectFontDialog |
| 103 : public base::RefCountedThreadSafe<SelectFileDialog>, | 109 : public base::RefCountedThreadSafe<SelectFileDialog>, |
| 104 public BaseShellDialog { | 110 public BaseShellDialog { |
| 105 public: | 111 public: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 148 |
| 143 // Same as above - also support specifying the default font selected in the | 149 // Same as above - also support specifying the default font selected in the |
| 144 // list when the dialog appears. | 150 // list when the dialog appears. |
| 145 virtual void SelectFont(gfx::NativeWindow owning_window, | 151 virtual void SelectFont(gfx::NativeWindow owning_window, |
| 146 void* params, | 152 void* params, |
| 147 const std::wstring& font_name, | 153 const std::wstring& font_name, |
| 148 int font_size) = 0; | 154 int font_size) = 0; |
| 149 }; | 155 }; |
| 150 | 156 |
| 151 #endif // CHROME_BROWSER_SHELL_DIALOGS_H_ | 157 #endif // CHROME_BROWSER_SHELL_DIALOGS_H_ |
| OLD | NEW |