| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // File method ordering: Methods in this file are in the same order as | 5 // File method ordering: Methods in this file are in the same order as |
| 6 // in download_item_impl.h, with the following exception: The public | 6 // in download_item_impl.h, with the following exception: The public |
| 7 // interface Start is placed in chronological order with the other | 7 // interface Start is placed in chronological order with the other |
| 8 // (private) routines that together define a DownloadItem's state | 8 // (private) routines that together define a DownloadItem's state |
| 9 // transitions as the download progresses. See "Download progression | 9 // transitions as the download progresses. See "Download progression |
| 10 // cascade" later in this file. | 10 // cascade" later in this file. |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 471 } |
| 472 | 472 |
| 473 DownloadInterruptReason DownloadItemImpl::GetLastReason() const { | 473 DownloadInterruptReason DownloadItemImpl::GetLastReason() const { |
| 474 return last_reason_; | 474 return last_reason_; |
| 475 } | 475 } |
| 476 | 476 |
| 477 bool DownloadItemImpl::IsPaused() const { | 477 bool DownloadItemImpl::IsPaused() const { |
| 478 return is_paused_; | 478 return is_paused_; |
| 479 } | 479 } |
| 480 | 480 |
| 481 bool DownloadItemImpl::CanResumeInterrupted() const { |
| 482 return GetResumeMode() != RESUME_MODE_INVALID; |
| 483 } |
| 484 |
| 481 bool DownloadItemImpl::IsTemporary() const { | 485 bool DownloadItemImpl::IsTemporary() const { |
| 482 return is_temporary_; | 486 return is_temporary_; |
| 483 } | 487 } |
| 484 | 488 |
| 485 bool DownloadItemImpl::IsPartialDownload() const { | 489 bool DownloadItemImpl::IsPartialDownload() const { |
| 486 DownloadState state = InternalToExternalState(state_); | 490 DownloadState state = InternalToExternalState(state_); |
| 487 return (state == IN_PROGRESS) || (state == INTERRUPTED); | 491 return (state == IN_PROGRESS) || (state == INTERRUPTED); |
| 488 } | 492 } |
| 489 | 493 |
| 490 bool DownloadItemImpl::IsInProgress() const { | 494 bool DownloadItemImpl::IsInProgress() const { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 } | 683 } |
| 680 | 684 |
| 681 bool DownloadItemImpl::CanOpenDownload() { | 685 bool DownloadItemImpl::CanOpenDownload() { |
| 682 // We can open the file or mark it for opening on completion if the download | 686 // We can open the file or mark it for opening on completion if the download |
| 683 // is expected to complete successfully. Exclude temporary downloads, since | 687 // is expected to complete successfully. Exclude temporary downloads, since |
| 684 // they aren't owned by the download system. | 688 // they aren't owned by the download system. |
| 685 return (IsInProgress() || IsComplete()) && !IsTemporary() && | 689 return (IsInProgress() || IsComplete()) && !IsTemporary() && |
| 686 !file_externally_removed_; | 690 !file_externally_removed_; |
| 687 } | 691 } |
| 688 | 692 |
| 693 bool DownloadItemImpl::CanResumeDownload() const { |
| 694 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 695 |
| 696 // Do not allow interrupted downloads to be resumed until the target name |
| 697 // has been determined, and the user has validated any dangerous items. |
| 698 // TODO(rdsmith) -- Add a state indicating that filename determination has |
| 699 // occurred. |
| 700 if (GetTargetFilePath().empty()) |
| 701 return false; |
| 702 |
| 703 if (GetSafetyState() == DANGEROUS) |
| 704 return false; |
| 705 |
| 706 return IsInProgress() || (GetResumeMode() != RESUME_MODE_INVALID); |
| 707 } |
| 708 |
| 689 bool DownloadItemImpl::ShouldOpenFileBasedOnExtension() { | 709 bool DownloadItemImpl::ShouldOpenFileBasedOnExtension() { |
| 690 return delegate_->ShouldOpenFileBasedOnExtension(GetUserVerifiedFilePath()); | 710 return delegate_->ShouldOpenFileBasedOnExtension(GetUserVerifiedFilePath()); |
| 691 } | 711 } |
| 692 | 712 |
| 693 bool DownloadItemImpl::GetOpenWhenComplete() const { | 713 bool DownloadItemImpl::GetOpenWhenComplete() const { |
| 694 return open_when_complete_; | 714 return open_when_complete_; |
| 695 } | 715 } |
| 696 | 716 |
| 697 bool DownloadItemImpl::GetAutoOpened() { | 717 bool DownloadItemImpl::GetAutoOpened() { |
| 698 return auto_opened_; | 718 return auto_opened_; |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 case RESUME_MODE_USER_CONTINUE: | 1683 case RESUME_MODE_USER_CONTINUE: |
| 1664 return "USER_CONTINUE"; | 1684 return "USER_CONTINUE"; |
| 1665 case RESUME_MODE_USER_RESTART: | 1685 case RESUME_MODE_USER_RESTART: |
| 1666 return "USER_RESTART"; | 1686 return "USER_RESTART"; |
| 1667 } | 1687 } |
| 1668 NOTREACHED() << "Unknown resume mode " << mode; | 1688 NOTREACHED() << "Unknown resume mode " << mode; |
| 1669 return "unknown"; | 1689 return "unknown"; |
| 1670 } | 1690 } |
| 1671 | 1691 |
| 1672 } // namespace content | 1692 } // namespace content |
| OLD | NEW |