mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for response filtering (issue #515).
- Add a new CefRequestHandler::GetResourceResponseFilter method and CefResponseFilter class.
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
|
||||
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/resource_handler_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/response_filter_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/auth_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/frame_ctocpp.h"
|
||||
@ -234,6 +235,44 @@ int CEF_CALLBACK request_handler_on_resource_response(
|
||||
return _retval;
|
||||
}
|
||||
|
||||
struct _cef_response_filter_t* CEF_CALLBACK request_handler_get_resource_response_filter(
|
||||
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 NULL;
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser)
|
||||
return NULL;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame);
|
||||
if (!frame)
|
||||
return NULL;
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request);
|
||||
if (!request)
|
||||
return NULL;
|
||||
// Verify param: response; type: refptr_diff
|
||||
DCHECK(response);
|
||||
if (!response)
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
CefRefPtr<CefResponseFilter> _retval = CefRequestHandlerCppToC::Get(
|
||||
self)->GetResourceResponseFilter(
|
||||
CefBrowserCToCpp::Wrap(browser),
|
||||
CefFrameCToCpp::Wrap(frame),
|
||||
CefRequestCToCpp::Wrap(request),
|
||||
CefResponseCToCpp::Wrap(response));
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefResponseFilterCppToC::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_handler_on_resource_load_complete(
|
||||
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
||||
cef_frame_t* frame, cef_request_t* request,
|
||||
@ -497,6 +536,8 @@ CefRequestHandlerCppToC::CefRequestHandlerCppToC() {
|
||||
GetStruct()->get_resource_handler = request_handler_get_resource_handler;
|
||||
GetStruct()->on_resource_redirect = request_handler_on_resource_redirect;
|
||||
GetStruct()->on_resource_response = request_handler_on_resource_response;
|
||||
GetStruct()->get_resource_response_filter =
|
||||
request_handler_get_resource_response_filter;
|
||||
GetStruct()->on_resource_load_complete =
|
||||
request_handler_on_resource_load_complete;
|
||||
GetStruct()->get_auth_credentials = request_handler_get_auth_credentials;
|
||||
|
107
libcef_dll/cpptoc/response_filter_cpptoc.cc
Normal file
107
libcef_dll/cpptoc/response_filter_cpptoc.cc
Normal file
@ -0,0 +1,107 @@
|
||||
// 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/response_filter_cpptoc.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK response_filter_init_filter(
|
||||
struct _cef_response_filter_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefResponseFilterCppToC::Get(self)->InitFilter();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_response_filter_status_t CEF_CALLBACK response_filter_filter(
|
||||
struct _cef_response_filter_t* self, void* data_in, size_t data_in_size,
|
||||
size_t* data_in_read, void* data_out, size_t data_out_size,
|
||||
size_t* data_out_written) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return RESPONSE_FILTER_ERROR;
|
||||
// Verify param: data_in_read; type: simple_byref
|
||||
DCHECK(data_in_read);
|
||||
if (!data_in_read)
|
||||
return RESPONSE_FILTER_ERROR;
|
||||
// Verify param: data_out; type: simple_byaddr
|
||||
DCHECK(data_out);
|
||||
if (!data_out)
|
||||
return RESPONSE_FILTER_ERROR;
|
||||
// Verify param: data_out_written; type: simple_byref
|
||||
DCHECK(data_out_written);
|
||||
if (!data_out_written)
|
||||
return RESPONSE_FILTER_ERROR;
|
||||
// Unverified params: data_in
|
||||
|
||||
// Translate param: data_in_read; type: simple_byref
|
||||
size_t data_in_readVal = data_in_read?*data_in_read:0;
|
||||
// Translate param: data_out_written; type: simple_byref
|
||||
size_t data_out_writtenVal = data_out_written?*data_out_written:0;
|
||||
|
||||
// Execute
|
||||
cef_response_filter_status_t _retval = CefResponseFilterCppToC::Get(
|
||||
self)->Filter(
|
||||
data_in,
|
||||
data_in_size,
|
||||
data_in_readVal,
|
||||
data_out,
|
||||
data_out_size,
|
||||
data_out_writtenVal);
|
||||
|
||||
// Restore param: data_in_read; type: simple_byref
|
||||
if (data_in_read)
|
||||
*data_in_read = data_in_readVal;
|
||||
// Restore param: data_out_written; type: simple_byref
|
||||
if (data_out_written)
|
||||
*data_out_written = data_out_writtenVal;
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefResponseFilterCppToC::CefResponseFilterCppToC() {
|
||||
GetStruct()->init_filter = response_filter_init_filter;
|
||||
GetStruct()->filter = response_filter_filter;
|
||||
}
|
||||
|
||||
template<> CefRefPtr<CefResponseFilter> CefCppToC<CefResponseFilterCppToC,
|
||||
CefResponseFilter, cef_response_filter_t>::UnwrapDerived(
|
||||
CefWrapperType type, cef_response_filter_t* s) {
|
||||
NOTREACHED() << "Unexpected class type: " << type;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> base::AtomicRefCount CefCppToC<CefResponseFilterCppToC,
|
||||
CefResponseFilter, cef_response_filter_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
||||
template<> CefWrapperType CefCppToC<CefResponseFilterCppToC, CefResponseFilter,
|
||||
cef_response_filter_t>::kWrapperType = WT_RESPONSE_FILTER;
|
35
libcef_dll/cpptoc/response_filter_cpptoc.h
Normal file
35
libcef_dll/cpptoc/response_filter_cpptoc.h
Normal file
@ -0,0 +1,35 @@
|
||||
// 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_RESPONSE_FILTER_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_RESPONSE_FILTER_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_response_filter.h"
|
||||
#include "include/capi/cef_response_filter_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 CefResponseFilterCppToC
|
||||
: public CefCppToC<CefResponseFilterCppToC, CefResponseFilter,
|
||||
cef_response_filter_t> {
|
||||
public:
|
||||
CefResponseFilterCppToC();
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_RESPONSE_FILTER_CPPTOC_H_
|
Reference in New Issue
Block a user