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