Add OnResourceReponse and CefContentFilter for viewing and filtering response content (issue #241).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@243 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-05-23 23:39:07 +00:00
parent 338b9c0cc9
commit 73f4d5a5e6
14 changed files with 603 additions and 5 deletions

View File

@@ -0,0 +1,69 @@
// Copyright (c) 2011 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.
//
// ---------------------------------------------------------------------------
//
// A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/content_filter_cpptoc.h"
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK content_filter_process_data(
struct _cef_content_filter_t* self, const void* data, int data_size,
cef_stream_reader_t** substitute_data)
{
DCHECK(self);
DCHECK(data);
DCHECK(substitute_data);
if (!self || !data || !substitute_data)
return;
CefRefPtr<CefStreamReader> substituteDataPtr;
CefContentFilterCppToC::Get(self)->ProcessData(data, data_size,
substituteDataPtr);
if(substituteDataPtr.get())
*substitute_data = CefStreamReaderCToCpp::Unwrap(substituteDataPtr);
}
void CEF_CALLBACK content_filter_drain(struct _cef_content_filter_t* self,
cef_stream_reader_t** remainder)
{
DCHECK(self);
DCHECK(remainder);
if (!self || !remainder)
return;
CefRefPtr<CefStreamReader> remainderPtr;
CefContentFilterCppToC::Get(self)->Drain(remainderPtr);
if(remainderPtr.get())
*remainder = CefStreamReaderCToCpp::Unwrap(remainderPtr);
}
// CONSTRUCTOR - Do not edit by hand.
CefContentFilterCppToC::CefContentFilterCppToC(CefContentFilter* cls)
: CefCppToC<CefContentFilterCppToC, CefContentFilter, cef_content_filter_t>(
cls)
{
struct_.struct_.process_data = content_filter_process_data;
struct_.struct_.drain = content_filter_drain;
}
#ifndef NDEBUG
template<> long CefCppToC<CefContentFilterCppToC, CefContentFilter,
cef_content_filter_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,35 @@
// Copyright (c) 2011 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 and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef _CONTENTFILTER_CPPTOC_H
#define _CONTENTFILTER_CPPTOC_H
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_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 CefContentFilterCppToC
: public CefCppToC<CefContentFilterCppToC, CefContentFilter,
cef_content_filter_t>
{
public:
CefContentFilterCppToC(CefContentFilter* cls);
virtual ~CefContentFilterCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // _CONTENTFILTER_CPPTOC_H

View File

@@ -10,6 +10,7 @@
// for more information.
//
#include "libcef_dll/cpptoc/content_filter_cpptoc.h"
#include "libcef_dll/cpptoc/download_handler_cpptoc.h"
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
@@ -67,6 +68,29 @@ int CEF_CALLBACK request_handler_on_before_resource_load(
return rv;
}
void CEF_CALLBACK request_handler_on_resource_reponse(
struct _cef_request_handler_t* self, cef_browser_t* browser,
const cef_string_t* url, struct _cef_response_t* response,
struct _cef_content_filter_t** filter)
{
DCHECK(self);
DCHECK(browser);
DCHECK(url);
DCHECK(response);
DCHECK(filter);
if (!self || !browser || !url || !response || !filter)
return;
CefRefPtr<CefContentFilter> filterPtr;
CefRequestHandlerCppToC::Get(self)->OnResourceReponse(
CefBrowserCToCpp::Wrap(browser), url, CefResponseCToCpp::Wrap(response),
filterPtr);
if(filterPtr.get())
*filter = CefContentFilterCppToC::Wrap(filterPtr);
}
int CEF_CALLBACK request_handler_on_protocol_execution(
struct _cef_request_handler_t* self, cef_browser_t* browser,
const cef_string_t* url, int* allowOSExecution)
@@ -145,6 +169,7 @@ CefRequestHandlerCppToC::CefRequestHandlerCppToC(CefRequestHandler* cls)
struct_.struct_.on_before_browse = request_handler_on_before_browse;
struct_.struct_.on_before_resource_load =
request_handler_on_before_resource_load;
struct_.struct_.on_resource_reponse = request_handler_on_resource_reponse;
struct_.struct_.on_protocol_execution = request_handler_on_protocol_execution;
struct_.struct_.get_download_handler = request_handler_get_download_handler;
struct_.struct_.get_auth_credentials = request_handler_get_auth_credentials;