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

Unified Diff: content/browser/download/download_request_core.cc

Issue 2528483003: [Android Downloads] Long-press menu item "Download Link" should delegate job to OfflinePages backen… (Closed)
Patch Set: removed unnecessary #include Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_request_core.cc
diff --git a/content/browser/download/download_request_core.cc b/content/browser/download/download_request_core.cc
index f23dcda4bf2270fd276a3f387260bdb0b76bbd3c..5ae735b8d6b0547f3514b176618c46d538553833 100644
--- a/content/browser/download/download_request_core.cc
+++ b/content/browser/download/download_request_core.cc
@@ -45,6 +45,10 @@ namespace content {
namespace {
+// Mime type of download resource that should trigger handoff to OfflinePages
+// backend for full page load+snapshot.
+const char kHTMLType[] = "text/html";
+
// This is a UserData::Data that will be attached to a URLRequest as a
// side-channel for passing download parameters.
class DownloadRequestData : public base::SupportsUserData::Data {
@@ -259,6 +263,13 @@ bool DownloadRequestCore::OnResponseStarted(
save_info_.get())
: DOWNLOAD_INTERRUPT_REASON_NONE;
+ // If the download resource is an HTML page, interrupt this download with
+ // a result code that allows handoff to the OfflinePage backend.
+ if (result == DOWNLOAD_INTERRUPT_REASON_NONE &&
+ override_mime_type == kHTMLType) {
+ result = DOWNLOAD_INTERRUPT_REASON_PAGE_DOWNLOAD_HANDOFF;
jianli 2016/11/23 01:27:32 Do we want to return instead?
+ }
+
std::unique_ptr<DownloadCreateInfo> create_info =
CreateDownloadCreateInfo(result);
if (result != DOWNLOAD_INTERRUPT_REASON_NONE) {

Powered by Google App Engine
This is Rietveld 408576698