- Allow asynchronous continuation of OnBeforeResourceLoad (issue #1593).
- Use CefRequestCallback for most asynchronous CefRequestHandler methods.
This commit is contained in:
parent
0b795eed10
commit
fe03339870
|
@ -126,8 +126,6 @@
|
|||
'include/capi/cef_zip_reader_capi.h',
|
||||
],
|
||||
'autogen_library_side': [
|
||||
'libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h',
|
||||
'libcef_dll/ctocpp/app_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/app_ctocpp.h',
|
||||
'libcef_dll/cpptoc/auth_callback_cpptoc.cc',
|
||||
|
@ -228,8 +226,6 @@
|
|||
'libcef_dll/cpptoc/print_settings_cpptoc.h',
|
||||
'libcef_dll/cpptoc/process_message_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
||||
'libcef_dll/cpptoc/quota_callback_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/quota_callback_cpptoc.h',
|
||||
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
||||
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
|
||||
|
@ -238,6 +234,8 @@
|
|||
'libcef_dll/ctocpp/render_process_handler_ctocpp.h',
|
||||
'libcef_dll/cpptoc/request_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/request_cpptoc.h',
|
||||
'libcef_dll/cpptoc/request_callback_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/request_callback_cpptoc.h',
|
||||
'libcef_dll/cpptoc/request_context_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/request_context_cpptoc.h',
|
||||
'libcef_dll/ctocpp/request_context_handler_ctocpp.cc',
|
||||
|
@ -302,8 +300,6 @@
|
|||
'libcef_dll/cpptoc/zip_reader_cpptoc.h',
|
||||
],
|
||||
'autogen_client_side': [
|
||||
'libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h',
|
||||
'libcef_dll/cpptoc/app_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/app_cpptoc.h',
|
||||
'libcef_dll/ctocpp/auth_callback_ctocpp.cc',
|
||||
|
@ -404,8 +400,6 @@
|
|||
'libcef_dll/ctocpp/print_settings_ctocpp.h',
|
||||
'libcef_dll/ctocpp/process_message_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
||||
'libcef_dll/ctocpp/quota_callback_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/quota_callback_ctocpp.h',
|
||||
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
||||
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
|
||||
|
@ -414,6 +408,8 @@
|
|||
'libcef_dll/cpptoc/render_process_handler_cpptoc.h',
|
||||
'libcef_dll/ctocpp/request_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/request_ctocpp.h',
|
||||
'libcef_dll/ctocpp/request_callback_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/request_callback_ctocpp.h',
|
||||
'libcef_dll/ctocpp/request_context_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/request_context_ctocpp.h',
|
||||
'libcef_dll/cpptoc/request_context_handler_cpptoc.cc',
|
||||
|
|
|
@ -54,32 +54,9 @@ extern "C" {
|
|||
|
||||
|
||||
///
|
||||
// Callback structure used for asynchronous continuation of quota requests.
|
||||
// Callback structure used for asynchronous continuation of url requests.
|
||||
///
|
||||
typedef struct _cef_quota_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Continue the quota request. If |allow| is true (1) the request will be
|
||||
// allowed. Otherwise, the request will be denied.
|
||||
///
|
||||
void (CEF_CALLBACK *cont)(struct _cef_quota_callback_t* self, int allow);
|
||||
|
||||
///
|
||||
// Cancel the quota request.
|
||||
///
|
||||
void (CEF_CALLBACK *cancel)(struct _cef_quota_callback_t* self);
|
||||
} cef_quota_callback_t;
|
||||
|
||||
|
||||
///
|
||||
// Callback structure used for asynchronous continuation of url requests when
|
||||
// invalid SSL certificates are encountered.
|
||||
///
|
||||
typedef struct _cef_allow_certificate_error_callback_t {
|
||||
typedef struct _cef_request_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
|
@ -89,9 +66,13 @@ typedef struct _cef_allow_certificate_error_callback_t {
|
|||
// Continue the url request. If |allow| is true (1) the request will be
|
||||
// continued. Otherwise, the request will be canceled.
|
||||
///
|
||||
void (CEF_CALLBACK *cont)(
|
||||
struct _cef_allow_certificate_error_callback_t* self, int allow);
|
||||
} cef_allow_certificate_error_callback_t;
|
||||
void (CEF_CALLBACK *cont)(struct _cef_request_callback_t* self, int allow);
|
||||
|
||||
///
|
||||
// Cancel the url request.
|
||||
///
|
||||
void (CEF_CALLBACK *cancel)(struct _cef_request_callback_t* self);
|
||||
} cef_request_callback_t;
|
||||
|
||||
|
||||
///
|
||||
|
@ -120,12 +101,16 @@ typedef struct _cef_request_handler_t {
|
|||
|
||||
///
|
||||
// Called on the IO thread before a resource request is loaded. The |request|
|
||||
// object may be modified. To cancel the request return true (1) otherwise
|
||||
// return false (0).
|
||||
// object may be modified. Return RV_CONTINUE to continue the request
|
||||
// immediately. Return RV_CONTINUE_ASYNC and call cef_request_tCallback::
|
||||
// cont() at a later time to continue or cancel the request asynchronously.
|
||||
// Return RV_CANCEL to cancel the request immediately.
|
||||
//
|
||||
///
|
||||
int (CEF_CALLBACK *on_before_resource_load)(
|
||||
cef_return_value_t (CEF_CALLBACK *on_before_resource_load)(
|
||||
struct _cef_request_handler_t* self, struct _cef_browser_t* browser,
|
||||
struct _cef_frame_t* frame, struct _cef_request_t* request);
|
||||
struct _cef_frame_t* frame, struct _cef_request_t* request,
|
||||
struct _cef_request_callback_t* callback);
|
||||
|
||||
///
|
||||
// Called on the IO thread before a resource is loaded. To allow the resource
|
||||
|
@ -150,8 +135,9 @@ typedef struct _cef_request_handler_t {
|
|||
// Called on the IO thread when the browser needs credentials from the user.
|
||||
// |isProxy| indicates whether the host is a proxy server. |host| contains the
|
||||
// hostname and |port| contains the port number. Return true (1) to continue
|
||||
// the request and call cef_auth_callback_t::cont() when the authentication
|
||||
// information is available. Return false (0) to cancel the request.
|
||||
// the request and call cef_auth_callback_t::cont() either in this function or
|
||||
// at a later time when the authentication information is available. Return
|
||||
// false (0) to cancel the request immediately.
|
||||
///
|
||||
int (CEF_CALLBACK *get_auth_credentials)(struct _cef_request_handler_t* self,
|
||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame, int isProxy,
|
||||
|
@ -162,13 +148,14 @@ typedef struct _cef_request_handler_t {
|
|||
// Called on the IO thread when JavaScript requests a specific storage quota
|
||||
// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
|
||||
// origin of the page making the request. |new_size| is the requested quota
|
||||
// size in bytes. Return true (1) and call cef_quota_callback_t::cont() either
|
||||
// in this function or at a later time to grant or deny the request. Return
|
||||
// false (0) to cancel the request.
|
||||
// size in bytes. Return true (1) to continue the request and call
|
||||
// cef_request_tCallback::cont() either in this function or at a later time to
|
||||
// grant or deny the request. Return false (0) to cancel the request
|
||||
// immediately.
|
||||
///
|
||||
int (CEF_CALLBACK *on_quota_request)(struct _cef_request_handler_t* self,
|
||||
struct _cef_browser_t* browser, const cef_string_t* origin_url,
|
||||
int64 new_size, struct _cef_quota_callback_t* callback);
|
||||
int64 new_size, struct _cef_request_callback_t* callback);
|
||||
|
||||
///
|
||||
// Called on the UI thread to handle requests for URLs with an unknown
|
||||
|
@ -183,18 +170,17 @@ typedef struct _cef_request_handler_t {
|
|||
|
||||
///
|
||||
// Called on the UI thread to handle requests for URLs with an invalid SSL
|
||||
// certificate. Return true (1) and call
|
||||
// cef_allow_certificate_error_callback_t:: cont() either in this function or
|
||||
// at a later time to continue or cancel the request. Return false (0) to
|
||||
// cancel the request immediately. If |callback| is NULL the error cannot be
|
||||
// recovered from and the request will be canceled automatically. If
|
||||
// CefSettings.ignore_certificate_errors is set all invalid certificates will
|
||||
// be accepted without calling this function.
|
||||
// certificate. Return true (1) and call cef_request_tCallback::cont() either
|
||||
// in this function or at a later time to continue or cancel the request.
|
||||
// Return false (0) to cancel the request immediately. If |callback| is NULL
|
||||
// the error cannot be recovered from and the request will be canceled
|
||||
// automatically. If CefSettings.ignore_certificate_errors is set all invalid
|
||||
// certificates will be accepted without calling this function.
|
||||
///
|
||||
int (CEF_CALLBACK *on_certificate_error)(struct _cef_request_handler_t* self,
|
||||
struct _cef_browser_t* browser, cef_errorcode_t cert_error,
|
||||
const cef_string_t* request_url, struct _cef_sslinfo_t* ssl_info,
|
||||
struct _cef_allow_certificate_error_callback_t* callback);
|
||||
struct _cef_request_callback_t* callback);
|
||||
|
||||
///
|
||||
// Called on the browser process IO thread before a plugin is loaded. Return
|
||||
|
|
|
@ -48,43 +48,28 @@
|
|||
#include "include/cef_ssl_info.h"
|
||||
#include "include/cef_web_plugin.h"
|
||||
|
||||
|
||||
///
|
||||
// Callback interface used for asynchronous continuation of quota requests.
|
||||
// Callback interface used for asynchronous continuation of url requests.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefQuotaCallback : public virtual CefBase {
|
||||
class CefRequestCallback : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Continue the quota request. If |allow| is true the request will be
|
||||
// allowed. Otherwise, the request will be denied.
|
||||
// Continue the url request. If |allow| is true the request will be continued.
|
||||
// Otherwise, the request will be canceled.
|
||||
///
|
||||
/*--cef(capi_name=cont)--*/
|
||||
virtual void Continue(bool allow) =0;
|
||||
|
||||
///
|
||||
// Cancel the quota request.
|
||||
// Cancel the url request.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void Cancel() =0;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
// Callback interface used for asynchronous continuation of url requests when
|
||||
// invalid SSL certificates are encountered.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefAllowCertificateErrorCallback : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Continue the url request. If |allow| is true the request will be
|
||||
// continued. Otherwise, the request will be canceled.
|
||||
///
|
||||
/*--cef(capi_name=cont)--*/
|
||||
virtual void Continue(bool allow) =0;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
// Implement this interface to handle events related to browser requests. The
|
||||
// methods of this class will be called on the thread indicated.
|
||||
|
@ -92,6 +77,7 @@ class CefAllowCertificateErrorCallback : public virtual CefBase {
|
|||
/*--cef(source=client)--*/
|
||||
class CefRequestHandler : public virtual CefBase {
|
||||
public:
|
||||
typedef cef_return_value_t ReturnValue;
|
||||
typedef cef_termination_status_t TerminationStatus;
|
||||
|
||||
///
|
||||
|
@ -114,14 +100,19 @@ class CefRequestHandler : public virtual CefBase {
|
|||
|
||||
///
|
||||
// Called on the IO thread before a resource request is loaded. The |request|
|
||||
// object may be modified. To cancel the request return true otherwise return
|
||||
// false.
|
||||
// object may be modified. Return RV_CONTINUE to continue the request
|
||||
// immediately. Return RV_CONTINUE_ASYNC and call CefRequestCallback::
|
||||
// Continue() at a later time to continue or cancel the request
|
||||
// asynchronously. Return RV_CANCEL to cancel the request immediately.
|
||||
//
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) {
|
||||
return false;
|
||||
/*--cef(default_retval=RV_CONTINUE)--*/
|
||||
virtual ReturnValue OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) {
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -153,8 +144,9 @@ class CefRequestHandler : public virtual CefBase {
|
|||
// Called on the IO thread when the browser needs credentials from the user.
|
||||
// |isProxy| indicates whether the host is a proxy server. |host| contains the
|
||||
// hostname and |port| contains the port number. Return true to continue the
|
||||
// request and call CefAuthCallback::Continue() when the authentication
|
||||
// information is available. Return false to cancel the request.
|
||||
// request and call CefAuthCallback::Continue() either in this method or
|
||||
// at a later time when the authentication information is available. Return
|
||||
// false to cancel the request immediately.
|
||||
///
|
||||
/*--cef(optional_param=realm)--*/
|
||||
virtual bool GetAuthCredentials(CefRefPtr<CefBrowser> browser,
|
||||
|
@ -172,15 +164,15 @@ class CefRequestHandler : public virtual CefBase {
|
|||
// Called on the IO thread when JavaScript requests a specific storage quota
|
||||
// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
|
||||
// origin of the page making the request. |new_size| is the requested quota
|
||||
// size in bytes. Return true and call CefQuotaCallback::Continue() either in
|
||||
// this method or at a later time to grant or deny the request. Return false
|
||||
// to cancel the request.
|
||||
// size in bytes. Return true to continue the request and call
|
||||
// CefRequestCallback::Continue() either in this method or at a later time to
|
||||
// grant or deny the request. Return false to cancel the request immediately.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& origin_url,
|
||||
int64 new_size,
|
||||
CefRefPtr<CefQuotaCallback> callback) {
|
||||
CefRefPtr<CefRequestCallback> callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -198,12 +190,12 @@ class CefRequestHandler : public virtual CefBase {
|
|||
|
||||
///
|
||||
// Called on the UI thread to handle requests for URLs with an invalid
|
||||
// SSL certificate. Return true and call CefAllowCertificateErrorCallback::
|
||||
// Continue() either in this method or at a later time to continue or cancel
|
||||
// the request. Return false to cancel the request immediately. If |callback|
|
||||
// is empty the error cannot be recovered from and the request will be
|
||||
// canceled automatically. If CefSettings.ignore_certificate_errors is set
|
||||
// all invalid certificates will be accepted without calling this method.
|
||||
// SSL certificate. Return true and call CefRequestCallback::Continue() either
|
||||
// in this method or at a later time to continue or cancel the request. Return
|
||||
// false to cancel the request immediately. If |callback| is empty the error
|
||||
// cannot be recovered from and the request will be canceled automatically.
|
||||
// If CefSettings.ignore_certificate_errors is set all invalid certificates
|
||||
// will be accepted without calling this method.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool OnCertificateError(
|
||||
|
@ -211,7 +203,7 @@ class CefRequestHandler : public virtual CefBase {
|
|||
cef_errorcode_t cert_error,
|
||||
const CefString& request_url,
|
||||
CefRefPtr<CefSSLInfo> ssl_info,
|
||||
CefRefPtr<CefAllowCertificateErrorCallback> callback) {
|
||||
CefRefPtr<CefRequestCallback> callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -565,6 +565,26 @@ typedef struct _cef_browser_settings_t {
|
|||
cef_color_t background_color;
|
||||
} cef_browser_settings_t;
|
||||
|
||||
///
|
||||
// Return value types.
|
||||
///
|
||||
typedef enum {
|
||||
///
|
||||
// Cancel immediately.
|
||||
///
|
||||
RV_CANCEL = 0,
|
||||
|
||||
///
|
||||
// Continue immediately.
|
||||
///
|
||||
RV_CONTINUE,
|
||||
|
||||
///
|
||||
// Continue asynchronously (usually via a callback).
|
||||
///
|
||||
RV_CONTINUE_ASYNC,
|
||||
} cef_return_value_t;
|
||||
|
||||
///
|
||||
// URL component parts.
|
||||
///
|
||||
|
|
|
@ -85,7 +85,7 @@ class CefAccessTokenStore : public content::AccessTokenStore {
|
|||
DISALLOW_COPY_AND_ASSIGN(CefAccessTokenStore);
|
||||
};
|
||||
|
||||
class CefQuotaCallbackImpl : public CefQuotaCallback {
|
||||
class CefQuotaCallbackImpl : public CefRequestCallback {
|
||||
public:
|
||||
explicit CefQuotaCallbackImpl(
|
||||
const content::QuotaPermissionContext::PermissionCallback& callback)
|
||||
|
@ -96,10 +96,10 @@ class CefQuotaCallbackImpl : public CefQuotaCallback {
|
|||
if (!callback_.is_null()) {
|
||||
// The callback is still pending. Cancel it now.
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
CancelNow(callback_);
|
||||
RunNow(callback_, false);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefQuotaCallbackImpl::CancelNow, callback_));
|
||||
base::Bind(&CefQuotaCallbackImpl::RunNow, callback_, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,9 +107,7 @@ class CefQuotaCallbackImpl : public CefQuotaCallback {
|
|||
void Continue(bool allow) override {
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
if (!callback_.is_null()) {
|
||||
callback_.Run(allow ?
|
||||
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW :
|
||||
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
||||
RunNow(callback_, allow);
|
||||
callback_.Reset();
|
||||
}
|
||||
} else {
|
||||
|
@ -119,14 +117,7 @@ class CefQuotaCallbackImpl : public CefQuotaCallback {
|
|||
}
|
||||
|
||||
void Cancel() override {
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
if (!callback_.is_null()) {
|
||||
CancelNow(callback_);
|
||||
callback_.Reset();
|
||||
}
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_IOT, base::Bind(&CefQuotaCallbackImpl::Cancel, this));
|
||||
}
|
||||
Continue(false);
|
||||
}
|
||||
|
||||
void Disconnect() {
|
||||
|
@ -134,11 +125,13 @@ class CefQuotaCallbackImpl : public CefQuotaCallback {
|
|||
}
|
||||
|
||||
private:
|
||||
static void CancelNow(
|
||||
const content::QuotaPermissionContext::PermissionCallback& callback) {
|
||||
static void RunNow(
|
||||
const content::QuotaPermissionContext::PermissionCallback& callback,
|
||||
bool allow) {
|
||||
CEF_REQUIRE_IOT();
|
||||
callback.Run(
|
||||
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED);
|
||||
callback.Run(allow ?
|
||||
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW :
|
||||
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
||||
}
|
||||
|
||||
content::QuotaPermissionContext::PermissionCallback callback_;
|
||||
|
@ -147,8 +140,7 @@ class CefQuotaCallbackImpl : public CefQuotaCallback {
|
|||
DISALLOW_COPY_AND_ASSIGN(CefQuotaCallbackImpl);
|
||||
};
|
||||
|
||||
class CefAllowCertificateErrorCallbackImpl
|
||||
: public CefAllowCertificateErrorCallback {
|
||||
class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
|
||||
public:
|
||||
typedef base::Callback<void(bool)> // NOLINT(readability/function)
|
||||
CallbackType;
|
||||
|
@ -157,24 +149,46 @@ class CefAllowCertificateErrorCallbackImpl
|
|||
: callback_(callback) {
|
||||
}
|
||||
|
||||
~CefAllowCertificateErrorCallbackImpl() {
|
||||
if (!callback_.is_null()) {
|
||||
// The callback is still pending. Cancel it now.
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
RunNow(callback_, false);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefAllowCertificateErrorCallbackImpl::RunNow,
|
||||
callback_, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Continue(bool allow) override {
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
if (!callback_.is_null()) {
|
||||
callback_.Run(allow);
|
||||
RunNow(callback_, allow);
|
||||
callback_.Reset();
|
||||
}
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefAllowCertificateErrorCallbackImpl::Continue,
|
||||
this, allow));
|
||||
this, allow));
|
||||
}
|
||||
}
|
||||
|
||||
void Cancel() override {
|
||||
Continue(false);
|
||||
}
|
||||
|
||||
void Disconnect() {
|
||||
callback_.Reset();
|
||||
}
|
||||
|
||||
private:
|
||||
static void RunNow(const CallbackType& callback, bool allow) {
|
||||
CEF_REQUIRE_IOT();
|
||||
callback.Run(allow);
|
||||
}
|
||||
|
||||
CallbackType callback_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefAllowCertificateErrorCallbackImpl);
|
||||
|
@ -211,11 +225,6 @@ class CefGeolocationCallbackImpl : public CefGeolocationCallback {
|
|||
}
|
||||
|
||||
private:
|
||||
static void Run(const CallbackType& callback, bool allow) {
|
||||
CEF_REQUIRE_UIT();
|
||||
callback.Run(allow);
|
||||
}
|
||||
|
||||
CallbackType callback_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefGeolocationCallbackImpl);
|
||||
|
|
|
@ -17,6 +17,132 @@
|
|||
|
||||
namespace {
|
||||
|
||||
class CefBeforeResourceLoadCallbackImpl : public CefRequestCallback {
|
||||
public:
|
||||
typedef net::CompletionCallback CallbackType;
|
||||
|
||||
CefBeforeResourceLoadCallbackImpl(
|
||||
CefRefPtr<CefRequestImpl> cef_request,
|
||||
GURL* new_url,
|
||||
net::URLRequest* url_request,
|
||||
const CallbackType& callback)
|
||||
: cef_request_(cef_request),
|
||||
new_url_(new_url),
|
||||
url_request_(url_request),
|
||||
callback_(callback) {
|
||||
DCHECK(new_url);
|
||||
DCHECK(url_request_);
|
||||
|
||||
// Add an association between the URLRequest and this object.
|
||||
url_request_->SetUserData(UserDataKey(), new Disconnector(this));
|
||||
}
|
||||
|
||||
~CefBeforeResourceLoadCallbackImpl() {
|
||||
if (!callback_.is_null()) {
|
||||
// The callback is still pending. Cancel it now.
|
||||
if (CEF_CURRENTLY_ON_IOT()) {
|
||||
RunNow(cef_request_, new_url_, url_request_, callback_, false);
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefBeforeResourceLoadCallbackImpl::RunNow,
|
||||
cef_request_, new_url_, url_request_, callback_, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Continue(bool allow) override {
|
||||
// Always continue asynchronously.
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefBeforeResourceLoadCallbackImpl::ContinueNow,
|
||||
this, allow));
|
||||
}
|
||||
|
||||
void Cancel() override {
|
||||
Continue(false);
|
||||
}
|
||||
|
||||
void ContinueNow(bool allow) {
|
||||
CEF_REQUIRE_IOT();
|
||||
if (!callback_.is_null()) {
|
||||
RunNow(cef_request_, new_url_, url_request_, callback_, allow);
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void Disconnect() {
|
||||
CEF_REQUIRE_IOT();
|
||||
cef_request_ = nullptr;
|
||||
new_url_ = nullptr;
|
||||
url_request_ = nullptr;
|
||||
callback_.Reset();
|
||||
}
|
||||
|
||||
private:
|
||||
// Used to disconnect the callback when the associated URLRequest is
|
||||
// destroyed.
|
||||
class Disconnector : public base::SupportsUserData::Data {
|
||||
public:
|
||||
explicit Disconnector(CefBeforeResourceLoadCallbackImpl* callback)
|
||||
: callback_(callback) {
|
||||
}
|
||||
~Disconnector() override {
|
||||
if (callback_)
|
||||
callback_->Disconnect();
|
||||
}
|
||||
|
||||
void Disconnect() {
|
||||
callback_ = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
CefBeforeResourceLoadCallbackImpl* callback_;
|
||||
};
|
||||
|
||||
static void RunNow(CefRefPtr<CefRequestImpl> cef_request,
|
||||
GURL* new_url,
|
||||
net::URLRequest* request,
|
||||
const CallbackType& callback,
|
||||
bool allow) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
if (allow) {
|
||||
const GURL& old_url = request->url();
|
||||
GURL url = GURL(cef_request->GetURL().ToString());
|
||||
if (old_url != url)
|
||||
new_url->Swap(&url);
|
||||
|
||||
cef_request->Get(request);
|
||||
}
|
||||
|
||||
// Remove the association between the URLRequest and this object.
|
||||
Disconnector* disconnector =
|
||||
static_cast<Disconnector*>(request->GetUserData(UserDataKey()));
|
||||
DCHECK(disconnector);
|
||||
disconnector->Disconnect();
|
||||
request->RemoveUserData(UserDataKey());
|
||||
|
||||
callback.Run(allow ? net::OK : net::ERR_ABORTED);
|
||||
}
|
||||
|
||||
static inline void* UserDataKey() {
|
||||
return &kLocatorKey;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestImpl> cef_request_;
|
||||
const GURL old_url_;
|
||||
GURL* new_url_;
|
||||
net::URLRequest* url_request_;
|
||||
CallbackType callback_;
|
||||
|
||||
// The user data key.
|
||||
static int kLocatorKey;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefBeforeResourceLoadCallbackImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefBeforeResourceLoadCallbackImpl);
|
||||
};
|
||||
|
||||
int CefBeforeResourceLoadCallbackImpl::kLocatorKey = 0;
|
||||
|
||||
class CefAuthCallbackImpl : public CefAuthCallback {
|
||||
public:
|
||||
CefAuthCallbackImpl(const net::NetworkDelegate::AuthCallback& callback,
|
||||
|
@ -98,27 +224,32 @@ int CefNetworkDelegate::OnBeforeURLRequest(
|
|||
if (handler.get()) {
|
||||
CefRefPtr<CefFrame> frame = browser->GetFrameForRequest(request);
|
||||
|
||||
GURL old_url = request->url();
|
||||
|
||||
// Populate the request data.
|
||||
CefRefPtr<CefRequestImpl> requestPtr(new CefRequestImpl());
|
||||
requestPtr->Set(request);
|
||||
|
||||
// Give the client an opportunity to cancel the request.
|
||||
if (handler->OnBeforeResourceLoad(browser.get(), frame,
|
||||
requestPtr.get())) {
|
||||
return net::ERR_ABORTED;
|
||||
CefRefPtr<CefBeforeResourceLoadCallbackImpl> callbackImpl(
|
||||
new CefBeforeResourceLoadCallbackImpl(requestPtr, new_url, request,
|
||||
callback));
|
||||
|
||||
// Give the client an opportunity to evaluate the request.
|
||||
cef_return_value_t retval = handler->OnBeforeResourceLoad(
|
||||
browser.get(), frame, requestPtr.get(), callbackImpl.get());
|
||||
if (retval == RV_CANCEL) {
|
||||
// Cancel the request.
|
||||
callbackImpl->Continue(false);
|
||||
} else if (retval == RV_CONTINUE) {
|
||||
// Continue the request.
|
||||
callbackImpl->Continue(true);
|
||||
}
|
||||
|
||||
GURL url = GURL(std::string(requestPtr->GetURL()));
|
||||
if (old_url != url)
|
||||
new_url ->Swap(&url);
|
||||
|
||||
requestPtr->Get(request);
|
||||
// Continue or cancel the request asynchronously.
|
||||
return net::ERR_IO_PENDING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Continue the request immediately.
|
||||
return net::OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class CefNetworkDelegate : public net::NetworkDelegateImpl {
|
|||
const AuthCallback& callback,
|
||||
net::AuthCredentials* credentials) override;
|
||||
bool OnCanAccessFile(const net::URLRequest& request,
|
||||
const base::FilePath& path) const;
|
||||
const base::FilePath& path) const override;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefNetworkDelegate);
|
||||
};
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
// Copyright (c) 2015 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/allow_certificate_error_callback_cpptoc.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
void CEF_CALLBACK allow_certificate_error_callback_cont(
|
||||
struct _cef_allow_certificate_error_callback_t* self, int allow) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefAllowCertificateErrorCallbackCppToC::Get(self)->Continue(
|
||||
allow?true:false);
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefAllowCertificateErrorCallbackCppToC::CefAllowCertificateErrorCallbackCppToC(
|
||||
CefAllowCertificateErrorCallback* cls)
|
||||
: CefCppToC<CefAllowCertificateErrorCallbackCppToC,
|
||||
CefAllowCertificateErrorCallback,
|
||||
cef_allow_certificate_error_callback_t>(cls) {
|
||||
struct_.struct_.cont = allow_certificate_error_callback_cont;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> base::AtomicRefCount CefCppToC<CefAllowCertificateErrorCallbackCppToC,
|
||||
CefAllowCertificateErrorCallback,
|
||||
cef_allow_certificate_error_callback_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) 2015 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_ALLOW_CERTIFICATE_ERROR_CALLBACK_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_ALLOW_CERTIFICATE_ERROR_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_request_handler.h"
|
||||
#include "include/capi/cef_request_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 CefAllowCertificateErrorCallbackCppToC
|
||||
: public CefCppToC<CefAllowCertificateErrorCallbackCppToC,
|
||||
CefAllowCertificateErrorCallback,
|
||||
cef_allow_certificate_error_callback_t> {
|
||||
public:
|
||||
explicit CefAllowCertificateErrorCallbackCppToC(
|
||||
CefAllowCertificateErrorCallback* cls);
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_ALLOW_CERTIFICATE_ERROR_CALLBACK_CPPTOC_H_
|
||||
|
|
@ -10,12 +10,12 @@
|
|||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/quota_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_callback_cpptoc.h"
|
||||
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
void CEF_CALLBACK quota_callback_cont(struct _cef_quota_callback_t* self,
|
||||
void CEF_CALLBACK request_callback_cont(struct _cef_request_callback_t* self,
|
||||
int allow) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
|
@ -24,11 +24,12 @@ void CEF_CALLBACK quota_callback_cont(struct _cef_quota_callback_t* self,
|
|||
return;
|
||||
|
||||
// Execute
|
||||
CefQuotaCallbackCppToC::Get(self)->Continue(
|
||||
CefRequestCallbackCppToC::Get(self)->Continue(
|
||||
allow?true:false);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK quota_callback_cancel(struct _cef_quota_callback_t* self) {
|
||||
void CEF_CALLBACK request_callback_cancel(
|
||||
struct _cef_request_callback_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
|
@ -36,21 +37,21 @@ void CEF_CALLBACK quota_callback_cancel(struct _cef_quota_callback_t* self) {
|
|||
return;
|
||||
|
||||
// Execute
|
||||
CefQuotaCallbackCppToC::Get(self)->Cancel();
|
||||
CefRequestCallbackCppToC::Get(self)->Cancel();
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefQuotaCallbackCppToC::CefQuotaCallbackCppToC(CefQuotaCallback* cls)
|
||||
: CefCppToC<CefQuotaCallbackCppToC, CefQuotaCallback, cef_quota_callback_t>(
|
||||
cls) {
|
||||
struct_.struct_.cont = quota_callback_cont;
|
||||
struct_.struct_.cancel = quota_callback_cancel;
|
||||
CefRequestCallbackCppToC::CefRequestCallbackCppToC(CefRequestCallback* cls)
|
||||
: CefCppToC<CefRequestCallbackCppToC, CefRequestCallback,
|
||||
cef_request_callback_t>(cls) {
|
||||
struct_.struct_.cont = request_callback_cont;
|
||||
struct_.struct_.cancel = request_callback_cancel;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> base::AtomicRefCount CefCppToC<CefQuotaCallbackCppToC,
|
||||
CefQuotaCallback, cef_quota_callback_t>::DebugObjCt = 0;
|
||||
template<> base::AtomicRefCount CefCppToC<CefRequestCallbackCppToC,
|
||||
CefRequestCallback, cef_request_callback_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_QUOTA_CALLBACK_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_QUOTA_CALLBACK_CPPTOC_H_
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_REQUEST_CALLBACK_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_REQUEST_CALLBACK_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
|
@ -24,13 +24,13 @@
|
|||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefQuotaCallbackCppToC
|
||||
: public CefCppToC<CefQuotaCallbackCppToC, CefQuotaCallback,
|
||||
cef_quota_callback_t> {
|
||||
class CefRequestCallbackCppToC
|
||||
: public CefCppToC<CefRequestCallbackCppToC, CefRequestCallback,
|
||||
cef_request_callback_t> {
|
||||
public:
|
||||
explicit CefQuotaCallbackCppToC(CefQuotaCallback* cls);
|
||||
explicit CefRequestCallbackCppToC(CefRequestCallback* cls);
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_QUOTA_CALLBACK_CPPTOC_H_
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_REQUEST_CALLBACK_CPPTOC_H_
|
||||
|
|
@ -12,12 +12,11 @@
|
|||
|
||||
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/resource_handler_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/auth_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/frame_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/quota_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/request_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/request_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h"
|
||||
|
||||
|
@ -56,34 +55,41 @@ int CEF_CALLBACK request_handler_on_before_browse(
|
|||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK request_handler_on_before_resource_load(
|
||||
cef_return_value_t CEF_CALLBACK request_handler_on_before_resource_load(
|
||||
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
||||
cef_frame_t* frame, cef_request_t* request) {
|
||||
cef_frame_t* frame, cef_request_t* request,
|
||||
cef_request_callback_t* callback) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
return RV_CONTINUE;
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser)
|
||||
return 0;
|
||||
return RV_CONTINUE;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame);
|
||||
if (!frame)
|
||||
return 0;
|
||||
return RV_CONTINUE;
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return 0;
|
||||
return RV_CONTINUE;
|
||||
// Verify param: callback; type: refptr_diff
|
||||
DCHECK(callback);
|
||||
if (!callback)
|
||||
return RV_CONTINUE;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefRequestHandlerCppToC::Get(self)->OnBeforeResourceLoad(
|
||||
cef_return_value_t _retval = CefRequestHandlerCppToC::Get(
|
||||
self)->OnBeforeResourceLoad(
|
||||
CefBrowserCToCpp::Wrap(browser),
|
||||
CefFrameCToCpp::Wrap(frame),
|
||||
CefRequestCToCpp::Wrap(request));
|
||||
CefRequestCToCpp::Wrap(request),
|
||||
CefRequestCallbackCToCpp::Wrap(callback));
|
||||
|
||||
// Return type: bool
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
|
@ -205,7 +211,7 @@ int CEF_CALLBACK request_handler_get_auth_credentials(
|
|||
int CEF_CALLBACK request_handler_on_quota_request(
|
||||
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
||||
const cef_string_t* origin_url, int64 new_size,
|
||||
cef_quota_callback_t* callback) {
|
||||
cef_request_callback_t* callback) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
|
@ -229,7 +235,7 @@ int CEF_CALLBACK request_handler_on_quota_request(
|
|||
CefBrowserCToCpp::Wrap(browser),
|
||||
CefString(origin_url),
|
||||
new_size,
|
||||
CefQuotaCallbackCToCpp::Wrap(callback));
|
||||
CefRequestCallbackCToCpp::Wrap(callback));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
|
@ -274,8 +280,7 @@ void CEF_CALLBACK request_handler_on_protocol_execution(
|
|||
int CEF_CALLBACK request_handler_on_certificate_error(
|
||||
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
||||
cef_errorcode_t cert_error, const cef_string_t* request_url,
|
||||
struct _cef_sslinfo_t* ssl_info,
|
||||
cef_allow_certificate_error_callback_t* callback) {
|
||||
struct _cef_sslinfo_t* ssl_info, cef_request_callback_t* callback) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
|
@ -304,7 +309,7 @@ int CEF_CALLBACK request_handler_on_certificate_error(
|
|||
cert_error,
|
||||
CefString(request_url),
|
||||
CefSSLInfoCToCpp::Wrap(ssl_info),
|
||||
CefAllowCertificateErrorCallbackCToCpp::Wrap(callback));
|
||||
CefRequestCallbackCToCpp::Wrap(callback));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
// Copyright (c) 2015 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/allow_certificate_error_callback_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
void CefAllowCertificateErrorCallbackCToCpp::Continue(bool allow) {
|
||||
if (CEF_MEMBER_MISSING(struct_, cont))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
struct_->cont(struct_,
|
||||
allow);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> base::AtomicRefCount CefCToCpp<CefAllowCertificateErrorCallbackCToCpp,
|
||||
CefAllowCertificateErrorCallback,
|
||||
cef_allow_certificate_error_callback_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
// Copyright (c) 2015 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_ALLOW_CERTIFICATE_ERROR_CALLBACK_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_ALLOW_CERTIFICATE_ERROR_CALLBACK_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||
#else // USING_CEF_SHARED
|
||||
|
||||
#include "include/cef_request_handler.h"
|
||||
#include "include/capi/cef_request_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 CefAllowCertificateErrorCallbackCToCpp
|
||||
: public CefCToCpp<CefAllowCertificateErrorCallbackCToCpp,
|
||||
CefAllowCertificateErrorCallback,
|
||||
cef_allow_certificate_error_callback_t> {
|
||||
public:
|
||||
explicit CefAllowCertificateErrorCallbackCToCpp(
|
||||
cef_allow_certificate_error_callback_t* str)
|
||||
: CefCToCpp<CefAllowCertificateErrorCallbackCToCpp,
|
||||
CefAllowCertificateErrorCallback,
|
||||
cef_allow_certificate_error_callback_t>(str) {}
|
||||
|
||||
// CefAllowCertificateErrorCallback methods
|
||||
virtual void Continue(bool allow) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_ALLOW_CERTIFICATE_ERROR_CALLBACK_CTOCPP_H_
|
||||
|
|
@ -10,12 +10,12 @@
|
|||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/quota_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/request_callback_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
void CefQuotaCallbackCToCpp::Continue(bool allow) {
|
||||
void CefRequestCallbackCToCpp::Continue(bool allow) {
|
||||
if (CEF_MEMBER_MISSING(struct_, cont))
|
||||
return;
|
||||
|
||||
|
@ -26,7 +26,7 @@ void CefQuotaCallbackCToCpp::Continue(bool allow) {
|
|||
allow);
|
||||
}
|
||||
|
||||
void CefQuotaCallbackCToCpp::Cancel() {
|
||||
void CefRequestCallbackCToCpp::Cancel() {
|
||||
if (CEF_MEMBER_MISSING(struct_, cancel))
|
||||
return;
|
||||
|
||||
|
@ -38,7 +38,7 @@ void CefQuotaCallbackCToCpp::Cancel() {
|
|||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> base::AtomicRefCount CefCToCpp<CefQuotaCallbackCToCpp,
|
||||
CefQuotaCallback, cef_quota_callback_t>::DebugObjCt = 0;
|
||||
template<> base::AtomicRefCount CefCToCpp<CefRequestCallbackCToCpp,
|
||||
CefRequestCallback, cef_request_callback_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
// for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_QUOTA_CALLBACK_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_QUOTA_CALLBACK_CTOCPP_H_
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_CALLBACK_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_REQUEST_CALLBACK_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef USING_CEF_SHARED
|
||||
|
@ -24,19 +24,19 @@
|
|||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefQuotaCallbackCToCpp
|
||||
: public CefCToCpp<CefQuotaCallbackCToCpp, CefQuotaCallback,
|
||||
cef_quota_callback_t> {
|
||||
class CefRequestCallbackCToCpp
|
||||
: public CefCToCpp<CefRequestCallbackCToCpp, CefRequestCallback,
|
||||
cef_request_callback_t> {
|
||||
public:
|
||||
explicit CefQuotaCallbackCToCpp(cef_quota_callback_t* str)
|
||||
: CefCToCpp<CefQuotaCallbackCToCpp, CefQuotaCallback,
|
||||
cef_quota_callback_t>(str) {}
|
||||
explicit CefRequestCallbackCToCpp(cef_request_callback_t* str)
|
||||
: CefCToCpp<CefRequestCallbackCToCpp, CefRequestCallback,
|
||||
cef_request_callback_t>(str) {}
|
||||
|
||||
// CefQuotaCallback methods
|
||||
// CefRequestCallback methods
|
||||
virtual void Continue(bool allow) OVERRIDE;
|
||||
virtual void Cancel() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_QUOTA_CALLBACK_CTOCPP_H_
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_REQUEST_CALLBACK_CTOCPP_H_
|
||||
|
|
@ -10,12 +10,11 @@
|
|||
// for more information.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/auth_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/frame_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/quota_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/sslinfo_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
||||
|
@ -56,35 +55,40 @@ bool CefRequestHandlerCToCpp::OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
|||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefRequestHandlerCToCpp::OnBeforeResourceLoad(
|
||||
CefRequestHandler::ReturnValue CefRequestHandlerCToCpp::OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) {
|
||||
CefRefPtr<CefRequest> request, CefRefPtr<CefRequestCallback> callback) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_before_resource_load))
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame.get());
|
||||
if (!frame.get())
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request.get());
|
||||
if (!request.get())
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
// Verify param: callback; type: refptr_diff
|
||||
DCHECK(callback.get());
|
||||
if (!callback.get())
|
||||
return RV_CONTINUE;
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->on_before_resource_load(struct_,
|
||||
cef_return_value_t _retval = struct_->on_before_resource_load(struct_,
|
||||
CefBrowserCppToC::Wrap(browser),
|
||||
CefFrameCppToC::Wrap(frame),
|
||||
CefRequestCppToC::Wrap(request));
|
||||
CefRequestCppToC::Wrap(request),
|
||||
CefRequestCallbackCppToC::Wrap(callback));
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
CefRefPtr<CefResourceHandler> CefRequestHandlerCToCpp::GetResourceHandler(
|
||||
|
@ -194,7 +198,7 @@ bool CefRequestHandlerCToCpp::GetAuthCredentials(CefRefPtr<CefBrowser> browser,
|
|||
|
||||
bool CefRequestHandlerCToCpp::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& origin_url, int64 new_size,
|
||||
CefRefPtr<CefQuotaCallback> callback) {
|
||||
CefRefPtr<CefRequestCallback> callback) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_quota_request))
|
||||
return false;
|
||||
|
||||
|
@ -218,7 +222,7 @@ bool CefRequestHandlerCToCpp::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
|||
CefBrowserCppToC::Wrap(browser),
|
||||
origin_url.GetStruct(),
|
||||
new_size,
|
||||
CefQuotaCallbackCppToC::Wrap(callback));
|
||||
CefRequestCallbackCppToC::Wrap(callback));
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
|
@ -255,8 +259,7 @@ void CefRequestHandlerCToCpp::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
|||
|
||||
bool CefRequestHandlerCToCpp::OnCertificateError(CefRefPtr<CefBrowser> browser,
|
||||
cef_errorcode_t cert_error, const CefString& request_url,
|
||||
CefRefPtr<CefSSLInfo> ssl_info,
|
||||
CefRefPtr<CefAllowCertificateErrorCallback> callback) {
|
||||
CefRefPtr<CefSSLInfo> ssl_info, CefRefPtr<CefRequestCallback> callback) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_certificate_error))
|
||||
return false;
|
||||
|
||||
|
@ -285,7 +288,7 @@ bool CefRequestHandlerCToCpp::OnCertificateError(CefRefPtr<CefBrowser> browser,
|
|||
cert_error,
|
||||
request_url.GetStruct(),
|
||||
CefSSLInfoCppToC::Wrap(ssl_info),
|
||||
CefAllowCertificateErrorCallbackCppToC::Wrap(callback));
|
||||
CefRequestCallbackCppToC::Wrap(callback));
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
|
|
|
@ -35,8 +35,9 @@ class CefRequestHandlerCToCpp
|
|||
// CefRequestHandler methods
|
||||
bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request, bool is_redirect) override;
|
||||
bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request) override;
|
||||
ReturnValue OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override;
|
||||
CefRefPtr<CefResourceHandler> GetResourceHandler(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) override;
|
||||
|
@ -49,13 +50,13 @@ class CefRequestHandlerCToCpp
|
|||
CefRefPtr<CefAuthCallback> callback) override;
|
||||
bool OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& origin_url, int64 new_size,
|
||||
CefRefPtr<CefQuotaCallback> callback) override;
|
||||
CefRefPtr<CefRequestCallback> callback) override;
|
||||
void OnProtocolExecution(CefRefPtr<CefBrowser> browser, const CefString& url,
|
||||
bool& allow_os_execution) override;
|
||||
bool OnCertificateError(CefRefPtr<CefBrowser> browser,
|
||||
cef_errorcode_t cert_error, const CefString& request_url,
|
||||
CefRefPtr<CefSSLInfo> ssl_info,
|
||||
CefRefPtr<CefAllowCertificateErrorCallback> callback) override;
|
||||
CefRefPtr<CefRequestCallback> callback) override;
|
||||
bool OnBeforePluginLoad(CefRefPtr<CefBrowser> browser, const CefString& url,
|
||||
const CefString& policy_url, CefRefPtr<CefWebPluginInfo> info) override;
|
||||
void OnPluginCrashed(CefRefPtr<CefBrowser> browser,
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "include/capi/cef_v8_capi.h"
|
||||
#include "include/cef_web_plugin.h"
|
||||
#include "include/capi/cef_web_plugin_capi.h"
|
||||
#include "libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/auth_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/before_download_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/binary_value_cpptoc.h"
|
||||
|
@ -58,7 +57,7 @@
|
|||
#include "libcef_dll/cpptoc/print_job_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/print_settings_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/quota_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/sslcert_principal_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/sslinfo_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
|
||||
|
@ -184,8 +183,6 @@ CEF_EXPORT void cef_shutdown() {
|
|||
|
||||
#ifndef NDEBUG
|
||||
// Check that all wrapper objects have been destroyed
|
||||
DCHECK(base::AtomicRefCountIsZero(
|
||||
&CefAllowCertificateErrorCallbackCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefAuthCallbackCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(
|
||||
&CefBeforeDownloadCallbackCppToC::DebugObjCt));
|
||||
|
@ -235,11 +232,11 @@ CEF_EXPORT void cef_shutdown() {
|
|||
DCHECK(base::AtomicRefCountIsZero(&CefPrintJobCallbackCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefPrintSettingsCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefProcessMessageCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefQuotaCallbackCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefReadHandlerCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefRenderHandlerCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(
|
||||
&CefRenderProcessHandlerCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefRequestCallbackCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefRequestHandlerCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(
|
||||
&CefResourceBundleHandlerCToCpp::DebugObjCt));
|
||||
|
|
|
@ -70,7 +70,6 @@
|
|||
#include "libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/write_handler_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/auth_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/before_download_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/binary_value_ctocpp.h"
|
||||
|
@ -96,7 +95,7 @@
|
|||
#include "libcef_dll/ctocpp/print_job_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/print_settings_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/process_message_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/quota_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/request_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/sslcert_principal_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h"
|
||||
|
@ -176,8 +175,6 @@ CEF_GLOBAL void CefShutdown() {
|
|||
|
||||
#ifndef NDEBUG
|
||||
// Check that all wrapper objects have been destroyed
|
||||
DCHECK(base::AtomicRefCountIsZero(
|
||||
&CefAllowCertificateErrorCallbackCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefAuthCallbackCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(
|
||||
&CefBeforeDownloadCallbackCToCpp::DebugObjCt));
|
||||
|
@ -227,11 +224,11 @@ CEF_GLOBAL void CefShutdown() {
|
|||
DCHECK(base::AtomicRefCountIsZero(&CefPrintJobCallbackCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefPrintSettingsCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefProcessMessageCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefQuotaCallbackCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefReadHandlerCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefRenderHandlerCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(
|
||||
&CefRenderProcessHandlerCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefRequestCallbackCToCpp::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(&CefRequestHandlerCppToC::DebugObjCt));
|
||||
DCHECK(base::AtomicRefCountIsZero(
|
||||
&CefResourceBundleHandlerCppToC::DebugObjCt));
|
||||
|
|
|
@ -542,7 +542,7 @@ CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
|||
bool ClientHandler::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& origin_url,
|
||||
int64 new_size,
|
||||
CefRefPtr<CefQuotaCallback> callback) {
|
||||
CefRefPtr<CefRequestCallback> callback) {
|
||||
CEF_REQUIRE_IO_THREAD();
|
||||
|
||||
static const int64 max_size = 1024 * 1024 * 20; // 20mb.
|
||||
|
@ -569,7 +569,7 @@ bool ClientHandler::OnCertificateError(
|
|||
ErrorCode cert_error,
|
||||
const CefString& request_url,
|
||||
CefRefPtr<CefSSLInfo> ssl_info,
|
||||
CefRefPtr<CefAllowCertificateErrorCallback> callback) {
|
||||
CefRefPtr<CefRequestCallback> callback) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
CefRefPtr<CefSSLCertPrincipal> subject = ssl_info->GetSubject();
|
||||
|
|
|
@ -183,7 +183,7 @@ class ClientHandler : public CefClient,
|
|||
bool OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& origin_url,
|
||||
int64 new_size,
|
||||
CefRefPtr<CefQuotaCallback> callback) OVERRIDE;
|
||||
CefRefPtr<CefRequestCallback> callback) OVERRIDE;
|
||||
void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& url,
|
||||
bool& allow_os_execution) OVERRIDE;
|
||||
|
@ -192,7 +192,7 @@ class ClientHandler : public CefClient,
|
|||
ErrorCode cert_error,
|
||||
const CefString& request_url,
|
||||
CefRefPtr<CefSSLInfo> ssl_info,
|
||||
CefRefPtr<CefAllowCertificateErrorCallback> callback) OVERRIDE;
|
||||
CefRefPtr<CefRequestCallback> callback) OVERRIDE;
|
||||
void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
|
||||
TerminationStatus status) OVERRIDE;
|
||||
|
||||
|
|
|
@ -443,9 +443,11 @@ class HistoryNavTestHandler : public TestHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) override {
|
||||
cef_return_value_t OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override {
|
||||
const NavListItem& item = kHNavList[nav_];
|
||||
|
||||
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
|
||||
|
@ -460,7 +462,7 @@ class HistoryNavTestHandler : public TestHandler {
|
|||
if (url == item.target)
|
||||
got_correct_target_[nav_].yes();
|
||||
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
void OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
|
||||
|
@ -736,9 +738,11 @@ class RedirectTestHandler : public TestHandler {
|
|||
SetTestTimeout();
|
||||
}
|
||||
|
||||
bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) override {
|
||||
cef_return_value_t OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override {
|
||||
// Should be called for all but the second URL.
|
||||
std::string url = request->GetURL();
|
||||
|
||||
|
@ -755,7 +759,7 @@ class RedirectTestHandler : public TestHandler {
|
|||
got_invalid_before_resource_load_.yes();
|
||||
}
|
||||
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
void OnResourceRedirect(CefRefPtr<CefBrowser> browser,
|
||||
|
@ -1302,9 +1306,11 @@ class OrderNavTestHandler : public TestHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) override {
|
||||
cef_return_value_t OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override {
|
||||
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
|
||||
|
||||
if (browser->IsPopup()) {
|
||||
|
@ -1317,7 +1323,7 @@ class OrderNavTestHandler : public TestHandler {
|
|||
EXPECT_EQ(browser_id_main_, browser->GetIdentifier());
|
||||
}
|
||||
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
void OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
|
||||
|
@ -1687,16 +1693,18 @@ class CrossOriginNavTestHandler : public TestHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) override {
|
||||
cef_return_value_t OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override {
|
||||
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
|
||||
EXPECT_EQ(TT_EXPLICIT, request->GetTransitionType());
|
||||
|
||||
EXPECT_GT(browser_id_current_, 0);
|
||||
EXPECT_EQ(browser_id_current_, browser->GetIdentifier());
|
||||
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
void OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
|
|
|
@ -130,9 +130,11 @@ class NetNotifyTestHandler : public TestHandler {
|
|||
SetTestTimeout();
|
||||
}
|
||||
|
||||
bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) override {
|
||||
cef_return_value_t OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override {
|
||||
EXPECT_TRUE(CefCurrentlyOn(TID_IO));
|
||||
|
||||
const std::string& url = request->GetURL();
|
||||
|
@ -143,7 +145,7 @@ class NetNotifyTestHandler : public TestHandler {
|
|||
else
|
||||
EXPECT_TRUE(false); // Not reached
|
||||
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
CefRefPtr<CefResourceHandler> GetResourceHandler(
|
||||
|
@ -503,6 +505,174 @@ TEST(RequestHandlerTest, NotificationsCrossOriginDelayedBrowser) {
|
|||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
const char kResourceTestHtml[] = "http://test.com/resource.html";
|
||||
const char kResourceTestHtml2[] = "http://test.com/resource2.html";
|
||||
|
||||
class BeforeResourceLoadTest : public TestHandler {
|
||||
public:
|
||||
enum TestMode {
|
||||
CANCEL,
|
||||
CANCEL_ASYNC,
|
||||
CANCEL_NAV,
|
||||
CONTINUE,
|
||||
CONTINUE_ASYNC,
|
||||
};
|
||||
|
||||
explicit BeforeResourceLoadTest(TestMode mode)
|
||||
: test_mode_(mode) {
|
||||
}
|
||||
|
||||
void RunTest() override {
|
||||
AddResource(kResourceTestHtml, "<html><body>Test</body></html>",
|
||||
"text/html");
|
||||
AddResource(kResourceTestHtml2, "<html><body>Test2</body></html>",
|
||||
"text/html");
|
||||
CreateBrowser(kResourceTestHtml);
|
||||
SetTestTimeout();
|
||||
}
|
||||
|
||||
cef_return_value_t OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override {
|
||||
EXPECT_IO_THREAD();
|
||||
|
||||
// Allow the 2nd navigation to continue.
|
||||
const std::string& url = request->GetURL();
|
||||
if (url == kResourceTestHtml2) {
|
||||
got_before_resource_load2_.yes();
|
||||
EXPECT_EQ(CANCEL_NAV, test_mode_);
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
EXPECT_FALSE(got_before_resource_load_);
|
||||
got_before_resource_load_.yes();
|
||||
|
||||
if (test_mode_ == CANCEL) {
|
||||
// Cancel immediately.
|
||||
return RV_CANCEL;
|
||||
} else if (test_mode_ == CONTINUE) {
|
||||
// Continue immediately.
|
||||
return RV_CONTINUE;
|
||||
} else {
|
||||
if (test_mode_ == CANCEL_NAV) {
|
||||
// Cancel the request by navigating to a new URL.
|
||||
browser->GetMainFrame()->LoadURL(kResourceTestHtml2);
|
||||
} else {
|
||||
// Continue or cancel asynchronously.
|
||||
CefPostTask(TID_UI,
|
||||
base::Bind(&CefRequestCallback::Continue, callback.get(),
|
||||
test_mode_ == CONTINUE_ASYNC));
|
||||
}
|
||||
return RV_CONTINUE_ASYNC;
|
||||
}
|
||||
}
|
||||
|
||||
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
int httpStatusCode) override {
|
||||
EXPECT_UI_THREAD();
|
||||
|
||||
EXPECT_FALSE(got_load_end_);
|
||||
got_load_end_.yes();
|
||||
|
||||
const std::string& url = frame->GetURL();
|
||||
if (test_mode_ == CANCEL_NAV)
|
||||
EXPECT_STREQ(kResourceTestHtml2, url.data());
|
||||
else
|
||||
EXPECT_STREQ(kResourceTestHtml, url.data());
|
||||
|
||||
TestHandler::OnLoadEnd(browser, frame, httpStatusCode);
|
||||
DestroyTest();
|
||||
}
|
||||
|
||||
void OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
ErrorCode errorCode,
|
||||
const CefString& errorText,
|
||||
const CefString& failedUrl) override {
|
||||
EXPECT_UI_THREAD();
|
||||
|
||||
EXPECT_FALSE(got_load_error_);
|
||||
got_load_error_.yes();
|
||||
|
||||
const std::string& url = failedUrl;
|
||||
EXPECT_STREQ(kResourceTestHtml, url.data());
|
||||
|
||||
TestHandler::OnLoadError(browser, frame, errorCode, errorText, failedUrl);
|
||||
if (test_mode_ != CANCEL_NAV)
|
||||
DestroyTest();
|
||||
}
|
||||
|
||||
void DestroyTest() override {
|
||||
EXPECT_TRUE(got_before_resource_load_);
|
||||
|
||||
if (test_mode_ == CANCEL_NAV)
|
||||
EXPECT_TRUE(got_before_resource_load2_);
|
||||
else
|
||||
EXPECT_FALSE(got_before_resource_load2_);
|
||||
|
||||
if (test_mode_ == CONTINUE || test_mode_ == CONTINUE_ASYNC) {
|
||||
EXPECT_TRUE(got_load_end_);
|
||||
EXPECT_FALSE(got_load_error_);
|
||||
} else if (test_mode_ == CANCEL || test_mode_ == CANCEL_ASYNC) {
|
||||
EXPECT_FALSE(got_load_end_);
|
||||
EXPECT_TRUE(got_load_error_);
|
||||
}
|
||||
|
||||
TestHandler::DestroyTest();
|
||||
}
|
||||
|
||||
private:
|
||||
const TestMode test_mode_;
|
||||
|
||||
TrackCallback got_before_resource_load_;
|
||||
TrackCallback got_before_resource_load2_;
|
||||
TrackCallback got_load_end_;
|
||||
TrackCallback got_load_error_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(RequestHandlerTest, BeforeResourceLoadCancel) {
|
||||
CefRefPtr<BeforeResourceLoadTest> handler =
|
||||
new BeforeResourceLoadTest(BeforeResourceLoadTest::CANCEL);
|
||||
handler->ExecuteTest();
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
TEST(RequestHandlerTest, BeforeResourceLoadCancelAsync) {
|
||||
CefRefPtr<BeforeResourceLoadTest> handler =
|
||||
new BeforeResourceLoadTest(BeforeResourceLoadTest::CANCEL_ASYNC);
|
||||
handler->ExecuteTest();
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
TEST(RequestHandlerTest, BeforeResourceLoadCancelNav) {
|
||||
CefRefPtr<BeforeResourceLoadTest> handler =
|
||||
new BeforeResourceLoadTest(BeforeResourceLoadTest::CANCEL_NAV);
|
||||
handler->ExecuteTest();
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
TEST(RequestHandlerTest, BeforeResourceLoadContinue) {
|
||||
CefRefPtr<BeforeResourceLoadTest> handler =
|
||||
new BeforeResourceLoadTest(BeforeResourceLoadTest::CONTINUE);
|
||||
handler->ExecuteTest();
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
TEST(RequestHandlerTest, BeforeResourceLoadContinueAsync) {
|
||||
CefRefPtr<BeforeResourceLoadTest> handler =
|
||||
new BeforeResourceLoadTest(BeforeResourceLoadTest::CONTINUE_ASYNC);
|
||||
handler->ExecuteTest();
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
|
||||
// Entry point for creating request handler browser test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateRequestHandlerBrowserTests(
|
||||
|
|
|
@ -160,9 +160,11 @@ class RequestSendRecvTestHandler : public TestHandler {
|
|||
browser->GetMainFrame()->LoadRequest(request_);
|
||||
}
|
||||
|
||||
bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) override {
|
||||
cef_return_value_t OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override {
|
||||
// Verify that the request is the same
|
||||
TestRequestEqual(request_, request, true);
|
||||
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
|
||||
|
@ -170,7 +172,7 @@ class RequestSendRecvTestHandler : public TestHandler {
|
|||
|
||||
got_before_resource_load_.yes();
|
||||
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
CefRefPtr<CefResourceHandler> GetResourceHandler(
|
||||
|
@ -454,12 +456,14 @@ class TypeTestHandler : public TestHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) override {
|
||||
cef_return_value_t OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override {
|
||||
load_expectations_.GotRequest(request);
|
||||
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
CefRefPtr<CefResourceHandler> GetResourceHandler(
|
||||
|
|
|
@ -100,9 +100,11 @@ class TestSchemeHandler : public TestHandler {
|
|||
TestHandler::DestroyTest();
|
||||
}
|
||||
|
||||
bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) override {
|
||||
cef_return_value_t OnBeforeResourceLoad(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefRequestCallback> callback) override {
|
||||
std::string newUrl = request->GetURL();
|
||||
if (!test_results_->exit_url.empty() &&
|
||||
newUrl.find(test_results_->exit_url) != std::string::npos) {
|
||||
|
@ -110,7 +112,7 @@ class TestSchemeHandler : public TestHandler {
|
|||
if (newUrl.find("SUCCESS") != std::string::npos)
|
||||
test_results_->got_sub_success.yes();
|
||||
DestroyTest();
|
||||
return true;
|
||||
return RV_CANCEL;
|
||||
}
|
||||
|
||||
if (!test_results_->sub_redirect_url.empty() &&
|
||||
|
@ -130,7 +132,7 @@ class TestSchemeHandler : public TestHandler {
|
|||
test_results_->redirect_url.clear();
|
||||
}
|
||||
|
||||
return false;
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
|
|
Loading…
Reference in New Issue