resource_dispatcher_host.h revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Copyright (c) 2012 The Chromium Authors. All rights reserved. 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Use of this source code is governed by a BSD-style license that can be 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// found in the LICENSE file. 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "base/callback_forward.h" 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "content/public/browser/download_id.h" 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "net/base/net_errors.h" 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace net { 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass URLRequest; 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace content { 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DownloadItem; 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ResourceContext; 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ResourceDispatcherHostDelegate; 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DownloadSaveInfo; 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Referrer; 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CONTENT_EXPORT ResourceDispatcherHost { 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry public: 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef base::Callback<void(DownloadItem*, net::Error)> 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DownloadStartedCallback; 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Returns the singleton instance of the ResourceDispatcherHost. 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static ResourceDispatcherHost* Get(); 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // This does not take ownership of the delegate. It is expected that the 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // delegate have a longer lifetime than the ResourceDispatcherHost. 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) = 0; 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Controls whether third-party sub-content can pop-up HTTP basic auth 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // dialog boxes. 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void SetAllowCrossOriginAuthPrompt(bool value) = 0; 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Initiates a download by explicit request of the renderer (e.g. due to 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // alt-clicking a link) or some other chrome subsystem. 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // |is_content_initiated| is used to indicate that the request was generated 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // from a web page, and hence may not be as trustworthy as a browser 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // generated request. If |download_id| is invalid, a download id will be 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // automatically assigned to the request, otherwise the specified download id 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // will be used. (Note that this will result in re-use of an existing 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // download item if the download id was already assigned.) If the download 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // is started, |started_callback| will be called on the UI thread with the 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // DownloadItem; otherwise an error code will be returned. 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual net::Error BeginDownload( 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scoped_ptr<net::URLRequest> request, 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Referrer& referrer, 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool is_content_initiated, 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ResourceContext* context, 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int child_id, 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int route_id, 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool prefer_cache, 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scoped_ptr<DownloadSaveInfo> save_info, 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry content::DownloadId download_id, 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const DownloadStartedCallback& started_callback) = 0; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clears the ResourceDispatcherHostLoginDelegate associated with the request. 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void ClearLoginDelegateForRequest(net::URLRequest* request) = 0; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Causes all new requests for the route identified by |child_id| and 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // |route_id| to be blocked (not being started) until 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // ResumeBlockedRequestsForRoute is called. 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void BlockRequestsForRoute(int child_id, int route_id) = 0; 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Resumes any blocked request for the specified route id. 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void ResumeBlockedRequestsForRoute(int child_id, int route_id) = 0; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry protected: 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~ResourceDispatcherHost() {} 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // namespace content 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry