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_DOWNLOAD_URL_PARAMETERS_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ |
6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ | 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/optional.h" |
18 #include "content/public/browser/download_interrupt_reasons.h" | 19 #include "content/public/browser/download_interrupt_reasons.h" |
19 #include "content/public/browser/download_save_info.h" | 20 #include "content/public/browser/download_save_info.h" |
20 #include "content/public/common/referrer.h" | 21 #include "content/public/common/referrer.h" |
21 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
22 #include "storage/browser/blob/blob_data_handle.h" | 23 #include "storage/browser/blob/blob_data_handle.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 #include "url/origin.h" |
24 | 26 |
25 namespace content { | 27 namespace content { |
26 | 28 |
27 class DownloadItem; | 29 class DownloadItem; |
28 class WebContents; | 30 class WebContents; |
29 | 31 |
30 // Pass an instance of DownloadUrlParameters to DownloadManager::DownloadUrl() | 32 // Pass an instance of DownloadUrlParameters to DownloadManager::DownloadUrl() |
31 // to download the content at |url|. All parameters with setters are optional. | 33 // to download the content at |url|. All parameters with setters are optional. |
32 // |referrer| and |referrer_encoding| are the referrer for the download. If | 34 // |referrer| and |referrer_encoding| are the referrer for the download. If |
33 // |prefer_cache| is true, then if the response to |url| is in the HTTP cache it | 35 // |prefer_cache| is true, then if the response to |url| is in the HTTP cache it |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void add_request_header(const std::string& name, const std::string& value) { | 102 void add_request_header(const std::string& name, const std::string& value) { |
101 request_headers_.push_back(make_pair(name, value)); | 103 request_headers_.push_back(make_pair(name, value)); |
102 } | 104 } |
103 | 105 |
104 // HTTP Referrer and referrer encoding. | 106 // HTTP Referrer and referrer encoding. |
105 void set_referrer(const Referrer& referrer) { referrer_ = referrer; } | 107 void set_referrer(const Referrer& referrer) { referrer_ = referrer; } |
106 void set_referrer_encoding(const std::string& referrer_encoding) { | 108 void set_referrer_encoding(const std::string& referrer_encoding) { |
107 referrer_encoding_ = referrer_encoding; | 109 referrer_encoding_ = referrer_encoding; |
108 } | 110 } |
109 | 111 |
| 112 // The origin of the context which initiated the request. See |
| 113 // net::URLRequest::initiator(). |
| 114 void set_initiator(const base::Optional<url::Origin>& initiator) { |
| 115 initiator_ = initiator; |
| 116 } |
| 117 |
110 // If this is a request for resuming an HTTP/S download, |last_modified| | 118 // If this is a request for resuming an HTTP/S download, |last_modified| |
111 // should be the value of the last seen Last-Modified response header. | 119 // should be the value of the last seen Last-Modified response header. |
112 void set_last_modified(const std::string& last_modified) { | 120 void set_last_modified(const std::string& last_modified) { |
113 last_modified_ = last_modified; | 121 last_modified_ = last_modified; |
114 } | 122 } |
115 | 123 |
116 // If this is a request for resuming an HTTP/S download, |etag| should be the | 124 // If this is a request for resuming an HTTP/S download, |etag| should be the |
117 // last seen Etag response header. | 125 // last seen Etag response header. |
118 void set_etag(const std::string& etag) { | 126 void set_etag(const std::string& etag) { |
119 etag_ = etag; | 127 etag_ = etag; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 const OnStartedCallback& callback() const { return callback_; } | 211 const OnStartedCallback& callback() const { return callback_; } |
204 bool content_initiated() const { return content_initiated_; } | 212 bool content_initiated() const { return content_initiated_; } |
205 const std::string& last_modified() const { return last_modified_; } | 213 const std::string& last_modified() const { return last_modified_; } |
206 const std::string& etag() const { return etag_; } | 214 const std::string& etag() const { return etag_; } |
207 const std::string& method() const { return method_; } | 215 const std::string& method() const { return method_; } |
208 const std::string& post_body() const { return post_body_; } | 216 const std::string& post_body() const { return post_body_; } |
209 int64_t post_id() const { return post_id_; } | 217 int64_t post_id() const { return post_id_; } |
210 bool prefer_cache() const { return prefer_cache_; } | 218 bool prefer_cache() const { return prefer_cache_; } |
211 const Referrer& referrer() const { return referrer_; } | 219 const Referrer& referrer() const { return referrer_; } |
212 const std::string& referrer_encoding() const { return referrer_encoding_; } | 220 const std::string& referrer_encoding() const { return referrer_encoding_; } |
| 221 const base::Optional<url::Origin>& initiator() const { return initiator_; } |
213 | 222 |
214 // These will be -1 if the request is not associated with a frame. See | 223 // These will be -1 if the request is not associated with a frame. See |
215 // the constructors for more. | 224 // the constructors for more. |
216 int render_process_host_id() const { return render_process_host_id_; } | 225 int render_process_host_id() const { return render_process_host_id_; } |
217 int render_view_host_routing_id() const { | 226 int render_view_host_routing_id() const { |
218 return render_view_host_routing_id_; | 227 return render_view_host_routing_id_; |
219 } | 228 } |
220 int render_frame_host_routing_id() const { | 229 int render_frame_host_routing_id() const { |
221 return render_frame_host_routing_id_; | 230 return render_frame_host_routing_id_; |
222 } | 231 } |
(...skipping 27 matching lines...) Expand all Loading... |
250 OnStartedCallback callback_; | 259 OnStartedCallback callback_; |
251 bool content_initiated_; | 260 bool content_initiated_; |
252 RequestHeadersType request_headers_; | 261 RequestHeadersType request_headers_; |
253 std::string last_modified_; | 262 std::string last_modified_; |
254 std::string etag_; | 263 std::string etag_; |
255 std::string method_; | 264 std::string method_; |
256 std::string post_body_; | 265 std::string post_body_; |
257 int64_t post_id_; | 266 int64_t post_id_; |
258 bool prefer_cache_; | 267 bool prefer_cache_; |
259 Referrer referrer_; | 268 Referrer referrer_; |
| 269 base::Optional<url::Origin> initiator_; |
260 std::string referrer_encoding_; | 270 std::string referrer_encoding_; |
261 int render_process_host_id_; | 271 int render_process_host_id_; |
262 int render_view_host_routing_id_; | 272 int render_view_host_routing_id_; |
263 int render_frame_host_routing_id_; | 273 int render_frame_host_routing_id_; |
264 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 274 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
265 DownloadSaveInfo save_info_; | 275 DownloadSaveInfo save_info_; |
266 GURL url_; | 276 GURL url_; |
267 bool do_not_prompt_for_login_; | 277 bool do_not_prompt_for_login_; |
268 std::unique_ptr<storage::BlobDataHandle> blob_data_handle_; | 278 std::unique_ptr<storage::BlobDataHandle> blob_data_handle_; |
269 | 279 |
270 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); | 280 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); |
271 }; | 281 }; |
272 | 282 |
273 } // namespace content | 283 } // namespace content |
274 | 284 |
275 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ | 285 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ |
OLD | NEW |