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_DELEGATE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 class ResourceThrottle; | 32 class ResourceThrottle; |
33 class StreamHandle; | 33 class StreamHandle; |
34 struct Referrer; | 34 struct Referrer; |
35 struct ResourceResponse; | 35 struct ResourceResponse; |
36 | 36 |
37 // Interface that the embedder provides to ResourceDispatcherHost to allow | 37 // Interface that the embedder provides to ResourceDispatcherHost to allow |
38 // observing and modifying requests. | 38 // observing and modifying requests. |
39 class CONTENT_EXPORT ResourceDispatcherHostDelegate { | 39 class CONTENT_EXPORT ResourceDispatcherHostDelegate { |
40 public: | 40 public: |
41 // Called when a request begins. Return false to abort the request. | 41 // Called when a request begins. Return false to abort the request. |
42 virtual bool ShouldBeginRequest( | 42 virtual bool ShouldBeginRequest(int child_id, |
43 int child_id, | 43 int route_id, |
44 int route_id, | 44 const std::string& method, |
45 const std::string& method, | 45 const GURL& url, |
46 const GURL& url, | 46 ResourceType resource_type, |
47 ResourceType::Type resource_type, | 47 ResourceContext* resource_context); |
48 ResourceContext* resource_context); | |
49 | 48 |
50 // Called after ShouldBeginRequest to allow the embedder to add resource | 49 // Called after ShouldBeginRequest to allow the embedder to add resource |
51 // throttles. | 50 // throttles. |
52 virtual void RequestBeginning( | 51 virtual void RequestBeginning(net::URLRequest* request, |
53 net::URLRequest* request, | 52 ResourceContext* resource_context, |
54 ResourceContext* resource_context, | 53 AppCacheService* appcache_service, |
55 AppCacheService* appcache_service, | 54 ResourceType resource_type, |
56 ResourceType::Type resource_type, | 55 int child_id, |
57 int child_id, | 56 int route_id, |
58 int route_id, | 57 ScopedVector<ResourceThrottle>* throttles); |
59 ScopedVector<ResourceThrottle>* throttles); | |
60 | 58 |
61 // Allows an embedder to add additional resource handlers for a download. | 59 // Allows an embedder to add additional resource handlers for a download. |
62 // |must_download| is set if the request must be handled as a download. | 60 // |must_download| is set if the request must be handled as a download. |
63 virtual void DownloadStarting( | 61 virtual void DownloadStarting(net::URLRequest* request, |
64 net::URLRequest* request, | 62 ResourceContext* resource_context, |
65 ResourceContext* resource_context, | 63 int child_id, |
66 int child_id, | 64 int route_id, |
67 int route_id, | 65 int request_id, |
68 int request_id, | 66 bool is_content_initiated, |
69 bool is_content_initiated, | 67 bool must_download, |
70 bool must_download, | 68 ScopedVector<ResourceThrottle>* throttles); |
71 ScopedVector<ResourceThrottle>* throttles); | |
72 | 69 |
73 // Creates a ResourceDispatcherHostLoginDelegate that asks the user for a | 70 // Creates a ResourceDispatcherHostLoginDelegate that asks the user for a |
74 // username and password. | 71 // username and password. |
75 virtual ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( | 72 virtual ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( |
76 net::AuthChallengeInfo* auth_info, net::URLRequest* request); | 73 net::AuthChallengeInfo* auth_info, |
| 74 net::URLRequest* request); |
77 | 75 |
78 // Launches the url for the given tab. Returns true if an attempt to handle | 76 // Launches the url for the given tab. Returns true if an attempt to handle |
79 // the url was made, e.g. by launching an app. Note that this does not | 77 // the url was made, e.g. by launching an app. Note that this does not |
80 // guarantee that the app successfully handled it. | 78 // guarantee that the app successfully handled it. |
81 virtual bool HandleExternalProtocol(const GURL& url, | 79 virtual bool HandleExternalProtocol(const GURL& url, |
82 int child_id, | 80 int child_id, |
83 int route_id); | 81 int route_id); |
84 | 82 |
85 // Returns true if we should force the given resource to be downloaded. | 83 // Returns true if we should force the given resource to be downloaded. |
86 // Otherwise, the content layer decides. | 84 // Otherwise, the content layer decides. |
87 virtual bool ShouldForceDownloadResource( | 85 virtual bool ShouldForceDownloadResource(const GURL& url, |
88 const GURL& url, const std::string& mime_type); | 86 const std::string& mime_type); |
89 | 87 |
90 // Returns true and sets |origin| if a Stream should be created for the | 88 // Returns true and sets |origin| if a Stream should be created for the |
91 // resource. | 89 // resource. |
92 // If true is returned, a new Stream will be created and OnStreamCreated() | 90 // If true is returned, a new Stream will be created and OnStreamCreated() |
93 // will be called with | 91 // will be called with |
94 // - a StreamHandle instance for the Stream. The handle contains the URL for | 92 // - a StreamHandle instance for the Stream. The handle contains the URL for |
95 // reading the Stream etc. | 93 // reading the Stream etc. |
96 // The Stream's origin will be set to |origin|. | 94 // The Stream's origin will be set to |origin|. |
97 // | 95 // |
98 // If the stream will be rendered in a BrowserPlugin, |payload| will contain | 96 // If the stream will be rendered in a BrowserPlugin, |payload| will contain |
99 // the data that should be given to the old ResourceHandler to forward to the | 97 // the data that should be given to the old ResourceHandler to forward to the |
100 // renderer process. | 98 // renderer process. |
101 virtual bool ShouldInterceptResourceAsStream( | 99 virtual bool ShouldInterceptResourceAsStream(net::URLRequest* request, |
102 net::URLRequest* request, | 100 const std::string& mime_type, |
103 const std::string& mime_type, | 101 GURL* origin, |
104 GURL* origin, | 102 std::string* payload); |
105 std::string* payload); | |
106 | 103 |
107 // Informs the delegate that a Stream was created. The Stream can be read from | 104 // Informs the delegate that a Stream was created. The Stream can be read from |
108 // the blob URL of the Stream, but can only be read once. | 105 // the blob URL of the Stream, but can only be read once. |
109 virtual void OnStreamCreated( | 106 virtual void OnStreamCreated(net::URLRequest* request, |
110 net::URLRequest* request, | 107 scoped_ptr<content::StreamHandle> stream); |
111 scoped_ptr<content::StreamHandle> stream); | |
112 | 108 |
113 // Informs the delegate that a response has started. | 109 // Informs the delegate that a response has started. |
114 virtual void OnResponseStarted( | 110 virtual void OnResponseStarted(net::URLRequest* request, |
115 net::URLRequest* request, | 111 ResourceContext* resource_context, |
116 ResourceContext* resource_context, | 112 ResourceResponse* response, |
117 ResourceResponse* response, | 113 IPC::Sender* sender); |
118 IPC::Sender* sender); | |
119 | 114 |
120 // Informs the delegate that a request has been redirected. | 115 // Informs the delegate that a request has been redirected. |
121 virtual void OnRequestRedirected( | 116 virtual void OnRequestRedirected(const GURL& redirect_url, |
122 const GURL& redirect_url, | 117 net::URLRequest* request, |
123 net::URLRequest* request, | 118 ResourceContext* resource_context, |
124 ResourceContext* resource_context, | 119 ResourceResponse* response); |
125 ResourceResponse* response); | |
126 | 120 |
127 // Notification that a request has completed. | 121 // Notification that a request has completed. |
128 virtual void RequestComplete(net::URLRequest* url_request); | 122 virtual void RequestComplete(net::URLRequest* url_request); |
129 | 123 |
130 protected: | 124 protected: |
131 ResourceDispatcherHostDelegate(); | 125 ResourceDispatcherHostDelegate(); |
132 virtual ~ResourceDispatcherHostDelegate(); | 126 virtual ~ResourceDispatcherHostDelegate(); |
133 }; | 127 }; |
134 | 128 |
135 } // namespace content | 129 } // namespace content |
136 | 130 |
137 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ | 131 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
OLD | NEW |