| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "content/public/browser/download_interrupt_reasons.h" | 12 #include "content/common/content_export.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 class URLRequest; | 15 class URLRequest; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class DownloadItem; | 20 class DownloadItem; |
| 21 class ResourceContext; | 21 class ResourceContext; |
| 22 class ResourceDispatcherHostDelegate; | 22 class ResourceDispatcherHostDelegate; |
| 23 struct DownloadSaveInfo; | 23 struct DownloadSaveInfo; |
| 24 struct Referrer; | 24 struct Referrer; |
| 25 class RenderFrameHost; | 25 class RenderFrameHost; |
| 26 | 26 |
| 27 class CONTENT_EXPORT ResourceDispatcherHost { | 27 class CONTENT_EXPORT ResourceDispatcherHost { |
| 28 public: | 28 public: |
| 29 typedef base::Callback<void(DownloadItem*, DownloadInterruptReason)> | |
| 30 DownloadStartedCallback; | |
| 31 | |
| 32 // Returns the singleton instance of the ResourceDispatcherHost. | 29 // Returns the singleton instance of the ResourceDispatcherHost. |
| 33 static ResourceDispatcherHost* Get(); | 30 static ResourceDispatcherHost* Get(); |
| 34 | 31 |
| 35 // Causes all new requests for the root RenderFrameHost and its children to be | 32 // Causes all new requests for the root RenderFrameHost and its children to be |
| 36 // blocked (not being started) until ResumeBlockedRequestsForFrameFromUI is | 33 // blocked (not being started) until ResumeBlockedRequestsForFrameFromUI is |
| 37 // called. | 34 // called. |
| 38 static void BlockRequestsForFrameFromUI(RenderFrameHost* root_frame_host); | 35 static void BlockRequestsForFrameFromUI(RenderFrameHost* root_frame_host); |
| 39 | 36 |
| 40 // Resumes any blocked request for the specified root RenderFrameHost and | 37 // Resumes any blocked request for the specified root RenderFrameHost and |
| 41 // child frame hosts. | 38 // child frame hosts. |
| 42 static void ResumeBlockedRequestsForFrameFromUI( | 39 static void ResumeBlockedRequestsForFrameFromUI( |
| 43 RenderFrameHost* root_frame_host); | 40 RenderFrameHost* root_frame_host); |
| 44 | 41 |
| 45 // This does not take ownership of the delegate. It is expected that the | 42 // This does not take ownership of the delegate. It is expected that the |
| 46 // delegate have a longer lifetime than the ResourceDispatcherHost. | 43 // delegate have a longer lifetime than the ResourceDispatcherHost. |
| 47 virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) = 0; | 44 virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) = 0; |
| 48 | 45 |
| 49 // Controls whether third-party sub-content can pop-up HTTP basic auth | 46 // Controls whether third-party sub-content can pop-up HTTP basic auth |
| 50 // dialog boxes. | 47 // dialog boxes. |
| 51 virtual void SetAllowCrossOriginAuthPrompt(bool value) = 0; | 48 virtual void SetAllowCrossOriginAuthPrompt(bool value) = 0; |
| 52 | 49 |
| 53 // Initiates a download by explicit request of the renderer (e.g. due to | |
| 54 // alt-clicking a link) or some other chrome subsystem. | |
| 55 // |is_content_initiated| is used to indicate that the request was generated | |
| 56 // from a web page, and hence may not be as trustworthy as a browser | |
| 57 // generated request. If |download_id| is invalid, a download id will be | |
| 58 // automatically assigned to the request, otherwise the specified download id | |
| 59 // will be used. (Note that this will result in re-use of an existing | |
| 60 // download item if the download id was already assigned.) If the download | |
| 61 // is started, |started_callback| will be called on the UI thread with the | |
| 62 // DownloadItem; otherwise an interrupt reason will be returned. | |
| 63 virtual DownloadInterruptReason BeginDownload( | |
| 64 scoped_ptr<net::URLRequest> request, | |
| 65 const Referrer& referrer, | |
| 66 bool is_content_initiated, | |
| 67 ResourceContext* context, | |
| 68 int child_id, | |
| 69 int render_view_route_id, | |
| 70 int render_frame_route_id, | |
| 71 bool prefer_cache, | |
| 72 bool do_not_prompt_for_login, | |
| 73 scoped_ptr<DownloadSaveInfo> save_info, | |
| 74 uint32_t download_id, | |
| 75 const DownloadStartedCallback& started_callback) = 0; | |
| 76 | |
| 77 // Clears the ResourceDispatcherHostLoginDelegate associated with the request. | 50 // Clears the ResourceDispatcherHostLoginDelegate associated with the request. |
| 78 virtual void ClearLoginDelegateForRequest(net::URLRequest* request) = 0; | 51 virtual void ClearLoginDelegateForRequest(net::URLRequest* request) = 0; |
| 79 | 52 |
| 80 protected: | 53 protected: |
| 81 virtual ~ResourceDispatcherHost() {} | 54 virtual ~ResourceDispatcherHost() {} |
| 82 }; | 55 }; |
| 83 | 56 |
| 84 } // namespace content | 57 } // namespace content |
| 85 | 58 |
| 86 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ | 59 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ |
| OLD | NEW |