~osomon/oxide/context-menu

« back to all changes in this revision

Viewing changes to patches/add-should-download-url-to-resource-dispatcher-host.patch

  • Committer: Olivier Tilloy
  • Date: 2015-04-24 11:34:28 UTC
  • mfrom: (1031.1.24 oxide)
  • Revision ID: olivier.tilloy@canonical.com-20150424113428-r221y8t5hv083t0n
Merge the latest changes from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
26
26
       *defer = true;
27
27
       return true;
28
28
     }
33
33
 
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,
 
38
+                                                    std::string());
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())
48
 
+               : base::string16(),
49
 
+           false,
50
 
+           Referrer(GURL(request()->referrer()), info->GetReferrerPolicy()),
51
 
+           response_->head.mime_type,
52
 
+           info->GetChildID(),
53
 
+           info->GetRouteID(),
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(),
 
46
+            false,
 
47
+            Referrer(GURL(request()->referrer()), info->GetReferrerPolicy()),
 
48
+            response_->head.mime_type,
 
49
+            info->GetChildID(),
 
50
+            info->GetRouteID(),
 
51
+            info->GetContext())) {
55
52
+      request()->Cancel();
56
53
+      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";
60
55
+      return false;
61
56
+    }
62
57
+  }
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) {