#ifndef CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
#define CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
#include <set>
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/external_protocol/external_protocol_handler.h"
#include "content/public/browser/resource_dispatcher_host_delegate.h"
class DelayedResourceQueue;
class DownloadRequestLimiter;
class SafeBrowsingService;
namespace extensions {
class UserScriptListener;
}
namespace prerender {
class PrerenderTracker;
}
class ChromeResourceDispatcherHostDelegate
: public content::ResourceDispatcherHostDelegate {
public:
explicit ChromeResourceDispatcherHostDelegate(
prerender::PrerenderTracker* prerender_tracker);
virtual ~ChromeResourceDispatcherHostDelegate();
virtual bool ShouldBeginRequest(
int child_id,
int route_id,
const std::string& method,
const GURL& url,
ResourceType::Type resource_type,
content::ResourceContext* resource_context) OVERRIDE;
virtual void RequestBeginning(
net::URLRequest* request,
content::ResourceContext* resource_context,
appcache::AppCacheService* appcache_service,
ResourceType::Type resource_type,
int child_id,
int route_id,
ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
virtual void DownloadStarting(
net::URLRequest* request,
content::ResourceContext* resource_context,
int child_id,
int route_id,
int request_id,
bool is_content_initiated,
bool must_download,
ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
net::AuthChallengeInfo* auth_info, net::URLRequest* request) OVERRIDE;
virtual bool HandleExternalProtocol(const GURL& url,
int child_id,
int route_id,
bool initiated_by_user_gesture) OVERRIDE;
virtual bool ShouldForceDownloadResource(
const GURL& url, const std::string& mime_type) OVERRIDE;
virtual bool ShouldInterceptResourceAsStream(
content::ResourceContext* resource_context,
const GURL& url,
const std::string& mime_type,
GURL* origin,
std::string* target_id) OVERRIDE;
virtual void OnStreamCreated(
content::ResourceContext* resource_context,
int render_process_id,
int render_view_id,
const std::string& target_id,
scoped_ptr<content::StreamHandle> stream,
int64 expected_content_size) OVERRIDE;
virtual void OnResponseStarted(
net::URLRequest* request,
content::ResourceContext* resource_context,
content::ResourceResponse* response,
IPC::Sender* sender) OVERRIDE;
virtual void OnRequestRedirected(
const GURL& redirect_url,
net::URLRequest* request,
content::ResourceContext* resource_context,
content::ResourceResponse* response) OVERRIDE;
virtual void RequestComplete(net::URLRequest* url_request) OVERRIDE;
static void SetExternalProtocolHandlerDelegateForTesting(
ExternalProtocolHandler::Delegate* delegate);
private:
void AppendStandardResourceThrottles(
net::URLRequest* request,
content::ResourceContext* resource_context,
ResourceType::Type resource_type,
ScopedVector<content::ResourceThrottle>* throttles);
#if defined(ENABLE_ONE_CLICK_SIGNIN)
void AppendChromeSyncGaiaHeader(
net::URLRequest* request,
content::ResourceContext* resource_context);
#endif
scoped_refptr<DownloadRequestLimiter> download_request_limiter_;
scoped_refptr<SafeBrowsingService> safe_browsing_;
scoped_refptr<extensions::UserScriptListener> user_script_listener_;
prerender::PrerenderTracker* prerender_tracker_;
DISALLOW_COPY_AND_ASSIGN(ChromeResourceDispatcherHostDelegate);
};
#endif