22
22
#include "content/browser/loader/stream_resource_handler.h"
23
23
#include "content/public/browser/content_browser_client.h"
24
24
#include "content/public/browser/download_item.h"
25
@@ -339,16 +340,46 @@ bool BufferedResourceHandler::SelectNext
25
@@ -349,16 +350,41 @@ bool BufferedResourceHandler::SelectNext
34
34
+ if (host_->delegate()) {
35
35
+ std::string disposition;
36
+ request()->GetResponseHeaderByName(
37
+ "content-disposition", &disposition);
38
+ net::HttpContentDisposition
39
+ content_disposition(disposition, std::string());
36
+ request()->GetResponseHeaderByName("content-disposition", &disposition);
37
+ net::HttpContentDisposition content_disposition(disposition,
40
39
+ ResourceRequestInfoImpl* info = GetRequestInfo();
41
40
+ if (!host_->delegate()->ShouldDownloadUrl(
42
41
+ request()->url(),
43
42
+ request()->first_party_for_cookies(),
44
+ info->HasUserGesture(),
45
+ !disposition.empty() &&
46
+ (content_disposition.parse_result_flags() & net::HttpContentDisposition::HAS_FILENAME)
47
+ ? base::UTF8ToUTF16(content_disposition.filename())
50
+ Referrer(GURL(request()->referrer()), info->GetReferrerPolicy()),
51
+ response_->head.mime_type,
54
+ info->GetContext())) {
43
+ info->HasUserGesture(),
44
+ !disposition.empty() && (content_disposition.parse_result_flags() & net::HttpContentDisposition::HAS_FILENAME) ?
45
+ base::UTF8ToUTF16(content_disposition.filename()) : base::string16(),
47
+ Referrer(GURL(request()->referrer()), info->GetReferrerPolicy()),
48
+ response_->head.mime_type,
51
+ info->GetContext())) {
55
52
+ request()->Cancel();
57
+ LOG(INFO) << "Download request for "
58
+ << request()->url().GetContent()
59
+ << " got cancelled by embedder";
54
+ LOG(INFO) << "Download request for " << request()->url().GetContent() << " got cancelled by embedder";
72
67
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
73
68
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
74
69
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
75
@@ -511,16 +511,33 @@ DownloadInterruptReason ResourceDispatch
70
@@ -599,16 +599,33 @@ DownloadInterruptReason ResourceDispatch
76
71
scoped_ptr<DownloadSaveInfo> save_info,
77
72
uint32 download_id,
78
73
const DownloadStartedCallback& started_callback) {