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

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: 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..6c343e5e8a18d90ae5d5be7c5fc0ece846d3480f 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,24 +13,38 @@
#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"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
namespace {
+void DeleteExistingDownloadFileDone(
+ bool is_off_the_record,
+ const base::Closure& callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DownloadManagerService::GetInstance()->CheckForExternallyRemovedDownloads(
Theresa 2016/09/15 03:28:30 The check for externally removed downloads doesn't
qinmin 2016/09/15 22:18:56 I believe CheckForExternallyRemovedDownloads() doe
Theresa 2016/09/15 22:44:09 When I was adding the checks for externally downlo
qinmin 2016/09/15 23:14:00 Yes, I have tested this patch and it works as inte
Theresa 2016/09/15 23:50:32 Yes, that's what I expected. In #5 step, the downl
qinmin 2016/09/16 00:14:59 Thanks, Theresa. Yes, you are correct. The deletio
+ nullptr, nullptr, is_off_the_record);
+ callback.Run();
+}
+
void DeleteExistingDownloadFile(
const base::FilePath& download_path,
+ bool is_off_the_record,
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));
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&DeleteExistingDownloadFileDone, is_off_the_record,
+ base::Bind(callback, download_path)));
}
void CreateNewFileDone(
@@ -89,9 +103,13 @@ 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_,
+ download_item_->GetBrowserContext()->IsOffTheRecord(),
file_selected_callback_));
return true;
}
« 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