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:
@@ -11,8 +11,10 @@
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// STATIC METHODS - Body may be edited by hand.
|
||||
@@ -187,6 +189,40 @@ void CefBrowserHostCToCpp::SetZoomLevel(double zoomLevel) {
|
||||
zoomLevel);
|
||||
}
|
||||
|
||||
void CefBrowserHostCToCpp::RunFileDialog(FileDialogMode mode,
|
||||
const CefString& title, const CefString& default_file_name,
|
||||
const std::vector<CefString>& accept_types,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) {
|
||||
if (CEF_MEMBER_MISSING(struct_, run_file_dialog))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: callback; type: refptr_diff
|
||||
DCHECK(callback.get());
|
||||
if (!callback.get())
|
||||
return;
|
||||
// Unverified params: title, default_file_name, accept_types
|
||||
|
||||
// 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);
|
||||
|
||||
// Execute
|
||||
struct_->run_file_dialog(struct_,
|
||||
mode,
|
||||
title.GetStruct(),
|
||||
default_file_name.GetStruct(),
|
||||
accept_typesList,
|
||||
CefRunFileDialogCallbackCppToC::Wrap(callback));
|
||||
|
||||
// Restore param:accept_types; type: string_vec_byref_const
|
||||
if (accept_typesList)
|
||||
cef_string_list_free(accept_typesList);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefBrowserHostCToCpp, CefBrowserHost,
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include <vector>
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/cef_client.h"
|
||||
@@ -46,6 +47,10 @@ class CefBrowserHostCToCpp
|
||||
virtual CefString GetDevToolsURL(bool http_scheme) OVERRIDE;
|
||||
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,
|
||||
CefRefPtr<CefRunFileDialogCallback> callback) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/context_menu_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/dialog_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/display_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/download_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/focus_handler_ctocpp.h"
|
||||
@@ -41,6 +42,19 @@ CefRefPtr<CefContextMenuHandler> CefClientCToCpp::GetContextMenuHandler() {
|
||||
return CefContextMenuHandlerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDialogHandler> CefClientCToCpp::GetDialogHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_dialog_handler))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_dialog_handler_t* _retval = struct_->get_dialog_handler(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDialogHandlerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDisplayHandler> CefClientCToCpp::GetDisplayHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_display_handler))
|
||||
return NULL;
|
||||
|
@@ -33,6 +33,7 @@ class CefClientCToCpp
|
||||
|
||||
// CefClient methods
|
||||
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefDialogHandler> GetDialogHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE;
|
||||
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE;
|
||||
|
69
libcef_dll/ctocpp/dialog_handler_ctocpp.cc
Normal file
69
libcef_dll/ctocpp/dialog_handler_ctocpp.cc
Normal file
@@ -0,0 +1,69 @@
|
||||
// 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/browser_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/file_dialog_callback_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/dialog_handler_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefDialogHandlerCToCpp::OnFileDialog(CefRefPtr<CefBrowser> browser,
|
||||
FileDialogMode mode, const CefString& title,
|
||||
const CefString& default_file_name,
|
||||
const std::vector<CefString>& accept_types,
|
||||
CefRefPtr<CefFileDialogCallback> callback) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_file_dialog))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return false;
|
||||
// Verify param: callback; type: refptr_diff
|
||||
DCHECK(callback.get());
|
||||
if (!callback.get())
|
||||
return false;
|
||||
// Unverified params: title, default_file_name, accept_types
|
||||
|
||||
// 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);
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->on_file_dialog(struct_,
|
||||
CefBrowserCppToC::Wrap(browser),
|
||||
mode,
|
||||
title.GetStruct(),
|
||||
default_file_name.GetStruct(),
|
||||
accept_typesList,
|
||||
CefFileDialogCallbackCppToC::Wrap(callback));
|
||||
|
||||
// Restore param:accept_types; type: string_vec_byref_const
|
||||
if (accept_typesList)
|
||||
cef_string_list_free(accept_typesList);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefDialogHandlerCToCpp, CefDialogHandler,
|
||||
cef_dialog_handler_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
46
libcef_dll/ctocpp/dialog_handler_ctocpp.h
Normal file
46
libcef_dll/ctocpp/dialog_handler_ctocpp.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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_CTOCPP_DIALOG_HANDLER_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_DIALOG_HANDLER_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include <vector>
|
||||
#include "include/cef_dialog_handler.h"
|
||||
#include "include/capi/cef_dialog_handler_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefDialogHandlerCToCpp
|
||||
: public CefCToCpp<CefDialogHandlerCToCpp, CefDialogHandler,
|
||||
cef_dialog_handler_t> {
|
||||
public:
|
||||
explicit CefDialogHandlerCToCpp(cef_dialog_handler_t* str)
|
||||
: CefCToCpp<CefDialogHandlerCToCpp, CefDialogHandler,
|
||||
cef_dialog_handler_t>(str) {}
|
||||
virtual ~CefDialogHandlerCToCpp() {}
|
||||
|
||||
// CefDialogHandler methods
|
||||
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser, FileDialogMode mode,
|
||||
const CefString& title, const CefString& default_file_name,
|
||||
const std::vector<CefString>& accept_types,
|
||||
CefRefPtr<CefFileDialogCallback> callback) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_DIALOG_HANDLER_CTOCPP_H_
|
||||
|
56
libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc
Normal file
56
libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc
Normal file
@@ -0,0 +1,56 @@
|
||||
// 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/ctocpp/file_dialog_callback_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
void CefFileDialogCallbackCToCpp::Continue(
|
||||
const std::vector<CefString>& file_paths) {
|
||||
if (CEF_MEMBER_MISSING(struct_, cont))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Translate param: file_paths; type: string_vec_byref_const
|
||||
cef_string_list_t file_pathsList = cef_string_list_alloc();
|
||||
DCHECK(file_pathsList);
|
||||
if (file_pathsList)
|
||||
transfer_string_list_contents(file_paths, file_pathsList);
|
||||
|
||||
// Execute
|
||||
struct_->cont(struct_,
|
||||
file_pathsList);
|
||||
|
||||
// Restore param:file_paths; type: string_vec_byref_const
|
||||
if (file_pathsList)
|
||||
cef_string_list_free(file_pathsList);
|
||||
}
|
||||
|
||||
void CefFileDialogCallbackCToCpp::Cancel() {
|
||||
if (CEF_MEMBER_MISSING(struct_, cancel))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
struct_->cancel(struct_);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefFileDialogCallbackCToCpp, CefFileDialogCallback,
|
||||
cef_file_dialog_callback_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
44
libcef_dll/ctocpp/file_dialog_callback_ctocpp.h
Normal file
44
libcef_dll/ctocpp/file_dialog_callback_ctocpp.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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_CTOCPP_FILE_DIALOG_CALLBACK_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_FILE_DIALOG_CALLBACK_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include <vector>
|
||||
#include "include/cef_dialog_handler.h"
|
||||
#include "include/capi/cef_dialog_handler_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefFileDialogCallbackCToCpp
|
||||
: public CefCToCpp<CefFileDialogCallbackCToCpp, CefFileDialogCallback,
|
||||
cef_file_dialog_callback_t> {
|
||||
public:
|
||||
explicit CefFileDialogCallbackCToCpp(cef_file_dialog_callback_t* str)
|
||||
: CefCToCpp<CefFileDialogCallbackCToCpp, CefFileDialogCallback,
|
||||
cef_file_dialog_callback_t>(str) {}
|
||||
virtual ~CefFileDialogCallbackCToCpp() {}
|
||||
|
||||
// CefFileDialogCallback methods
|
||||
virtual void Continue(const std::vector<CefString>& file_paths) OVERRIDE;
|
||||
virtual void Cancel() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_FILE_DIALOG_CALLBACK_CTOCPP_H_
|
||||
|
54
libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc
Normal file
54
libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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/browser_host_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
// 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))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser_host; type: refptr_diff
|
||||
DCHECK(browser_host.get());
|
||||
if (!browser_host.get())
|
||||
return;
|
||||
|
||||
// Translate param: file_paths; type: string_vec_byref_const
|
||||
cef_string_list_t file_pathsList = cef_string_list_alloc();
|
||||
DCHECK(file_pathsList);
|
||||
if (file_pathsList)
|
||||
transfer_string_list_contents(file_paths, file_pathsList);
|
||||
|
||||
// Execute
|
||||
struct_->cont(struct_,
|
||||
CefBrowserHostCppToC::Wrap(browser_host),
|
||||
file_pathsList);
|
||||
|
||||
// Restore param:file_paths; type: string_vec_byref_const
|
||||
if (file_pathsList)
|
||||
cef_string_list_free(file_pathsList);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefRunFileDialogCallbackCToCpp,
|
||||
CefRunFileDialogCallback, cef_run_file_dialog_callback_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
46
libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h
Normal file
46
libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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_CTOCPP_RUN_FILE_DIALOG_CALLBACK_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_RUN_FILE_DIALOG_CALLBACK_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include <vector>
|
||||
#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/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefRunFileDialogCallbackCToCpp
|
||||
: public CefCToCpp<CefRunFileDialogCallbackCToCpp, CefRunFileDialogCallback,
|
||||
cef_run_file_dialog_callback_t> {
|
||||
public:
|
||||
explicit CefRunFileDialogCallbackCToCpp(cef_run_file_dialog_callback_t* str)
|
||||
: CefCToCpp<CefRunFileDialogCallbackCToCpp, CefRunFileDialogCallback,
|
||||
cef_run_file_dialog_callback_t>(str) {}
|
||||
virtual ~CefRunFileDialogCallbackCToCpp() {}
|
||||
|
||||
// CefRunFileDialogCallback methods
|
||||
virtual void OnFileDialogDismissed(CefRefPtr<CefBrowserHost> browser_host,
|
||||
const std::vector<CefString>& file_paths) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_RUN_FILE_DIALOG_CALLBACK_CTOCPP_H_
|
||||
|
Reference in New Issue
Block a user