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

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

Issue 2087043004: MD Downloads: "Clear All" should remove dangerous downloads for good (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b720e55396101f40b4ccab9f5d4452aab2d0c5f7 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
@@ -222,9 +222,7 @@ void MdDownloadsDOMHandler::HandlePause(const base::ListValue* args) {
void MdDownloadsDOMHandler::HandleResume(const base::ListValue* args) {
CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_RESUME);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (file)
- file->Resume();
Dan Beam 2016/06/23 01:21:13 damn, maybe i'll require a test after all...
+ RemoveDownloadInArgs(args);
}
void MdDownloadsDOMHandler::HandleRemove(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);
+}
« no previous file with comments | « chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698