| 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 UI_BASE_DIALOGS_SELECT_FILE_DIALOG_H_ | 5 #ifndef UI_BASE_DIALOGS_SELECT_FILE_DIALOG_H_ |
| 6 #define UI_BASE_DIALOGS_SELECT_FILE_DIALOG_H_ | 6 #define UI_BASE_DIALOGS_SELECT_FILE_DIALOG_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // | 53 // |
| 54 // If not overridden, calls FileSelected() with path from |file|. | 54 // If not overridden, calls FileSelected() with path from |file|. |
| 55 virtual void FileSelectedWithExtraInfo( | 55 virtual void FileSelectedWithExtraInfo( |
| 56 const ui::SelectedFileInfo& file, | 56 const ui::SelectedFileInfo& file, |
| 57 int index, | 57 int index, |
| 58 void* params); | 58 void* params); |
| 59 | 59 |
| 60 // Notifies the Listener that many files have been selected. The | 60 // Notifies the Listener that many files have been selected. The |
| 61 // files are in |files|. |params| is contextual passed to SelectFile. | 61 // files are in |files|. |params| is contextual passed to SelectFile. |
| 62 virtual void MultiFilesSelected( | 62 virtual void MultiFilesSelected( |
| 63 const std::vector<FilePath>& files, void* params) {} | 63 const std::vector<FilePath>& files, void* params) {} |
| 64 | 64 |
| 65 // Similar to MultiFilesSelected() but takes SelectedFileInfo instead of | 65 // Similar to MultiFilesSelected() but takes SelectedFileInfo instead of |
| 66 // FilePath. Used for passing extra information (ex. display name). | 66 // FilePath. Used for passing extra information (ex. display name). |
| 67 // | 67 // |
| 68 // If not overridden, calls MultiFilesSelected() with paths from |files|. | 68 // If not overridden, calls MultiFilesSelected() with paths from |files|. |
| 69 virtual void MultiFilesSelectedWithExtraInfo( | 69 virtual void MultiFilesSelectedWithExtraInfo( |
| 70 const std::vector<ui::SelectedFileInfo>& files, | 70 const std::vector<ui::SelectedFileInfo>& files, |
| 71 void* params); | 71 void* params); |
| 72 | 72 |
| 73 // Notifies the Listener that the file/folder selection was aborted (via | 73 // Notifies the Listener that the file/folder selection was aborted (via |
| 74 // the user canceling or closing the selection dialog box, for example). | 74 // the user canceling or closing the selection dialog box, for example). |
| 75 // |params| is contextual passed to SelectFile. | 75 // |params| is contextual passed to SelectFile. |
| 76 virtual void FileSelectionCanceled(void* params) {} | 76 virtual void FileSelectionCanceled(void* params) {} |
| 77 | 77 |
| 78 protected: | 78 protected: |
| 79 virtual ~Listener() {} | 79 virtual ~Listener() {} |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 // Sets the factory that creates SelectFileDialog objects, overriding default | 82 // Sets the factory that creates SelectFileDialog objects, overriding default |
| 83 // behaviour. | 83 // behaviour. |
| 84 // | 84 // |
| 85 // This is optional and should only be used by components that have to live | 85 // This is optional and should only be used by components that have to live |
| 86 // elsewhere in the tree due to layering violations. (For example, because of | 86 // elsewhere in the tree due to layering violations. (For example, because of |
| 87 // a dependency on chrome's extension system.) | 87 // a dependency on chrome's extension system.) |
| 88 static void SetFactory(ui::SelectFileDialogFactory* factory); | 88 static void SetFactory(ui::SelectFileDialogFactory* factory); |
| 89 | 89 |
| 90 // Creates a dialog box helper. This object is ref-counted, but the returned | 90 // Creates a dialog box helper. This object is ref-counted, but the returned |
| 91 // object will have no reference (refcount is 0). |policy| is an optional | 91 // object will have no reference (refcount is 0). |policy| is an optional |
| 92 // class that can prevent showing a dialog. | 92 // class that can prevent showing a dialog. |
| 93 static SelectFileDialog* Create(Listener* listener, | 93 static SelectFileDialog* Create(Listener* listener, |
| 94 ui::SelectFilePolicy* policy); | 94 ui::SelectFilePolicy* policy); |
| 95 | 95 |
| 96 // Holds information about allowed extensions on a file save dialog. | 96 // Holds information about allowed extensions on a file save dialog. |
| 97 // |extensions| is a list of allowed extensions. For example, it might be | |
| 98 // { { "htm", "html" }, { "txt" } }. Only pass more than one extension | |
| 99 // in the inner vector if the extensions are equivalent. Do NOT include | |
| 100 // leading periods. | |
| 101 // |extension_description_overrides| overrides the system descriptions of the | |
| 102 // specified extensions. Entries correspond to |extensions|; if left blank | |
| 103 // the system descriptions will be used. | |
| 104 // |include_all_files| specifies whether there will be a filter added for all | |
| 105 // files (i.e. *.*). | |
| 106 struct UI_EXPORT FileTypeInfo { | 97 struct UI_EXPORT FileTypeInfo { |
| 107 FileTypeInfo(); | 98 FileTypeInfo(); |
| 108 ~FileTypeInfo(); | 99 ~FileTypeInfo(); |
| 109 | 100 |
| 101 // A list of allowed extensions. For example, it might be |
| 102 // |
| 103 // { { "htm", "html" }, { "txt" } } |
| 104 // |
| 105 // Only pass more than one extension in the inner vector if the extensions |
| 106 // are equivalent. Do NOT include leading periods. |
| 110 std::vector<std::vector<FilePath::StringType> > extensions; | 107 std::vector<std::vector<FilePath::StringType> > extensions; |
| 108 |
| 109 // Overrides the system descriptions of the specified extensions. Entries |
| 110 // correspond to |extensions|; if left blank the system descriptions will |
| 111 // be used. |
| 111 std::vector<string16> extension_description_overrides; | 112 std::vector<string16> extension_description_overrides; |
| 113 |
| 114 // Specifies whether there will be a filter added for all files (i.e. *.*). |
| 112 bool include_all_files; | 115 bool include_all_files; |
| 116 |
| 117 // Specifies whether the caller can support files/folders that are on |
| 118 // GDrive. |
| 119 bool support_gdata; |
| 113 }; | 120 }; |
| 114 | 121 |
| 115 // Selects a File. | 122 // Selects a File. |
| 116 // Before doing anything this function checks if FileBrowsing is forbidden | 123 // Before doing anything this function checks if FileBrowsing is forbidden |
| 117 // by Policy. If so, it tries to show an InfoBar and behaves as though no File | 124 // by Policy. If so, it tries to show an InfoBar and behaves as though no File |
| 118 // was selected (the user clicked `Cancel` immediately). | 125 // was selected (the user clicked `Cancel` immediately). |
| 119 // Otherwise it will start displaying the dialog box. This will also | 126 // Otherwise it will start displaying the dialog box. This will also |
| 120 // block the calling window until the dialog box is complete. The listener | 127 // block the calling window until the dialog box is complete. The listener |
| 121 // associated with this object will be notified when the selection is | 128 // associated with this object will be notified when the selection is |
| 122 // complete. | 129 // complete. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 virtual bool HasMultipleFileTypeChoicesImpl() = 0; | 192 virtual bool HasMultipleFileTypeChoicesImpl() = 0; |
| 186 | 193 |
| 187 scoped_ptr<ui::SelectFilePolicy> select_file_policy_; | 194 scoped_ptr<ui::SelectFilePolicy> select_file_policy_; |
| 188 | 195 |
| 189 DISALLOW_COPY_AND_ASSIGN(SelectFileDialog); | 196 DISALLOW_COPY_AND_ASSIGN(SelectFileDialog); |
| 190 }; | 197 }; |
| 191 | 198 |
| 192 } // namespace ui | 199 } // namespace ui |
| 193 | 200 |
| 194 #endif // UI_BASE_DIALOGS_SELECT_FILE_DIALOG_H_ | 201 #endif // UI_BASE_DIALOGS_SELECT_FILE_DIALOG_H_ |
| OLD | NEW |