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:
@ -19,6 +19,7 @@
|
||||
#include "libcef_dll/cpptoc/sslinfo_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/resource_handler_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/response_filter_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
@ -226,6 +227,44 @@ bool CefRequestHandlerCToCpp::OnResourceResponse(CefRefPtr<CefBrowser> browser,
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefResponseFilter> CefRequestHandlerCToCpp::GetResourceResponseFilter(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response) {
|
||||
cef_request_handler_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_resource_response_filter))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return NULL;
|
||||
// Verify param: frame; type: refptr_diff
|
||||
DCHECK(frame.get());
|
||||
if (!frame.get())
|
||||
return NULL;
|
||||
// Verify param: request; type: refptr_diff
|
||||
DCHECK(request.get());
|
||||
if (!request.get())
|
||||
return NULL;
|
||||
// Verify param: response; type: refptr_diff
|
||||
DCHECK(response.get());
|
||||
if (!response.get())
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
cef_response_filter_t* _retval = _struct->get_resource_response_filter(
|
||||
_struct,
|
||||
CefBrowserCppToC::Wrap(browser),
|
||||
CefFrameCppToC::Wrap(frame),
|
||||
CefRequestCppToC::Wrap(request),
|
||||
CefResponseCppToC::Wrap(response));
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefResponseFilterCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
void CefRequestHandlerCToCpp::OnResourceLoadComplete(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response,
|
||||
|
@ -48,6 +48,10 @@ class CefRequestHandlerCToCpp
|
||||
bool OnResourceResponse(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefResponse> response) override;
|
||||
CefRefPtr<CefResponseFilter> GetResourceResponseFilter(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefResponse> response) override;
|
||||
void OnResourceLoadComplete(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefResponse> response, URLRequestStatus status,
|
||||
|
79
libcef_dll/ctocpp/response_filter_ctocpp.cc
Normal file
79
libcef_dll/ctocpp/response_filter_ctocpp.cc
Normal file
@ -0,0 +1,79 @@
|
||||
// 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/response_filter_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefResponseFilterCToCpp::InitFilter() {
|
||||
cef_response_filter_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, init_filter))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->init_filter(_struct);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefResponseFilter::FilterStatus CefResponseFilterCToCpp::Filter(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) {
|
||||
cef_response_filter_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, filter))
|
||||
return RESPONSE_FILTER_ERROR;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: data_out; type: simple_byaddr
|
||||
DCHECK(data_out);
|
||||
if (!data_out)
|
||||
return RESPONSE_FILTER_ERROR;
|
||||
// Unverified params: data_in
|
||||
|
||||
// Execute
|
||||
cef_response_filter_status_t _retval = _struct->filter(_struct,
|
||||
data_in,
|
||||
data_in_size,
|
||||
&data_in_read,
|
||||
data_out,
|
||||
data_out_size,
|
||||
&data_out_written);
|
||||
|
||||
// Return type: simple
|
||||
return _retval;
|
||||
}
|
||||
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefResponseFilterCToCpp::CefResponseFilterCToCpp() {
|
||||
}
|
||||
|
||||
template<> cef_response_filter_t* CefCToCpp<CefResponseFilterCToCpp,
|
||||
CefResponseFilter, cef_response_filter_t>::UnwrapDerived(
|
||||
CefWrapperType type, CefResponseFilter* c) {
|
||||
NOTREACHED() << "Unexpected class type: " << type;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> base::AtomicRefCount CefCToCpp<CefResponseFilterCToCpp,
|
||||
CefResponseFilter, cef_response_filter_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
||||
template<> CefWrapperType CefCToCpp<CefResponseFilterCToCpp, CefResponseFilter,
|
||||
cef_response_filter_t>::kWrapperType = WT_RESPONSE_FILTER;
|
41
libcef_dll/ctocpp/response_filter_ctocpp.h
Normal file
41
libcef_dll/ctocpp/response_filter_ctocpp.h
Normal file
@ -0,0 +1,41 @@
|
||||
// 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_RESPONSE_FILTER_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_RESPONSE_FILTER_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#ifndef BUILDING_CEF_SHARED
|
||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||
#else // BUILDING_CEF_SHARED
|
||||
|
||||
#include "include/cef_response_filter.h"
|
||||
#include "include/capi/cef_response_filter_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefResponseFilterCToCpp
|
||||
: public CefCToCpp<CefResponseFilterCToCpp, CefResponseFilter,
|
||||
cef_response_filter_t> {
|
||||
public:
|
||||
CefResponseFilterCToCpp();
|
||||
|
||||
// CefResponseFilter methods.
|
||||
bool InitFilter() override;
|
||||
FilterStatus Filter(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) override;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_RESPONSE_FILTER_CTOCPP_H_
|
Reference in New Issue
Block a user