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

Unified Diff: chrome/browser/download/download_item.cc

Issue 6905049: Detect removed files and reflect the state in chrome://downloads and the download shelf (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Correct typo Created 9 years, 7 months 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: chrome/browser/download/download_item.cc
diff --git a/chrome/browser/download/download_item.cc b/chrome/browser/download/download_item.cc
index 59126a86d43769586c96fbf06678a0fd2ce9b69c..04f50502601c54b4d3e6193906c486825bd5f367 100644
--- a/chrome/browser/download/download_item.cc
+++ b/chrome/browser/download/download_item.cc
@@ -131,6 +131,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
download_manager_(download_manager),
is_paused_(false),
open_when_complete_(false),
+ file_externally_removed_(false),
safety_state_(SAFE),
danger_type_(NOT_DANGEROUS),
auto_opened_(false),
@@ -169,6 +170,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
download_manager_(download_manager),
is_paused_(false),
open_when_complete_(false),
+ file_externally_removed_(false),
safety_state_(GetSafetyState(info.is_dangerous_file,
info.is_dangerous_url)),
danger_type_(GetDangerType(info.is_dangerous_file,
@@ -207,6 +209,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
download_manager_(download_manager),
is_paused_(false),
open_when_complete_(false),
+ file_externally_removed_(false),
safety_state_(SAFE),
danger_type_(NOT_DANGEROUS),
auto_opened_(false),
@@ -256,7 +259,8 @@ void DownloadItem::OpenFilesBasedOnExtension(bool open) {
void DownloadItem::OpenDownload() {
if (IsPartialDownload()) {
open_when_complete_ = !open_when_complete_;
- } else if (IsComplete()) {
+ } else if (IsComplete() && !file_externally_removed()) {
+ download_manager_->CheckForFileRemoval(this);
Randy Smith (Not in Mondays) 2011/05/16 20:57:12 I think I'd like a comment here explaining this de
Paweł Hajdan Jr. 2011/05/17 20:03:39 There is an ugliness in a way those objects commun
Randy Smith (Not in Mondays) 2011/05/18 19:28:18 Pawel: I'm confused about what you mean. Dispatch
Paweł Hajdan Jr. 2011/05/18 20:03:43 Sorry, I was a bit afraid that comment could be co
Randy Smith (Not in Mondays) 2011/05/18 20:13:13 Ah, thank you! That makes sense, but it won't wor
Paweł Hajdan Jr. 2011/05/18 20:23:44 Oh, I see. Indeed, please ignore my comment about
haraken1 2011/06/07 12:49:18 In conclusion, here I only added the comment that
opened_ = true;
FOR_EACH_OBSERVER(Observer, observers_, OnDownloadOpened(this));
if (is_extension_install()) {
@@ -356,6 +360,11 @@ void DownloadItem::OnAllDataSaved(int64 size) {
StopProgressTimer();
}
+void DownloadItem::OnDownloadedFileRemoved() {
+ file_externally_removed_ = true;
+ UpdateObservers();
+}
+
void DownloadItem::Completed() {
VLOG(20) << __FUNCTION__ << "() " << DebugString(false);

Powered by Google App Engine
This is Rietveld 408576698