- Add download handling support via new CefDownloadHandler and CefDownloadItem interfaces (issue #516).

- Fix setting of CefKeyEvent.focus_on_editable_field when the underlying RenderViewHost changes.
- Fix potential crash if URLRequest objects are still in-progress upon shutdown.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@715 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-06-28 17:21:18 +00:00
parent 14bbc90ddb
commit 421001ba9d
51 changed files with 2685 additions and 171 deletions

View File

@ -0,0 +1,52 @@
// 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/before_download_callback_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK before_download_callback_cont(
struct _cef_before_download_callback_t* self,
const cef_string_t* download_path, int show_dialog) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: download_path; type: string_byref_const
DCHECK(download_path);
if (!download_path)
return;
// Execute
CefBeforeDownloadCallbackCppToC::Get(self)->Continue(
CefString(download_path),
show_dialog?true:false);
}
// CONSTRUCTOR - Do not edit by hand.
CefBeforeDownloadCallbackCppToC::CefBeforeDownloadCallbackCppToC(
CefBeforeDownloadCallback* cls)
: CefCppToC<CefBeforeDownloadCallbackCppToC, CefBeforeDownloadCallback,
cef_before_download_callback_t>(cls) {
struct_.struct_.cont = before_download_callback_cont;
}
#ifndef NDEBUG
template<> long CefCppToC<CefBeforeDownloadCallbackCppToC,
CefBeforeDownloadCallback, cef_before_download_callback_t>::DebugObjCt =
0;
#endif

View 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_BEFORE_DOWNLOAD_CALLBACK_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_BEFORE_DOWNLOAD_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_download_handler.h"
#include "include/capi/cef_download_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 CefBeforeDownloadCallbackCppToC
: public CefCppToC<CefBeforeDownloadCallbackCppToC,
CefBeforeDownloadCallback, cef_before_download_callback_t> {
public:
explicit CefBeforeDownloadCallbackCppToC(CefBeforeDownloadCallback* cls);
virtual ~CefBeforeDownloadCallbackCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_BEFORE_DOWNLOAD_CALLBACK_CPPTOC_H_

View File

@ -13,6 +13,7 @@
#include "libcef_dll/cpptoc/client_cpptoc.h"
#include "libcef_dll/cpptoc/context_menu_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"
#include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h"
#include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h"
@ -58,6 +59,22 @@ struct _cef_display_handler_t* CEF_CALLBACK client_get_display_handler(
return CefDisplayHandlerCppToC::Wrap(_retval);
}
struct _cef_download_handler_t* CEF_CALLBACK client_get_download_handler(
struct _cef_client_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefDownloadHandler> _retval = CefClientCppToC::Get(
self)->GetDownloadHandler();
// Return type: refptr_same
return CefDownloadHandlerCppToC::Wrap(_retval);
}
struct _cef_focus_handler_t* CEF_CALLBACK client_get_focus_handler(
struct _cef_client_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -204,6 +221,7 @@ 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_display_handler = client_get_display_handler;
struct_.struct_.get_download_handler = client_get_download_handler;
struct_.struct_.get_focus_handler = client_get_focus_handler;
struct_.struct_.get_geolocation_handler = client_get_geolocation_handler;
struct_.struct_.get_jsdialog_handler = client_get_jsdialog_handler;

View File

@ -0,0 +1,100 @@
// 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/download_handler_cpptoc.h"
#include "libcef_dll/ctocpp/before_download_callback_ctocpp.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/download_item_ctocpp.h"
#include "libcef_dll/ctocpp/download_item_callback_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK download_handler_on_before_download(
struct _cef_download_handler_t* self, cef_browser_t* browser,
struct _cef_download_item_t* download_item,
const cef_string_t* suggested_name,
cef_before_download_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: download_item; type: refptr_diff
DCHECK(download_item);
if (!download_item)
return;
// Verify param: suggested_name; type: string_byref_const
DCHECK(suggested_name);
if (!suggested_name)
return;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
return;
// Execute
CefDownloadHandlerCppToC::Get(self)->OnBeforeDownload(
CefBrowserCToCpp::Wrap(browser),
CefDownloadItemCToCpp::Wrap(download_item),
CefString(suggested_name),
CefBeforeDownloadCallbackCToCpp::Wrap(callback));
}
void CEF_CALLBACK download_handler_on_download_updated(
struct _cef_download_handler_t* self, cef_browser_t* browser,
struct _cef_download_item_t* download_item,
cef_download_item_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Verify param: download_item; type: refptr_diff
DCHECK(download_item);
if (!download_item)
return;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
return;
// Execute
CefDownloadHandlerCppToC::Get(self)->OnDownloadUpdated(
CefBrowserCToCpp::Wrap(browser),
CefDownloadItemCToCpp::Wrap(download_item),
CefDownloadItemCallbackCToCpp::Wrap(callback));
}
// CONSTRUCTOR - Do not edit by hand.
CefDownloadHandlerCppToC::CefDownloadHandlerCppToC(CefDownloadHandler* cls)
: CefCppToC<CefDownloadHandlerCppToC, CefDownloadHandler,
cef_download_handler_t>(cls) {
struct_.struct_.on_before_download = download_handler_on_before_download;
struct_.struct_.on_download_updated = download_handler_on_download_updated;
}
#ifndef NDEBUG
template<> long CefCppToC<CefDownloadHandlerCppToC, CefDownloadHandler,
cef_download_handler_t>::DebugObjCt = 0;
#endif

View 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_DOWNLOAD_HANDLER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_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_download_handler.h"
#include "include/capi/cef_download_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 CefDownloadHandlerCppToC
: public CefCppToC<CefDownloadHandlerCppToC, CefDownloadHandler,
cef_download_handler_t> {
public:
explicit CefDownloadHandlerCppToC(CefDownloadHandler* cls);
virtual ~CefDownloadHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_HANDLER_CPPTOC_H_

View 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.
//
#include "libcef_dll/cpptoc/download_item_callback_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK download_item_callback_cancel(
struct _cef_download_item_callback_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefDownloadItemCallbackCppToC::Get(self)->Cancel();
}
// CONSTRUCTOR - Do not edit by hand.
CefDownloadItemCallbackCppToC::CefDownloadItemCallbackCppToC(
CefDownloadItemCallback* cls)
: CefCppToC<CefDownloadItemCallbackCppToC, CefDownloadItemCallback,
cef_download_item_callback_t>(cls) {
struct_.struct_.cancel = download_item_callback_cancel;
}
#ifndef NDEBUG
template<> long CefCppToC<CefDownloadItemCallbackCppToC,
CefDownloadItemCallback, cef_download_item_callback_t>::DebugObjCt = 0;
#endif

View 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_DOWNLOAD_ITEM_CALLBACK_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_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_download_handler.h"
#include "include/capi/cef_download_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 CefDownloadItemCallbackCppToC
: public CefCppToC<CefDownloadItemCallbackCppToC, CefDownloadItemCallback,
cef_download_item_callback_t> {
public:
explicit CefDownloadItemCallbackCppToC(CefDownloadItemCallback* cls);
virtual ~CefDownloadItemCallbackCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CALLBACK_CPPTOC_H_

View File

@ -0,0 +1,300 @@
// 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/download_item_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK download_item_is_valid(struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefDownloadItemCppToC::Get(self)->IsValid();
// Return type: bool
return _retval;
}
int CEF_CALLBACK download_item_is_in_progress(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefDownloadItemCppToC::Get(self)->IsInProgress();
// Return type: bool
return _retval;
}
int CEF_CALLBACK download_item_is_complete(struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefDownloadItemCppToC::Get(self)->IsComplete();
// Return type: bool
return _retval;
}
int CEF_CALLBACK download_item_is_canceled(struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefDownloadItemCppToC::Get(self)->IsCanceled();
// Return type: bool
return _retval;
}
int64 CEF_CALLBACK download_item_get_current_speed(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int64 _retval = CefDownloadItemCppToC::Get(self)->GetCurrentSpeed();
// Return type: simple
return _retval;
}
int CEF_CALLBACK download_item_get_percent_complete(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int _retval = CefDownloadItemCppToC::Get(self)->GetPercentComplete();
// Return type: simple
return _retval;
}
int64 CEF_CALLBACK download_item_get_total_bytes(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int64 _retval = CefDownloadItemCppToC::Get(self)->GetTotalBytes();
// Return type: simple
return _retval;
}
int64 CEF_CALLBACK download_item_get_received_bytes(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int64 _retval = CefDownloadItemCppToC::Get(self)->GetReceivedBytes();
// Return type: simple
return _retval;
}
cef_time_t CEF_CALLBACK download_item_get_start_time(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CefTime();
// Execute
cef_time_t _retval = CefDownloadItemCppToC::Get(self)->GetStartTime();
// Return type: simple
return _retval;
}
cef_time_t CEF_CALLBACK download_item_get_end_time(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CefTime();
// Execute
cef_time_t _retval = CefDownloadItemCppToC::Get(self)->GetEndTime();
// Return type: simple
return _retval;
}
cef_string_userfree_t CEF_CALLBACK download_item_get_full_path(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefDownloadItemCppToC::Get(self)->GetFullPath();
// Return type: string
return _retval.DetachToUserFree();
}
int32 CEF_CALLBACK download_item_get_id(struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
int32 _retval = CefDownloadItemCppToC::Get(self)->GetId();
// Return type: simple
return _retval;
}
cef_string_userfree_t CEF_CALLBACK download_item_get_url(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefDownloadItemCppToC::Get(self)->GetURL();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK download_item_get_suggested_file_name(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefDownloadItemCppToC::Get(self)->GetSuggestedFileName();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK download_item_get_content_disposition(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefDownloadItemCppToC::Get(self)->GetContentDisposition();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK download_item_get_mime_type(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefDownloadItemCppToC::Get(self)->GetMimeType();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK download_item_get_referrer_charset(
struct _cef_download_item_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefDownloadItemCppToC::Get(self)->GetReferrerCharset();
// Return type: string
return _retval.DetachToUserFree();
}
// CONSTRUCTOR - Do not edit by hand.
CefDownloadItemCppToC::CefDownloadItemCppToC(CefDownloadItem* cls)
: CefCppToC<CefDownloadItemCppToC, CefDownloadItem, cef_download_item_t>(
cls) {
struct_.struct_.is_valid = download_item_is_valid;
struct_.struct_.is_in_progress = download_item_is_in_progress;
struct_.struct_.is_complete = download_item_is_complete;
struct_.struct_.is_canceled = download_item_is_canceled;
struct_.struct_.get_current_speed = download_item_get_current_speed;
struct_.struct_.get_percent_complete = download_item_get_percent_complete;
struct_.struct_.get_total_bytes = download_item_get_total_bytes;
struct_.struct_.get_received_bytes = download_item_get_received_bytes;
struct_.struct_.get_start_time = download_item_get_start_time;
struct_.struct_.get_end_time = download_item_get_end_time;
struct_.struct_.get_full_path = download_item_get_full_path;
struct_.struct_.get_id = download_item_get_id;
struct_.struct_.get_url = download_item_get_url;
struct_.struct_.get_suggested_file_name =
download_item_get_suggested_file_name;
struct_.struct_.get_content_disposition =
download_item_get_content_disposition;
struct_.struct_.get_mime_type = download_item_get_mime_type;
struct_.struct_.get_referrer_charset = download_item_get_referrer_charset;
}
#ifndef NDEBUG
template<> long CefCppToC<CefDownloadItemCppToC, CefDownloadItem,
cef_download_item_t>::DebugObjCt = 0;
#endif

View 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_DOWNLOAD_ITEM_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_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_download_item.h"
#include "include/capi/cef_download_item_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 CefDownloadItemCppToC
: public CefCppToC<CefDownloadItemCppToC, CefDownloadItem,
cef_download_item_t> {
public:
explicit CefDownloadItemCppToC(CefDownloadItem* cls);
virtual ~CefDownloadItemCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_DOWNLOAD_ITEM_CPPTOC_H_