| 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 e2313415bed14f93b9d3fb2a09bf667cb6b0ef6d..6e53782c292c2e1f9facf71c4555318bf558172f 100644
|
| --- a/content/browser/download/download_item_impl.cc
|
| +++ b/content/browser/download/download_item_impl.cc
|
| @@ -1062,7 +1062,9 @@ void DownloadItemImpl::MaybeCompleteDownload() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| DCHECK(!is_save_package_download_);
|
|
|
| - if (!IsDownloadReadyForCompletion())
|
| + if (!IsDownloadReadyForCompletion(
|
| + base::Bind(&DownloadItemImpl::MaybeCompleteDownload,
|
| + weak_ptr_factory_.GetWeakPtr())))
|
| return;
|
|
|
| // TODO(rdsmith): DCHECK that we only pass through this point
|
| @@ -1086,16 +1088,6 @@ void DownloadItemImpl::OnDownloadCompleting() {
|
| if (state_ != IN_PROGRESS_INTERNAL)
|
| return;
|
|
|
| - // Give the delegate a chance to override.
|
| - delegate_->ReadyForDownloadCompletion(
|
| - this, base::Bind(&DownloadItemImpl::ReadyForDownloadCompletionDone,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| -}
|
| -
|
| -void DownloadItemImpl::ReadyForDownloadCompletionDone() {
|
| - if (state_ != IN_PROGRESS_INTERNAL)
|
| - return;
|
| -
|
| VLOG(20) << __FUNCTION__ << "()"
|
| << " " << DebugString(true);
|
| DCHECK(!GetTargetFilePath().empty());
|
| @@ -1247,12 +1239,8 @@ void DownloadItemImpl::CancelDownloadFile() {
|
| }
|
| }
|
|
|
| -bool DownloadItemImpl::IsDownloadReadyForCompletion() {
|
| - VLOG(20) << __FUNCTION__ << " " << AllDataSaved()
|
| - << " " << (GetSafetyState() != DownloadItem::DANGEROUS)
|
| - << " " << (state_ == IN_PROGRESS_INTERNAL)
|
| - << " " << !GetTargetFilePath().empty()
|
| - << " " << (target_path_.DirName() == current_path_.DirName());
|
| +bool DownloadItemImpl::IsDownloadReadyForCompletion(
|
| + const base::Closure& state_change_notification) {
|
| // If we don't have all the data, the download is not ready for
|
| // completion.
|
| if (!AllDataSaved())
|
| @@ -1278,6 +1266,11 @@ bool DownloadItemImpl::IsDownloadReadyForCompletion() {
|
| if (target_path_.DirName() != current_path_.DirName())
|
| return false;
|
|
|
| + // Give the delegate a chance to hold up a stop sign. It'll call
|
| + // use back through the passed callback if it does and that state changes.
|
| + if (!delegate_->ShouldCompleteDownload(this, state_change_notification))
|
| + return false;
|
| +
|
| return true;
|
| }
|
|
|
|
|