mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Implement improvements for request handling (issue #1327).
- Add a new CefRequestHandler::OnResourceResponse() method for inspecting the request/response headers and potentially restarting or redirecting the request. - Add a new CefRequest::GetIdentifier() method for tracking a request across multiple CefRequestHandler callbacks. - Pass a CefRequest object instead of just the old URL to CefRequestHandler::OnResourceRedirect(). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@2073 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
#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/response_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h"
|
||||
|
||||
@ -155,7 +156,7 @@ struct _cef_resource_handler_t* CEF_CALLBACK request_handler_get_resource_handle
|
||||
|
||||
void CEF_CALLBACK request_handler_on_resource_redirect(
|
||||
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
||||
cef_frame_t* frame, const cef_string_t* old_url, cef_string_t* new_url) {
|
||||
cef_frame_t* frame, cef_request_t* request, cef_string_t* new_url) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
@ -169,9 +170,9 @@ void CEF_CALLBACK request_handler_on_resource_redirect(
|
||||
DCHECK(frame);
|
||||
if (!frame)
|
||||
return;
|
||||
// Verify param: old_url; type: string_byref_const
|
||||
DCHECK(old_url);
|
||||
if (!old_url)
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return;
|
||||
// Verify param: new_url; type: string_byref
|
||||
DCHECK(new_url);
|
||||
@ -185,10 +186,47 @@ void CEF_CALLBACK request_handler_on_resource_redirect(
|
||||
CefRequestHandlerCppToC::Get(self)->OnResourceRedirect(
|
||||
CefBrowserCToCpp::Wrap(browser),
|
||||
CefFrameCToCpp::Wrap(frame),
|
||||
CefString(old_url),
|
||||
CefRequestCToCpp::Wrap(request),
|
||||
new_urlStr);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK request_handler_on_resource_response(
|
||||
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
||||
cef_frame_t* frame, cef_request_t* request,
|
||||
struct _cef_response_t* response) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser)
|
||||
return 0;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame);
|
||||
if (!frame)
|
||||
return 0;
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return 0;
|
||||
// Verify param: response; type: refptr_diff
|
||||
DCHECK(response);
|
||||
if (!response)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefRequestHandlerCppToC::Get(self)->OnResourceResponse(
|
||||
CefBrowserCToCpp::Wrap(browser),
|
||||
CefFrameCToCpp::Wrap(frame),
|
||||
CefRequestCToCpp::Wrap(request),
|
||||
CefResponseCToCpp::Wrap(response));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK request_handler_get_auth_credentials(
|
||||
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
||||
cef_frame_t* frame, int isProxy, const cef_string_t* host, int port,
|
||||
@ -445,6 +483,7 @@ CefRequestHandlerCppToC::CefRequestHandlerCppToC(CefRequestHandler* cls)
|
||||
request_handler_on_before_resource_load;
|
||||
struct_.struct_.get_resource_handler = request_handler_get_resource_handler;
|
||||
struct_.struct_.on_resource_redirect = request_handler_on_resource_redirect;
|
||||
struct_.struct_.on_resource_response = request_handler_on_resource_response;
|
||||
struct_.struct_.get_auth_credentials = request_handler_get_auth_credentials;
|
||||
struct_.struct_.on_quota_request = request_handler_on_quota_request;
|
||||
struct_.struct_.on_protocol_execution = request_handler_on_protocol_execution;
|
||||
|
Reference in New Issue
Block a user