- Code: Select all
class CefHandler : public CefBase
{
public:
...
...
// Called on the UI thread after a response to the resource request is
// received. Set |filter| if response content needs to be monitored
// and/or modified as it arrives. The return value is currently ignored.
/*--cef()--*/
virtual RetVal HandleResourceReponse(CefRefPtr<CefBrowser> browser,
const CefString& url,
CefRefPtr<CefResponse> response,
CefRefPtr<CefContentFilter>& filter) =0;
...
...
};
// Class used to represent a content filter interface. The methods of
// this class will always be called on the UI thread.
/*--cef(source=client)--*/
class CefContentFilter : public CefBase
{
public:
// Set |substitute_data| to the replacement for the data in |data|
// if data should be modified. The return value is currently ignored.
/*--cef()--*/
virtual bool ProcessData(void* data, int data_size, CefRefPtr<CefStreamReader>& substitute_data) =0;
// Called when there is no more data to be processed. It is expected
// that whatever data was retained in the last ProcessData() call,
// it should be returned now by setting |remainder| if appropriate.
// The return value is currently ignored.
/*--cef()--*/
virtual bool Drain(CefRefPtr<CefStreamReader>& remainder) =0;
};
I think CefHandler::HandleResourceResponse() has merit on its own even without the filter, as it gives the user the opportunity to peek into the actual response headers.
Not really sure if CefStreamReader is the best and most semantically correct class to use to pass the modified content back to CEF. Suggestions welcome.