- Code: Select all
<input type="file" accept=".jpg, .png, .jpeg">
In chrome's fileDialog there are only 2 filters:
--customfile (*.jpg;*.png;*.jpeg)
--all (*.*)
In CEF's fileDialog there are 4 filters:
--JPG file (*.jpg)
--PNG file (*.png)
--JPEG file (*.jpeg)
--all (*.*)
If I want to provide a file dialog perform like chrome's one, is popup my own file dialog with CefDialogHandler::OnFileDialog my only option?
BTW, I notice the comments mention about '(c) combined description and file extension delimited using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg")'. When or how the html or js look like will create such kind of filter.
- Code: Select all
class CefDialogHandler : public virtual CefBaseRefCounted {
public:
typedef cef_file_dialog_mode_t FileDialogMode;
///
// Called to run a file chooser dialog. |mode| represents the type of dialog
// to display. |title| to the title to be used for the dialog and may be empty
// to show the default title ("Open" or "Save" depending on the mode).
// |default_file_path| is the path with optional directory and/or file name
// component that should be initially selected in the dialog. |accept_filters|
// are used to restrict the selectable file types and may any combination of
// (a) valid lower-cased MIME types (e.g. "text/*" or "image/*"),
// (b) individual file extensions (e.g. ".txt" or ".png"), or (c) combined
// description and file extension delimited using "|" and ";" (e.g.
// "Image Types|.png;.gif;.jpg"). |selected_accept_filter| is the 0-based
// index of the filter that should be selected by default. To display a custom
// dialog return true and execute |callback| either inline or at a later time.
// To display the default dialog return false.
///
/*--cef(optional_param=title,optional_param=default_file_path,
optional_param=accept_filters,index_param=selected_accept_filter)--*/
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
int selected_accept_filter,
CefRefPtr<CefFileDialogCallback> callback) {
return false;
}
};