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

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

Issue 2344483003: Ask download manager to remove a download if it is overwritten by another (Closed)
Patch Set: delete completed download with same path Created 4 years, 3 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/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 902dbe00145d0c38ef02ba56e5c3cc79ee1ed97d..c5ed4a503391ecc08c0abc610bfa86d10a0dfffa 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
@@ -13,6 +13,7 @@
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/android/download/download_controller.h"
+#include "chrome/browser/android/download/download_manager_service.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h"
#include "components/infobars/core/infobar.h"
@@ -21,6 +22,15 @@
namespace {
+void DeleteExistingDownloadFileDone(
+ const base::FilePath& download_path,
+ const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DownloadManagerService::GetInstance()->RemoveExternallyRemovedDownloads(
+ download_path);
+ callback.Run(download_path);
+}
+
void DeleteExistingDownloadFile(
const base::FilePath& download_path,
const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) {
@@ -29,8 +39,9 @@ void DeleteExistingDownloadFile(
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));
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&DeleteExistingDownloadFileDone, download_path, callback));
}
void CreateNewFileDone(
@@ -89,6 +100,9 @@ ChromeDownloadManagerOverwriteInfoBarDelegate::GetIdentifier() const {
}
bool ChromeDownloadManagerOverwriteInfoBarDelegate::OverwriteExistingFile() {
+ if (!download_item_)
Theresa 2016/09/21 17:40:43 I'm not very familiar with this class, but looking
qinmin 2016/09/21 21:20:29 Yes, if this returns true, the file will no longer
+ return true;
+
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE,
base::Bind(&DeleteExistingDownloadFile, suggested_download_path_,

Powered by Google App Engine
This is Rietveld 408576698