#ifndef CHROME_RENDERER_SECURITY_FILTER_PEER_H_
#define CHROME_RENDERER_SECURITY_FILTER_PEER_H_
#include "content/public/child/request_peer.h"
#include "webkit/common/resource_response_info.h"
#include "webkit/common/resource_type.h"
namespace webkit_glue {
class ResourceLoaderBridge;
}
class SecurityFilterPeer : public content::RequestPeer {
public:
virtual ~SecurityFilterPeer();
static SecurityFilterPeer* CreateSecurityFilterPeerForDeniedRequest(
ResourceType::Type resource_type,
content::RequestPeer* peer,
int os_error);
static SecurityFilterPeer* CreateSecurityFilterPeerForFrame(
content::RequestPeer* peer,
int os_error);
virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE;
virtual bool OnReceivedRedirect(const GURL& new_url,
const webkit_glue::ResourceResponseInfo& info,
bool* has_new_first_party_for_cookies,
GURL* new_first_party_for_cookies) OVERRIDE;
virtual void OnReceivedResponse(
const webkit_glue::ResourceResponseInfo& info) OVERRIDE;
virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE {}
virtual void OnReceivedData(const char* data,
int data_length,
int encoded_data_length) OVERRIDE;
virtual void OnCompletedRequest(int error_code,
bool was_ignored_by_handler,
bool stale_copy_in_cache,
const std::string& security_info,
const base::TimeTicks& completion_time,
int64 total_transfer_size) OVERRIDE;
protected:
SecurityFilterPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
content::RequestPeer* peer);
content::RequestPeer* original_peer_;
webkit_glue::ResourceLoaderBridge* resource_loader_bridge_;
private:
DISALLOW_COPY_AND_ASSIGN(SecurityFilterPeer);
};
class BufferedPeer : public SecurityFilterPeer {
public:
BufferedPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
content::RequestPeer* peer,
const std::string& mime_type);
virtual ~BufferedPeer();
virtual void OnReceivedResponse(
const webkit_glue::ResourceResponseInfo& info) OVERRIDE;
virtual void OnReceivedData(const char* data,
int data_length,
int encoded_data_length) OVERRIDE;
virtual void OnCompletedRequest(
int error_code,
bool was_ignored_by_handler,
bool stale_copy_in_cache,
const std::string& security_info,
const base::TimeTicks& completion_time,
int64 total_transfer_size) OVERRIDE;
protected:
virtual bool DataReady() = 0;
webkit_glue::ResourceResponseInfo response_info_;
std::string data_;
private:
std::string mime_type_;
DISALLOW_COPY_AND_ASSIGN(BufferedPeer);
};
class ReplaceContentPeer : public SecurityFilterPeer {
public:
ReplaceContentPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
content::RequestPeer* peer,
const std::string& mime_type,
const std::string& data);
virtual ~ReplaceContentPeer();
virtual void OnReceivedResponse(
const webkit_glue::ResourceResponseInfo& info) OVERRIDE;
virtual void OnReceivedData(const char* data,
int data_length,
int encoded_data_length) OVERRIDE;
virtual void OnCompletedRequest(
int error_code,
bool was_ignored_by_handler,
bool stale_copy_in_cache,
const std::string& security_info,
const base::TimeTicks& completion_time,
int64 total_transfer_size) OVERRIDE;
private:
webkit_glue::ResourceResponseInfo response_info_;
std::string mime_type_;
std::string data_;
DISALLOW_COPY_AND_ASSIGN(ReplaceContentPeer);
};
#endif