Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: content/public/browser/download_url_parameters.h

Issue 1979783002: [Merge M51][Downloads] Use the initiating StoragePartition for resumption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/ref_counted.h"
16 #include "content/public/browser/download_interrupt_reasons.h" 17 #include "content/public/browser/download_interrupt_reasons.h"
17 #include "content/public/browser/download_save_info.h" 18 #include "content/public/browser/download_save_info.h"
18 #include "content/public/common/referrer.h" 19 #include "content/public/common/referrer.h"
20 #include "net/url_request/url_request_context_getter.h"
19 #include "storage/browser/blob/blob_data_handle.h" 21 #include "storage/browser/blob/blob_data_handle.h"
20 #include "url/gurl.h" 22 #include "url/gurl.h"
21 23
22 namespace content { 24 namespace content {
23 25
24 class DownloadItem; 26 class DownloadItem;
25 class ResourceContext;
26 class ResourceDispatcherHost; 27 class ResourceDispatcherHost;
27 class WebContents; 28 class WebContents;
28 29
29 // Pass an instance of DownloadUrlParameters to DownloadManager::DownloadUrl() 30 // Pass an instance of DownloadUrlParameters to DownloadManager::DownloadUrl()
30 // to download the content at |url|. All parameters with setters are optional. 31 // to download the content at |url|. All parameters with setters are optional.
31 // |referrer| and |referrer_encoding| are the referrer for the download. If 32 // |referrer| and |referrer_encoding| are the referrer for the download. If
32 // |prefer_cache| is true, then if the response to |url| is in the HTTP cache it 33 // |prefer_cache| is true, then if the response to |url| is in the HTTP cache it
33 // will be used without revalidation. If |post_id| is non-negative, then it 34 // will be used without revalidation. If |post_id| is non-negative, then it
34 // identifies the post transaction used to originally retrieve the |url| 35 // identifies the post transaction used to originally retrieve the |url|
35 // resource - it also requires |prefer_cache| to be |true| since re-post'ing is 36 // resource - it also requires |prefer_cache| to be |true| since re-post'ing is
(...skipping 17 matching lines...) Expand all
53 // download request. I.e. the download triggered a warning of some sort and 54 // download request. I.e. the download triggered a warning of some sort and
54 // the user chose to not to proceed with the download as a result. 55 // the user chose to not to proceed with the download as a result.
55 typedef base::Callback<void(DownloadItem*, DownloadInterruptReason)> 56 typedef base::Callback<void(DownloadItem*, DownloadInterruptReason)>
56 OnStartedCallback; 57 OnStartedCallback;
57 58
58 typedef std::pair<std::string, std::string> RequestHeadersNameValuePair; 59 typedef std::pair<std::string, std::string> RequestHeadersNameValuePair;
59 typedef std::vector<RequestHeadersNameValuePair> RequestHeadersType; 60 typedef std::vector<RequestHeadersNameValuePair> RequestHeadersType;
60 61
61 // Construct DownloadUrlParameters for downloading the resource at |url| and 62 // Construct DownloadUrlParameters for downloading the resource at |url| and
62 // associating the download with |web_contents|. 63 // associating the download with |web_contents|.
64 //
65 // DEPRECATED: Using this method can cause the request to be associated with
66 // the wrong site instance where multiple iframes are involved. Use the
67 // DownloadUrlParameters constructor below and specify the process and frame
68 // IDs explicitly.
63 static scoped_ptr<DownloadUrlParameters> FromWebContents( 69 static scoped_ptr<DownloadUrlParameters> FromWebContents(
64 WebContents* web_contents, 70 WebContents* web_contents,
65 const GURL& url); 71 const GURL& url);
66 72
67 // Construct DownloadUrlParameters for downloading the resource at |url| and 73 // Construct DownloadUrlParameters for downloading the resource at |url| and
68 // associating the download with the WebContents identified by 74 // associating the download with the WebContents identified by
69 // |render_process_host_id| and |render_view_host_routing_id|. 75 // |render_process_host_id| and |render_view_host_routing_id|.
70 // 76 //
71 // If the download is not associated with a WebContents, then set the IDs to 77 // If the download is not associated with a WebContents, then set the IDs to
72 // -1. 78 // -1.
73 // NOTE: This is not safe and should only be done in a limited set of cases 79 //
74 // where the download URL has been previously vetted. A download that's 80 // NOTE: Initiating downloads that are not associated with a WebContents is
75 // initiated without associating it with a WebContents don't receive the same 81 // not safe and should only be done in a limited set of cases where the
76 // security checks as a request that's associated with one. Hence, downloads 82 // download URL has been previously vetted. A download that's initiated
77 // that are not associated with a WebContents should only be made for URLs 83 // without associating it with a WebContents don't receive the same security
78 // that are either trusted or URLs that have previously been successfully 84 // checks as a request that's associated with one. Hence, downloads that are
79 // issued using a non-privileged WebContents. 85 // not associated with a WebContents should only be made for URLs that are
80 DownloadUrlParameters(const GURL& url, 86 // either trusted or URLs that have previously been successfully issued using
81 int render_process_host_id, 87 // a non-privileged WebContents.
82 int render_view_host_routing_id, 88 DownloadUrlParameters(
83 int render_frame_host_routing_id, 89 const GURL& url,
84 ResourceContext* resource_context); 90 int render_process_host_id,
91 int render_view_host_routing_id,
92 int render_frame_host_routing_id,
93 net::URLRequestContextGetter* url_request_context_getter);
85 94
86 ~DownloadUrlParameters(); 95 ~DownloadUrlParameters();
87 96
88 // Should be set to true if the download was initiated by a script or a web 97 // Should be set to true if the download was initiated by a script or a web
89 // page. I.e. if the download request cannot be attributed to an explicit user 98 // page. I.e. if the download request cannot be attributed to an explicit user
90 // request for a download, then set this value to true. 99 // request for a download, then set this value to true.
91 void set_content_initiated(bool content_initiated) { 100 void set_content_initiated(bool content_initiated) {
92 content_initiated_ = content_initiated; 101 content_initiated_ = content_initiated;
93 } 102 }
94 void add_request_header(const std::string& name, const std::string& value) { 103 void add_request_header(const std::string& name, const std::string& value) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 const Referrer& referrer() const { return referrer_; } 214 const Referrer& referrer() const { return referrer_; }
206 const std::string& referrer_encoding() const { return referrer_encoding_; } 215 const std::string& referrer_encoding() const { return referrer_encoding_; }
207 int render_process_host_id() const { return render_process_host_id_; } 216 int render_process_host_id() const { return render_process_host_id_; }
208 int render_view_host_routing_id() const { 217 int render_view_host_routing_id() const {
209 return render_view_host_routing_id_; 218 return render_view_host_routing_id_;
210 } 219 }
211 int render_frame_host_routing_id() const { 220 int render_frame_host_routing_id() const {
212 return render_frame_host_routing_id_; 221 return render_frame_host_routing_id_;
213 } 222 }
214 const RequestHeadersType& request_headers() const { return request_headers_; } 223 const RequestHeadersType& request_headers() const { return request_headers_; }
215 ResourceContext* resource_context() const { return resource_context_; } 224 net::URLRequestContextGetter* url_request_context_getter() {
225 return url_request_context_getter_.get();
226 }
216 const base::FilePath& file_path() const { return save_info_.file_path; } 227 const base::FilePath& file_path() const { return save_info_.file_path; }
217 const base::string16& suggested_name() const { 228 const base::string16& suggested_name() const {
218 return save_info_.suggested_name; 229 return save_info_.suggested_name;
219 } 230 }
220 int64_t offset() const { return save_info_.offset; } 231 int64_t offset() const { return save_info_.offset; }
221 const std::string& hash_of_partial_file() const { 232 const std::string& hash_of_partial_file() const {
222 return save_info_.hash_of_partial_file; 233 return save_info_.hash_of_partial_file;
223 } 234 }
224 bool prompt() const { return save_info_.prompt_for_save_location; } 235 bool prompt() const { return save_info_.prompt_for_save_location; }
225 const GURL& url() const { return url_; } 236 const GURL& url() const { return url_; }
(...skipping 16 matching lines...) Expand all
242 std::string etag_; 253 std::string etag_;
243 std::string method_; 254 std::string method_;
244 std::string post_body_; 255 std::string post_body_;
245 int64_t post_id_; 256 int64_t post_id_;
246 bool prefer_cache_; 257 bool prefer_cache_;
247 Referrer referrer_; 258 Referrer referrer_;
248 std::string referrer_encoding_; 259 std::string referrer_encoding_;
249 int render_process_host_id_; 260 int render_process_host_id_;
250 int render_view_host_routing_id_; 261 int render_view_host_routing_id_;
251 int render_frame_host_routing_id_; 262 int render_frame_host_routing_id_;
252 ResourceContext* resource_context_; 263 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
253 DownloadSaveInfo save_info_; 264 DownloadSaveInfo save_info_;
254 GURL url_; 265 GURL url_;
255 bool do_not_prompt_for_login_; 266 bool do_not_prompt_for_login_;
256 scoped_ptr<storage::BlobDataHandle> blob_data_handle_; 267 scoped_ptr<storage::BlobDataHandle> blob_data_handle_;
257 268
258 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters); 269 DISALLOW_COPY_AND_ASSIGN(DownloadUrlParameters);
259 }; 270 };
260 271
261 } // namespace content 272 } // namespace content
262 273
263 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_ 274 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_URL_PARAMETERS_H_
OLDNEW
« no previous file with comments | « content/public/browser/download_manager.h ('k') | content/public/browser/download_url_parameters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698