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

Unified Diff: chrome/browser/download/download_util.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: Use ternary operator, Insert NOTIMPLEMENTED(), Change the description of "Removed" Created 9 years, 8 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
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/resources/downloads.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_util.cc
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 05751ded1ff230e8b028cb2f9f6e1809025a5dfa..98ecfad21f94a32d31099b4704f71b60e7f7b7bf 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -664,7 +664,19 @@ DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) {
if (download->safety_state() == DownloadItem::DANGEROUS) {
file_value->SetString("state", "DANGEROUS");
} else {
- file_value->SetString("state", "COMPLETE");
+ bool path_exists = true;
+#if defined(OS_WIN)
+ if (GetFileAttributes(
+ download->GetTargetFilePath().value().c_str()) ==
+ INVALID_FILE_ATTRIBUTES)
+ path_exists = false;
+#elif defined(OS_POSIX)
+ if (access(download->GetTargetFilePath().value().c_str(), F_OK) != 0)
+ path_exists = false;
+#else
+ NOTIMPLEMENTED();
+#endif
+ file_value->SetString("state", path_exists ? "COMPLETE" : "REMOVED");
Randy Smith (Not in Mondays) 2011/04/27 18:21:21 All file system accesses need to happen on the FIL
Paweł Hajdan Jr. 2011/04/29 08:43:41 Exactly. And using SetAllow... or re-implementing
}
}
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/resources/downloads.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698