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

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

Issue 966983002: downloads: clicking "remove" on chrome://downloads should also hide shelf item. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/views/download/download_shelf_view.cc ('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/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 83c753e117528f88fbe891c6801d22dc592253f5..0dc9ba58b1280a4c9c420b94eeb18152ec94731f 100644
--- a/chrome/browser/ui/webui/downloads_dom_handler.cc
+++ b/chrome/browser/ui/webui/downloads_dom_handler.cc
@@ -32,11 +32,14 @@
#include "chrome/browser/download/download_query.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
+#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/download/drag_download_item.h"
#include "chrome/browser/extensions/api/downloads/downloads_api.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/webui/fileicon_source.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -542,6 +545,16 @@ void DownloadsDOMHandler::HandleClearAll(const base::ListValue* args) {
void DownloadsDOMHandler::RemoveDownloads(
const std::vector<content::DownloadItem*>& to_remove) {
std::set<uint32> ids;
+
+ DownloadShelf* shelf = nullptr;
+
+ // |web_contents| is NULL in tests.
+ content::WebContents* web_contents = GetWebUIWebContents();
+ if (web_contents) {
+ Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
+ shelf = browser->window()->GetDownloadShelf();
asanka 2015/02/28 00:58:52 This might not work since the shelf could be on a
+ }
+
for (auto* download : to_remove) {
if (IsRemoved(*download) ||
download->GetState() == content::DownloadItem::IN_PROGRESS) {
@@ -551,7 +564,11 @@ void DownloadsDOMHandler::RemoveDownloads(
DownloadsDOMHandlerData::Create(download)->set_is_removed(true);
ids.insert(download->GetId());
download->UpdateObservers();
+
+ if (shelf)
+ shelf->RemoveDownload(download);
}
+
removes_.push_back(ids);
}
« no previous file with comments | « chrome/browser/ui/views/download/download_shelf_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698