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