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

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

Issue 1418663010: Adding WebContent-free Download (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing Core. Created 5 years 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_item_impl.cc
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index 42c0f778d27b1e9870778bf74eca8dff68291af1..eecd438d940d553e78edc3982ac21289d598b4bd 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -504,9 +504,8 @@ bool DownloadItemImpl::CanResume() const {
if (state_ != INTERRUPTED_INTERNAL)
return false;
- // Downloads that don't have a WebContents should still be resumable, but this
- // isn't currently the case. See ResumeInterruptedDownload().
- if (!GetWebContents())
+ // We currently only support HTTP(S) requests for download resumption.
+ if (!GetURL().SchemeIsHTTPOrHTTPS())
return false;
ResumeMode resume_mode = GetResumeMode();
@@ -1693,13 +1692,6 @@ void DownloadItemImpl::ResumeInterruptedDownload() {
if (state_ != INTERRUPTED_INTERNAL)
return;
- // If we can't get a web contents, we can't resume the download.
- // TODO(rdsmith): Find some alternative web contents to use--this
- // means we can't restart a download if it's a download imported
- // from the history.
- if (!GetWebContents())
- return;
-
// Reset the appropriate state if restarting.
ResumeMode mode = GetResumeMode();
if (mode == RESUME_MODE_IMMEDIATE_RESTART ||
@@ -1710,9 +1702,17 @@ void DownloadItemImpl::ResumeInterruptedDownload() {
etag_ = "";
}
- scoped_ptr<DownloadUrlParameters> download_params(
- DownloadUrlParameters::FromWebContents(GetWebContents(),
- GetOriginalUrl()));
+ scoped_ptr<DownloadUrlParameters> download_params;
+ if (GetWebContents()) {
+ download_params = DownloadUrlParameters::FromWebContents(GetWebContents(),
+ GetOriginalUrl());
+ } else if (GetBrowserContext()) {
+ download_params = make_scoped_ptr(
+ new DownloadUrlParameters(GetOriginalUrl(), -1, -1, -1,
+ GetBrowserContext()->GetResourceContext()));
+ } else {
+ return;
+ }
download_params->set_file_path(GetFullPath());
download_params->set_offset(GetReceivedBytes());

Powered by Google App Engine
This is Rietveld 408576698