mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Provide default implementations of the file chooser dialogs (open, open multiple, save) on all platforms (issue #761).
- Add a new CefBrowserHost::RunFileDialog method that displays the specified file chooser dialog and returns the results asynchronously (issue #761). - Add a new CefDialogHandler::OnFileDialog callback that allows the application to provide custom UI for file chooser dialogs (issue #761). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@862 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -13,6 +13,8 @@
|
||||
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// GLOBAL FUNCTIONS - Body may be edited by hand.
|
||||
@ -240,6 +242,34 @@ void CEF_CALLBACK browser_host_set_zoom_level(struct _cef_browser_host_t* self,
|
||||
zoomLevel);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK browser_host_run_file_dialog(struct _cef_browser_host_t* self,
|
||||
enum cef_file_dialog_mode_t mode, const cef_string_t* title,
|
||||
const cef_string_t* default_file_name, cef_string_list_t accept_types,
|
||||
cef_run_file_dialog_callback_t* callback) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: callback; type: refptr_diff
|
||||
DCHECK(callback);
|
||||
if (!callback)
|
||||
return;
|
||||
// Unverified params: title, default_file_name, accept_types
|
||||
|
||||
// Translate param: accept_types; type: string_vec_byref_const
|
||||
std::vector<CefString> accept_typesList;
|
||||
transfer_string_list_contents(accept_types, accept_typesList);
|
||||
|
||||
// Execute
|
||||
CefBrowserHostCppToC::Get(self)->RunFileDialog(
|
||||
mode,
|
||||
CefString(title),
|
||||
CefString(default_file_name),
|
||||
accept_typesList,
|
||||
CefRunFileDialogCallbackCToCpp::Wrap(callback));
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
@ -257,6 +287,7 @@ CefBrowserHostCppToC::CefBrowserHostCppToC(CefBrowserHost* cls)
|
||||
struct_.struct_.get_dev_tools_url = browser_host_get_dev_tools_url;
|
||||
struct_.struct_.get_zoom_level = browser_host_get_zoom_level;
|
||||
struct_.struct_.set_zoom_level = browser_host_set_zoom_level;
|
||||
struct_.struct_.run_file_dialog = browser_host_run_file_dialog;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/context_menu_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/dialog_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/display_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/download_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/focus_handler_cpptoc.h"
|
||||
@ -43,6 +44,22 @@ struct _cef_context_menu_handler_t* CEF_CALLBACK client_get_context_menu_handler
|
||||
return CefContextMenuHandlerCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_dialog_handler_t* CEF_CALLBACK client_get_dialog_handler(
|
||||
struct _cef_client_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefDialogHandler> _retval = CefClientCppToC::Get(
|
||||
self)->GetDialogHandler();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDialogHandlerCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
struct _cef_display_handler_t* CEF_CALLBACK client_get_display_handler(
|
||||
struct _cef_client_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -220,6 +237,7 @@ int CEF_CALLBACK client_on_process_message_received(struct _cef_client_t* self,
|
||||
CefClientCppToC::CefClientCppToC(CefClient* cls)
|
||||
: CefCppToC<CefClientCppToC, CefClient, cef_client_t>(cls) {
|
||||
struct_.struct_.get_context_menu_handler = client_get_context_menu_handler;
|
||||
struct_.struct_.get_dialog_handler = client_get_dialog_handler;
|
||||
struct_.struct_.get_display_handler = client_get_display_handler;
|
||||
struct_.struct_.get_download_handler = client_get_download_handler;
|
||||
struct_.struct_.get_focus_handler = client_get_focus_handler;
|
||||
|
71
libcef_dll/cpptoc/dialog_handler_cpptoc.cc
Normal file
71
libcef_dll/cpptoc/dialog_handler_cpptoc.cc
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/dialog_handler_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/file_dialog_callback_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK dialog_handler_on_file_dialog(
|
||||
struct _cef_dialog_handler_t* self, cef_browser_t* browser,
|
||||
enum cef_file_dialog_mode_t mode, const cef_string_t* title,
|
||||
const cef_string_t* default_file_name, cef_string_list_t accept_types,
|
||||
cef_file_dialog_callback_t* callback) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser)
|
||||
return 0;
|
||||
// Verify param: callback; type: refptr_diff
|
||||
DCHECK(callback);
|
||||
if (!callback)
|
||||
return 0;
|
||||
// Unverified params: title, default_file_name, accept_types
|
||||
|
||||
// Translate param: accept_types; type: string_vec_byref_const
|
||||
std::vector<CefString> accept_typesList;
|
||||
transfer_string_list_contents(accept_types, accept_typesList);
|
||||
|
||||
// Execute
|
||||
bool _retval = CefDialogHandlerCppToC::Get(self)->OnFileDialog(
|
||||
CefBrowserCToCpp::Wrap(browser),
|
||||
mode,
|
||||
CefString(title),
|
||||
CefString(default_file_name),
|
||||
accept_typesList,
|
||||
CefFileDialogCallbackCToCpp::Wrap(callback));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefDialogHandlerCppToC::CefDialogHandlerCppToC(CefDialogHandler* cls)
|
||||
: CefCppToC<CefDialogHandlerCppToC, CefDialogHandler, cef_dialog_handler_t>(
|
||||
cls) {
|
||||
struct_.struct_.on_file_dialog = dialog_handler_on_file_dialog;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefDialogHandlerCppToC, CefDialogHandler,
|
||||
cef_dialog_handler_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
37
libcef_dll/cpptoc/dialog_handler_cpptoc.h
Normal file
37
libcef_dll/cpptoc/dialog_handler_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_DIALOG_HANDLER_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_DIALOG_HANDLER_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dialog_handler.h"
|
||||
#include "include/capi/cef_dialog_handler_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefDialogHandlerCppToC
|
||||
: public CefCppToC<CefDialogHandlerCppToC, CefDialogHandler,
|
||||
cef_dialog_handler_t> {
|
||||
public:
|
||||
explicit CefDialogHandlerCppToC(CefDialogHandler* cls);
|
||||
virtual ~CefDialogHandlerCppToC() {}
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_DIALOG_HANDLER_CPPTOC_H_
|
||||
|
67
libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc
Normal file
67
libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/file_dialog_callback_cpptoc.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
void CEF_CALLBACK file_dialog_callback_cont(
|
||||
struct _cef_file_dialog_callback_t* self, cef_string_list_t file_paths) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: file_paths; type: string_vec_byref_const
|
||||
DCHECK(file_paths);
|
||||
if (!file_paths)
|
||||
return;
|
||||
|
||||
// Translate param: file_paths; type: string_vec_byref_const
|
||||
std::vector<CefString> file_pathsList;
|
||||
transfer_string_list_contents(file_paths, file_pathsList);
|
||||
|
||||
// Execute
|
||||
CefFileDialogCallbackCppToC::Get(self)->Continue(
|
||||
file_pathsList);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK file_dialog_callback_cancel(
|
||||
struct _cef_file_dialog_callback_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefFileDialogCallbackCppToC::Get(self)->Cancel();
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefFileDialogCallbackCppToC::CefFileDialogCallbackCppToC(
|
||||
CefFileDialogCallback* cls)
|
||||
: CefCppToC<CefFileDialogCallbackCppToC, CefFileDialogCallback,
|
||||
cef_file_dialog_callback_t>(cls) {
|
||||
struct_.struct_.cont = file_dialog_callback_cont;
|
||||
struct_.struct_.cancel = file_dialog_callback_cancel;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefFileDialogCallbackCppToC, CefFileDialogCallback,
|
||||
cef_file_dialog_callback_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
37
libcef_dll/cpptoc/file_dialog_callback_cpptoc.h
Normal file
37
libcef_dll/cpptoc/file_dialog_callback_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_FILE_DIALOG_CALLBACK_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_FILE_DIALOG_CALLBACK_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_dialog_handler.h"
|
||||
#include "include/capi/cef_dialog_handler_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefFileDialogCallbackCppToC
|
||||
: public CefCppToC<CefFileDialogCallbackCppToC, CefFileDialogCallback,
|
||||
cef_file_dialog_callback_t> {
|
||||
public:
|
||||
explicit CefFileDialogCallbackCppToC(CefFileDialogCallback* cls);
|
||||
virtual ~CefFileDialogCallbackCppToC() {}
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_FILE_DIALOG_CALLBACK_CPPTOC_H_
|
||||
|
61
libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc
Normal file
61
libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
void CEF_CALLBACK run_file_dialog_callback_cont(
|
||||
struct _cef_run_file_dialog_callback_t* self,
|
||||
struct _cef_browser_host_t* browser_host, cef_string_list_t file_paths) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: browser_host; type: refptr_diff
|
||||
DCHECK(browser_host);
|
||||
if (!browser_host)
|
||||
return;
|
||||
// Verify param: file_paths; type: string_vec_byref_const
|
||||
DCHECK(file_paths);
|
||||
if (!file_paths)
|
||||
return;
|
||||
|
||||
// Translate param: file_paths; type: string_vec_byref_const
|
||||
std::vector<CefString> file_pathsList;
|
||||
transfer_string_list_contents(file_paths, file_pathsList);
|
||||
|
||||
// Execute
|
||||
CefRunFileDialogCallbackCppToC::Get(self)->OnFileDialogDismissed(
|
||||
CefBrowserHostCToCpp::Wrap(browser_host),
|
||||
file_pathsList);
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefRunFileDialogCallbackCppToC::CefRunFileDialogCallbackCppToC(
|
||||
CefRunFileDialogCallback* cls)
|
||||
: CefCppToC<CefRunFileDialogCallbackCppToC, CefRunFileDialogCallback,
|
||||
cef_run_file_dialog_callback_t>(cls) {
|
||||
struct_.struct_.cont = run_file_dialog_callback_cont;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCppToC<CefRunFileDialogCallbackCppToC,
|
||||
CefRunFileDialogCallback, cef_run_file_dialog_callback_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
39
libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h
Normal file
39
libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_RUN_FILE_DIALOG_CALLBACK_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_RUN_FILE_DIALOG_CALLBACK_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/cef_client.h"
|
||||
#include "include/capi/cef_client_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefRunFileDialogCallbackCppToC
|
||||
: public CefCppToC<CefRunFileDialogCallbackCppToC, CefRunFileDialogCallback,
|
||||
cef_run_file_dialog_callback_t> {
|
||||
public:
|
||||
explicit CefRunFileDialogCallbackCppToC(CefRunFileDialogCallback* cls);
|
||||
virtual ~CefRunFileDialogCallbackCppToC() {}
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_RUN_FILE_DIALOG_CALLBACK_CPPTOC_H_
|
||||
|
Reference in New Issue
Block a user