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

Unified Diff: chrome/browser/ui/webui/downloads_dom_handler.cc

Issue 795353002: downloads: prevent "Clear all" from removing in progress downloads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gmock Created 6 years 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/ui/webui/downloads_dom_handler.cc
diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc
index 5ab35f113d923063dcddd69aa4d7f34c611bbe1d..83c753e117528f88fbe891c6801d22dc592253f5 100644
--- a/chrome/browser/ui/webui/downloads_dom_handler.cc
+++ b/chrome/browser/ui/webui/downloads_dom_handler.cc
@@ -532,8 +532,8 @@ void DownloadsDOMHandler::HandleClearAll(const base::ListValue* args) {
CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_CLEAR_ALL);
std::vector<content::DownloadItem*> downloads;
- if (main_notifier_.GetManager())
- main_notifier_.GetManager()->GetAllDownloads(&downloads);
+ if (GetMainNotifierManager())
+ GetMainNotifierManager()->GetAllDownloads(&downloads);
if (original_notifier_ && original_notifier_->GetManager())
original_notifier_->GetManager()->GetAllDownloads(&downloads);
RemoveDownloads(downloads);
@@ -543,8 +543,10 @@ void DownloadsDOMHandler::RemoveDownloads(
const std::vector<content::DownloadItem*>& to_remove) {
std::set<uint32> ids;
for (auto* download : to_remove) {
- if (IsRemoved(*download))
+ if (IsRemoved(*download) ||
+ download->GetState() == content::DownloadItem::IN_PROGRESS) {
continue;
+ }
DownloadsDOMHandlerData::Create(download)->set_is_removed(true);
ids.insert(download->GetId());
@@ -579,6 +581,10 @@ void DownloadsDOMHandler::ScheduleSendCurrentDownloads() {
weak_ptr_factory_.GetWeakPtr()));
}
+content::DownloadManager* DownloadsDOMHandler::GetMainNotifierManager() {
+ return main_notifier_.GetManager();
+}
+
void DownloadsDOMHandler::SendCurrentDownloads() {
update_scheduled_ = false;
content::DownloadManager::DownloadVector all_items, filtered_items;
« no previous file with comments | « chrome/browser/ui/webui/downloads_dom_handler.h ('k') | chrome/browser/ui/webui/downloads_dom_handler_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698