resource_dispatcher_host.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ 6#define CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ 7 8#include "base/callback_forward.h" 9#include "net/base/net_errors.h" 10 11namespace net { 12class URLRequest; 13} 14 15namespace content { 16 17class DownloadItem; 18class ResourceContext; 19class ResourceDispatcherHostDelegate; 20struct DownloadSaveInfo; 21 22class CONTENT_EXPORT ResourceDispatcherHost { 23 public: 24 typedef base::Callback<void(DownloadItem*, net::Error)> 25 DownloadStartedCallback; 26 27 // Returns the singleton instance of the ResourceDispatcherHost. 28 static ResourceDispatcherHost* Get(); 29 30 // This does not take ownership of the delegate. It is expected that the 31 // delegate have a longer lifetime than the ResourceDispatcherHost. 32 virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) = 0; 33 34 // Controls whether third-party sub-content can pop-up HTTP basic auth 35 // dialog boxes. 36 virtual void SetAllowCrossOriginAuthPrompt(bool value) = 0; 37 38 // Initiates a download by explicit request of the renderer, e.g. due to 39 // alt-clicking a link. If the download is started, |started_callback| will 40 // be called on the UI thread with the DownloadItem; otherwise an error code 41 // will be returned. |is_content_initiated| is used to indicate that the 42 // request was generated from a web page, and hence may not be as trustworthy 43 // as a browser generated request. 44 virtual net::Error BeginDownload( 45 scoped_ptr<net::URLRequest> request, 46 bool is_content_initiated, 47 ResourceContext* context, 48 int child_id, 49 int route_id, 50 bool prefer_cache, 51 scoped_ptr<DownloadSaveInfo> save_info, 52 const DownloadStartedCallback& started_callback) = 0; 53 54 // Clears the ResourceDispatcherHostLoginDelegate associated with the request. 55 virtual void ClearLoginDelegateForRequest(net::URLRequest* request) = 0; 56 57 // Causes all new requests for the route identified by |child_id| and 58 // |route_id| to be blocked (not being started) until 59 // ResumeBlockedRequestsForRoute is called. 60 virtual void BlockRequestsForRoute(int child_id, int route_id) = 0; 61 62 // Resumes any blocked request for the specified route id. 63 virtual void ResumeBlockedRequestsForRoute(int child_id, int route_id) = 0; 64 65 protected: 66 virtual ~ResourceDispatcherHost() {} 67}; 68 69} // namespace content 70 71#endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ 72