Chromium Code Reviews| 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 <memory> | 10 #include <memory> |
| 11 #include <string> | |
| 11 | 12 |
| 12 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 13 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 class URLRequest; | 17 class URLRequest; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 class DownloadItem; | 22 class DownloadItem; |
| 22 class ResourceContext; | 23 class ResourceContext; |
| 23 class ResourceDispatcherHostDelegate; | 24 class ResourceDispatcherHostDelegate; |
| 24 struct DownloadSaveInfo; | 25 struct DownloadSaveInfo; |
| 25 struct Referrer; | 26 struct Referrer; |
| 26 class RenderFrameHost; | 27 class RenderFrameHost; |
| 27 | 28 |
| 29 // This callback is invoked when the interceptor finishes processing the | |
| 30 // header. | |
| 31 typedef base::Callback<void(bool, int)> OnHeaderProcessedCallback; | |
| 32 | |
| 33 // This callback is registered by interceptors who are interested in being | |
| 34 // notified of certain HTTP headers in outgoing requests. For e.g. Origin. | |
|
jam
2016/08/10 00:19:26
nit: please document the parameters to this callba
ananta
2016/08/10 00:30:02
Done.
| |
| 35 typedef base::Callback<void(const std::string&, const std::string&, int, | |
| 36 ResourceContext*, OnHeaderProcessedCallback)> | |
| 37 InterceptorCallback; | |
| 38 | |
| 28 class CONTENT_EXPORT ResourceDispatcherHost { | 39 class CONTENT_EXPORT ResourceDispatcherHost { |
| 29 public: | 40 public: |
| 30 // Returns the singleton instance of the ResourceDispatcherHost. | 41 // Returns the singleton instance of the ResourceDispatcherHost. |
| 31 static ResourceDispatcherHost* Get(); | 42 static ResourceDispatcherHost* Get(); |
| 32 | 43 |
| 33 // Causes all new requests for the root RenderFrameHost and its children to be | 44 // Causes all new requests for the root RenderFrameHost and its children to be |
| 34 // blocked (not being started) until ResumeBlockedRequestsForFrameFromUI is | 45 // blocked (not being started) until ResumeBlockedRequestsForFrameFromUI is |
| 35 // called. | 46 // called. |
| 36 static void BlockRequestsForFrameFromUI(RenderFrameHost* root_frame_host); | 47 static void BlockRequestsForFrameFromUI(RenderFrameHost* root_frame_host); |
| 37 | 48 |
| 38 // Resumes any blocked request for the specified root RenderFrameHost and | 49 // Resumes any blocked request for the specified root RenderFrameHost and |
| 39 // child frame hosts. | 50 // child frame hosts. |
| 40 static void ResumeBlockedRequestsForFrameFromUI( | 51 static void ResumeBlockedRequestsForFrameFromUI( |
| 41 RenderFrameHost* root_frame_host); | 52 RenderFrameHost* root_frame_host); |
| 42 | 53 |
| 43 // This does not take ownership of the delegate. It is expected that the | 54 // This does not take ownership of the delegate. It is expected that the |
| 44 // delegate have a longer lifetime than the ResourceDispatcherHost. | 55 // delegate have a longer lifetime than the ResourceDispatcherHost. |
| 45 virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) = 0; | 56 virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) = 0; |
| 46 | 57 |
| 47 // Controls whether third-party sub-content can pop-up HTTP basic auth | 58 // Controls whether third-party sub-content can pop-up HTTP basic auth |
| 48 // dialog boxes. | 59 // dialog boxes. |
| 49 virtual void SetAllowCrossOriginAuthPrompt(bool value) = 0; | 60 virtual void SetAllowCrossOriginAuthPrompt(bool value) = 0; |
| 50 | 61 |
| 51 // Clears the ResourceDispatcherHostLoginDelegate associated with the request. | 62 // Clears the ResourceDispatcherHostLoginDelegate associated with the request. |
| 52 virtual void ClearLoginDelegateForRequest(net::URLRequest* request) = 0; | 63 virtual void ClearLoginDelegateForRequest(net::URLRequest* request) = 0; |
| 53 | 64 |
| 65 // Registers the |interceptor| for the |http_header| passed in. | |
| 66 // The |starts_with| parameter is used to match the prefix of the | |
| 67 // |http_header| in the response and the interceptor will be invoked if there | |
| 68 // is a match. If the |starts_with| parameter is empty, the interceptor will | |
| 69 // be invoked for every occurrence of the |http_header|. | |
| 70 // Currently only HTTP header based interceptors are supported. | |
| 71 // In the future to register a generic interceptor, we could pass in empty | |
| 72 // strings for the |http_header| and |starts_with| parameters. | |
|
jam
2016/08/10 00:19:26
nit: I'd remove these two lines since we don't nee
ananta
2016/08/10 00:30:02
Done.
| |
| 73 // At the moment we only support one interceptor per |http_header|. | |
| 74 virtual void RegisterInterceptor( | |
| 75 const std::string& http_header, | |
| 76 const std::string& starts_with, | |
| 77 const InterceptorCallback& interceptor) = 0; | |
| 78 | |
| 54 protected: | 79 protected: |
| 55 virtual ~ResourceDispatcherHost() {} | 80 virtual ~ResourceDispatcherHost() {} |
| 56 }; | 81 }; |
| 57 | 82 |
| 58 } // namespace content | 83 } // namespace content |
| 59 | 84 |
| 60 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ | 85 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_ |
| OLD | NEW |