Chromium Code Reviews| 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); |
| } |