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,49 @@
// 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 static and
// virtual method implementations. See the translator.README.txt file in the
// tools directory for more information.
//
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
#include "libcef_dll/ctocpp/content_filter_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
void CefContentFilterCToCpp::ProcessData(const void* data, int data_size,
CefRefPtr<CefStreamReader>& substitute_data)
{
if (CEF_MEMBER_MISSING(struct_, process_data))
return;
cef_stream_reader_t* streamRet = NULL;
struct_->process_data(struct_, data, data_size, &streamRet);
if(streamRet)
substitute_data = CefStreamReaderCppToC::Unwrap(streamRet);
}
void CefContentFilterCToCpp::Drain(CefRefPtr<CefStreamReader>& remainder)
{
if (CEF_MEMBER_MISSING(struct_, drain))
return;
cef_stream_reader_t* streamRet = NULL;
struct_->drain(struct_, &streamRet);
if(streamRet)
remainder = CefStreamReaderCppToC::Unwrap(streamRet);
}
#ifndef NDEBUG
template<> long CefCToCpp<CefContentFilterCToCpp, CefContentFilter,
cef_content_filter_t>::DebugObjCt = 0;
#endif

View File

@@ -0,0 +1,43 @@
// 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_CTOCPP_H
#define _CONTENTFILTER_CTOCPP_H
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef.h"
#include "include/cef_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 CefContentFilterCToCpp
: public CefCToCpp<CefContentFilterCToCpp, CefContentFilter,
cef_content_filter_t>
{
public:
CefContentFilterCToCpp(cef_content_filter_t* str)
: CefCToCpp<CefContentFilterCToCpp, CefContentFilter,
cef_content_filter_t>(str) {}
virtual ~CefContentFilterCToCpp() {}
// CefContentFilter methods
virtual void ProcessData(const void* data, int data_size,
CefRefPtr<CefStreamReader>& substitute_data) OVERRIDE;
virtual void Drain(CefRefPtr<CefStreamReader>& remainder) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED
#endif // _CONTENTFILTER_CTOCPP_H

View File

@@ -15,6 +15,7 @@
#include "libcef_dll/cpptoc/request_cpptoc.h"
#include "libcef_dll/cpptoc/response_cpptoc.h"
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
#include "libcef_dll/ctocpp/content_filter_ctocpp.h"
#include "libcef_dll/ctocpp/download_handler_ctocpp.h"
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
@@ -54,6 +55,23 @@ bool CefRequestHandlerCToCpp::OnBeforeResourceLoad(
return (rv ? true : false);
}
void CefRequestHandlerCToCpp::OnResourceReponse(CefRefPtr<CefBrowser> browser,
const CefString& url, CefRefPtr<CefResponse> response,
CefRefPtr<CefContentFilter>& filter)
{
if (CEF_MEMBER_MISSING(struct_, on_resource_reponse))
return;
cef_content_filter_t* filterRet = NULL;
struct_->on_resource_reponse(struct_,
CefBrowserCppToC::Wrap(browser), url.GetStruct(),
CefResponseCppToC::Wrap(response), &filterRet);
if(filterRet)
filter = CefContentFilterCToCpp::Wrap(filterRet);
}
bool CefRequestHandlerCToCpp::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
const CefString& url, bool& allowOSExecution)
{

View File

@@ -40,6 +40,9 @@ public:
CefRefPtr<CefRequest> request, CefString& redirectUrl,
CefRefPtr<CefStreamReader>& resourceStream,
CefRefPtr<CefResponse> response, int loadFlags) OVERRIDE;
virtual void OnResourceReponse(CefRefPtr<CefBrowser> browser,
const CefString& url, CefRefPtr<CefResponse> response,
CefRefPtr<CefContentFilter>& filter) OVERRIDE;
virtual bool OnProtocolExecution(CefRefPtr<CefBrowser> browser,
const CefString& url, bool& allowOSExecution) OVERRIDE;
virtual bool GetDownloadHandler(CefRefPtr<CefBrowser> browser,