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

Unified Diff: chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc

Issue 1882413004: Fix an issue that download file is not deleted when clicking Replace button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc
diff --git a/chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc b/chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc
index 823222bdad24579a384e5d534edd08e830247ae3..f4cf6a25e9cac60624fd144e22bb68a6cf041cc4 100644
--- a/chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc
+++ b/chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc
@@ -17,6 +17,22 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
+namespace {
+
+void DeleteExistingDownloadFile(
+ const base::FilePath& download_path,
+ const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
+ base::File::Info info;
+ if (GetFileInfo(download_path, &info) && !info.is_directory)
+ base::DeleteFile(download_path, false);
+
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(callback, download_path));
+}
+
+} // namespace
+
namespace chrome {
namespace android {
@@ -49,7 +65,10 @@ ChromeDownloadManagerOverwriteInfoBarDelegate::GetIdentifier() const {
}
bool ChromeDownloadManagerOverwriteInfoBarDelegate::OverwriteExistingFile() {
- file_selected_callback_.Run(suggested_download_path_);
+ content::BrowserThread::PostTask(
+ content::BrowserThread::FILE, FROM_HERE,
+ base::Bind(&DeleteExistingDownloadFile, suggested_download_path_,
+ file_selected_callback_));
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698