Chromium Code Reviews| 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..2a6cee2d4b2bd13ab24d75846ea3c9bb9dbb2c6f 100644 |
| --- a/content/browser/download/download_item_impl.cc |
| +++ b/content/browser/download/download_item_impl.cc |
| @@ -504,15 +504,10 @@ 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()) |
| - return false; |
| - |
| ResumeMode resume_mode = GetResumeMode(); |
| - return IsDownloadResumptionEnabled() && |
| - (resume_mode == RESUME_MODE_USER_RESTART || |
| - resume_mode == RESUME_MODE_USER_CONTINUE); |
| + return IsDownloadResumptionEnabled() && GetURL().SchemeIsHTTPOrHTTPS() && |
|
asanka
2015/11/25 15:53:57
Nit: You can move the SchemeIs.. check into it's o
svaldez
2015/11/25 17:53:28
Done.
|
| + (resume_mode == RESUME_MODE_USER_RESTART || |
| + resume_mode == RESUME_MODE_USER_CONTINUE); |
| } |
| bool DownloadItemImpl::IsDone() const { |
| @@ -1693,13 +1688,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 +1698,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()); |
|
asanka
2015/11/25 15:53:57
Oh boy. I just noticed that we are calling GetOrig
svaldez
2015/11/25 17:53:28
Acknowledged.
|
| + } 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()); |