- Add open folder dialog support (FILE_DIALOG_OPEN_FOLDER mode) for CefBrowserHost::RunFileDialog (issue #1030).

- Standardize file dialog behavior across all platforms (issue #1492).
-- Show a file type filter list on OS X.
-- Show the file extensions as part of the filter list description on all platforms (e.g. "Image Types (*.png;*.gif;*.jpg)").
-- Rename the CefBrowserHost::RunFileDialog |accept_types| argument to |accept_filters| and expand support for filters that will be displayed as-is in addition to the currently supported mime-type and extension-based filters. For example, a filter value of "Supported Image Types|.png;.gif;.jpg" will display "Supported Image Types (*.png;*.gif;*.jpg)" in the filter drop-down list and accept *.png, *.gif and *.jpg files.
-- Persist the selected filter item index by passing a new |selected_accept_filter| argument to CefBrowserHost::RunFileDialog and returning the newly selected index via the CefRunFileDialogCallback and CefFileDialogCallback callbacks.
-- Rename the CefBrowserHost::RunFileDialog |default_file_name| argument to |default_file_path| and use the directory component, if any, to set the default directory location. If |default_file_path| ends in a trailing path separator it will be treated as a directory without a file name component.
-- Add FILE_DIALOG_OVERWRITEPROMPT_FLAG and FILE_DIALOG_HIDEREADONLY_FLAG values to cef_file_dialog_mode_t for controlling those behaviors where possible.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1973 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2015-01-20 18:24:54 +00:00
parent 3eabbb2e7d
commit e50ea8c29f
29 changed files with 1113 additions and 436 deletions

View File

@@ -188,37 +188,42 @@ void CefBrowserHostCToCpp::SetZoomLevel(double zoomLevel) {
}
void CefBrowserHostCToCpp::RunFileDialog(FileDialogMode mode,
const CefString& title, const CefString& default_file_name,
const std::vector<CefString>& accept_types,
const CefString& title, const CefString& default_file_path,
const std::vector<CefString>& accept_filters, int selected_accept_filter,
CefRefPtr<CefRunFileDialogCallback> callback) {
if (CEF_MEMBER_MISSING(struct_, run_file_dialog))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: selected_accept_filter; type: simple_byval
DCHECK_GE(selected_accept_filter, 0);
if (selected_accept_filter < 0)
return;
// Verify param: callback; type: refptr_diff
DCHECK(callback.get());
if (!callback.get())
return;
// Unverified params: title, default_file_name, accept_types
// Unverified params: title, default_file_path, accept_filters
// Translate param: accept_types; type: string_vec_byref_const
cef_string_list_t accept_typesList = cef_string_list_alloc();
DCHECK(accept_typesList);
if (accept_typesList)
transfer_string_list_contents(accept_types, accept_typesList);
// Translate param: accept_filters; type: string_vec_byref_const
cef_string_list_t accept_filtersList = cef_string_list_alloc();
DCHECK(accept_filtersList);
if (accept_filtersList)
transfer_string_list_contents(accept_filters, accept_filtersList);
// Execute
struct_->run_file_dialog(struct_,
mode,
title.GetStruct(),
default_file_name.GetStruct(),
accept_typesList,
default_file_path.GetStruct(),
accept_filtersList,
selected_accept_filter,
CefRunFileDialogCallbackCppToC::Wrap(callback));
// Restore param:accept_types; type: string_vec_byref_const
if (accept_typesList)
cef_string_list_free(accept_typesList);
// Restore param:accept_filters; type: string_vec_byref_const
if (accept_filtersList)
cef_string_list_free(accept_filtersList);
}
void CefBrowserHostCToCpp::StartDownload(const CefString& url) {

View File

@@ -47,8 +47,8 @@ class CefBrowserHostCToCpp
virtual double GetZoomLevel() OVERRIDE;
virtual void SetZoomLevel(double zoomLevel) OVERRIDE;
virtual void RunFileDialog(FileDialogMode mode, const CefString& title,
const CefString& default_file_name,
const std::vector<CefString>& accept_types,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters, int selected_accept_filter,
CefRefPtr<CefRunFileDialogCallback> callback) OVERRIDE;
virtual void StartDownload(const CefString& url) OVERRIDE;
virtual void Print() OVERRIDE;

View File

@@ -20,8 +20,8 @@
bool CefDialogHandlerCToCpp::OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode, const CefString& title,
const CefString& default_file_name,
const std::vector<CefString>& accept_types,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters, int selected_accept_filter,
CefRefPtr<CefFileDialogCallback> callback) {
if (CEF_MEMBER_MISSING(struct_, on_file_dialog))
return false;
@@ -32,30 +32,35 @@ bool CefDialogHandlerCToCpp::OnFileDialog(CefRefPtr<CefBrowser> browser,
DCHECK(browser.get());
if (!browser.get())
return false;
// Verify param: selected_accept_filter; type: simple_byval
DCHECK_GE(selected_accept_filter, 0);
if (selected_accept_filter < 0)
return false;
// Verify param: callback; type: refptr_diff
DCHECK(callback.get());
if (!callback.get())
return false;
// Unverified params: title, default_file_name, accept_types
// Unverified params: title, default_file_path, accept_filters
// Translate param: accept_types; type: string_vec_byref_const
cef_string_list_t accept_typesList = cef_string_list_alloc();
DCHECK(accept_typesList);
if (accept_typesList)
transfer_string_list_contents(accept_types, accept_typesList);
// Translate param: accept_filters; type: string_vec_byref_const
cef_string_list_t accept_filtersList = cef_string_list_alloc();
DCHECK(accept_filtersList);
if (accept_filtersList)
transfer_string_list_contents(accept_filters, accept_filtersList);
// Execute
int _retval = struct_->on_file_dialog(struct_,
CefBrowserCppToC::Wrap(browser),
mode,
title.GetStruct(),
default_file_name.GetStruct(),
accept_typesList,
default_file_path.GetStruct(),
accept_filtersList,
selected_accept_filter,
CefFileDialogCallbackCppToC::Wrap(callback));
// Restore param:accept_types; type: string_vec_byref_const
if (accept_typesList)
cef_string_list_free(accept_typesList);
// Restore param:accept_filters; type: string_vec_byref_const
if (accept_filtersList)
cef_string_list_free(accept_filtersList);
// Return type: bool
return _retval?true:false;

View File

@@ -35,8 +35,8 @@ class CefDialogHandlerCToCpp
// CefDialogHandler methods
bool OnFileDialog(CefRefPtr<CefBrowser> browser, FileDialogMode mode,
const CefString& title, const CefString& default_file_name,
const std::vector<CefString>& accept_types,
const CefString& title, const CefString& default_file_path,
const std::vector<CefString>& accept_filters, int selected_accept_filter,
CefRefPtr<CefFileDialogCallback> callback) override;
};

View File

@@ -16,13 +16,19 @@
// VIRTUAL METHODS - Body may be edited by hand.
void CefFileDialogCallbackCToCpp::Continue(
void CefFileDialogCallbackCToCpp::Continue(int selected_accept_filter,
const std::vector<CefString>& file_paths) {
if (CEF_MEMBER_MISSING(struct_, cont))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: selected_accept_filter; type: simple_byval
DCHECK_GE(selected_accept_filter, 0);
if (selected_accept_filter < 0)
return;
// Unverified params: file_paths
// Translate param: file_paths; type: string_vec_byref_const
cef_string_list_t file_pathsList = cef_string_list_alloc();
DCHECK(file_pathsList);
@@ -31,6 +37,7 @@ void CefFileDialogCallbackCToCpp::Continue(
// Execute
struct_->cont(struct_,
selected_accept_filter,
file_pathsList);
// Restore param:file_paths; type: string_vec_byref_const

View File

@@ -34,7 +34,8 @@ class CefFileDialogCallbackCToCpp
cef_file_dialog_callback_t>(str) {}
// CefFileDialogCallback methods
virtual void Continue(const std::vector<CefString>& file_paths) OVERRIDE;
virtual void Continue(int selected_accept_filter,
const std::vector<CefString>& file_paths) OVERRIDE;
virtual void Cancel() OVERRIDE;
};

View File

@@ -10,7 +10,6 @@
// for more information.
//
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
#include "libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h"
#include "libcef_dll/transfer_util.h"
@@ -18,17 +17,17 @@
// VIRTUAL METHODS - Body may be edited by hand.
void CefRunFileDialogCallbackCToCpp::OnFileDialogDismissed(
CefRefPtr<CefBrowserHost> browser_host,
const std::vector<CefString>& file_paths) {
if (CEF_MEMBER_MISSING(struct_, cont))
int selected_accept_filter, const std::vector<CefString>& file_paths) {
if (CEF_MEMBER_MISSING(struct_, on_file_dialog_dismissed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser_host; type: refptr_diff
DCHECK(browser_host.get());
if (!browser_host.get())
// Verify param: selected_accept_filter; type: simple_byval
DCHECK_GE(selected_accept_filter, 0);
if (selected_accept_filter < 0)
return;
// Unverified params: file_paths
// Translate param: file_paths; type: string_vec_byref_const
cef_string_list_t file_pathsList = cef_string_list_alloc();
@@ -37,8 +36,8 @@ void CefRunFileDialogCallbackCToCpp::OnFileDialogDismissed(
transfer_string_list_contents(file_paths, file_pathsList);
// Execute
struct_->cont(struct_,
CefBrowserHostCppToC::Wrap(browser_host),
struct_->on_file_dialog_dismissed(struct_,
selected_accept_filter,
file_pathsList);
// Restore param:file_paths; type: string_vec_byref_const

View File

@@ -36,7 +36,7 @@ class CefRunFileDialogCallbackCToCpp
cef_run_file_dialog_callback_t>(str) {}
// CefRunFileDialogCallback methods
void OnFileDialogDismissed(CefRefPtr<CefBrowserHost> browser_host,
void OnFileDialogDismissed(int selected_accept_filter,
const std::vector<CefString>& file_paths) override;
};