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

Unified Diff: chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc

Issue 2100443003: MD Downloads: "Clear All" should remove dangerous downloads for good (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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/ui/webui/md_downloads/md_downloads_dom_handler.cc
diff --git a/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc b/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc
index d13026ad06dc947c9ed316efc79840b1deb0acf6..eb5c832efdd8f2a59fc4211f59452bc2eddffdd0 100644
--- a/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc
+++ b/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc
@@ -201,9 +201,7 @@ void MdDownloadsDOMHandler::HandleSaveDangerous(const base::ListValue* args) {
void MdDownloadsDOMHandler::HandleDiscardDangerous(
const base::ListValue* args) {
CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DISCARD_DANGEROUS);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (file)
- file->Remove();
+ RemoveDownloadInArgs(args);
}
void MdDownloadsDOMHandler::HandleShow(const base::ListValue* args) {
@@ -232,13 +230,7 @@ void MdDownloadsDOMHandler::HandleRemove(const base::ListValue* args) {
return;
CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_REMOVE);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (!file)
- return;
-
- DownloadVector downloads;
- downloads.push_back(file);
- RemoveDownloads(downloads);
+ RemoveDownloadInArgs(args);
}
void MdDownloadsDOMHandler::HandleUndo(const base::ListValue* args) {
@@ -305,6 +297,12 @@ void MdDownloadsDOMHandler::RemoveDownloads(const DownloadVector& to_remove) {
IdSet ids;
for (auto* download : to_remove) {
+ if (download->IsDangerous()) {
+ // Don't allow users to revive dangerous downloads; just nuke 'em.
+ download->Remove();
+ continue;
+ }
+
DownloadItemModel item_model(download);
if (!item_model.ShouldShowInShelf() ||
download->GetState() == content::DownloadItem::IN_PROGRESS) {
@@ -427,3 +425,13 @@ void MdDownloadsDOMHandler::CheckForRemovedFiles() {
if (GetOriginalNotifierManager())
GetOriginalNotifierManager()->CheckForHistoryFilesRemoval();
}
+
+void MdDownloadsDOMHandler::RemoveDownloadInArgs(const base::ListValue* args) {
+ content::DownloadItem* file = GetDownloadByValue(args);
+ if (!file)
+ return;
+
+ DownloadVector downloads;
+ downloads.push_back(file);
+ RemoveDownloads(downloads);
+}

Powered by Google App Engine
This is Rietveld 408576698