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

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: rename function 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
« no previous file with comments | « no previous file | chrome/browser/android/download/download_manager_service.h » ('j') | 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 902dbe00145d0c38ef02ba56e5c3cc79ee1ed97d..5147a80235efec955d4387aa3649e56ce1914a06 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()->RemoveDownloadsForPath(
+ 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_)
+ return true;
+
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE,
base::Bind(&DeleteExistingDownloadFile, suggested_download_path_,
« no previous file with comments | « no previous file | chrome/browser/android/download/download_manager_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698