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 75209330acf6281ba5b485dfafc317ea080ddd0d..c06ab20e0de17c4b6a9f6a4b42b017c083dee0b5 100644 |
| --- a/chrome/browser/ui/webui/downloads_dom_handler.cc |
| +++ b/chrome/browser/ui/webui/downloads_dom_handler.cc |
| @@ -119,20 +119,12 @@ void DownloadsDOMHandler::ModelChanged() { |
| &download_items_); |
| sort(download_items_.begin(), download_items_.end(), DownloadItemSorter()); |
| - // Scan for any in progress downloads and add ourself to them as an observer. |
| + // Add oneself to all download items as an observer. |
| for (OrderedDownloads::iterator it = download_items_.begin(); |
| it != download_items_.end(); ++it) { |
| if (static_cast<int>(it - download_items_.begin()) > kMaxDownloads) |
| break; |
| - |
| - DownloadItem* download = *it; |
| - if (download->IsInProgress()) { |
| - // We want to know what happens as the download progresses. |
| - download->AddObserver(this); |
| - } else if (download->safety_state() == DownloadItem::DANGEROUS) { |
| - // We need to be notified when the user validates the dangerous download. |
| - download->AddObserver(this); |
| - } |
| + (*it)->AddObserver(this); |
| } |
| SendCurrentDownloads(); |
| @@ -146,12 +138,16 @@ void DownloadsDOMHandler::HandleGetDownloads(const ListValue* args) { |
| } else { |
| SendCurrentDownloads(); |
| } |
| + |
| + download_manager_->CheckForFilesRemoval(); |
|
Randy Smith (Not in Mondays)
2011/05/13 20:45:32
And I'd also nuke these, as well. I think doing t
haraken1
2011/05/16 11:42:27
I removed it.
|
| } |
| void DownloadsDOMHandler::HandleOpenFile(const ListValue* args) { |
| DownloadItem* file = GetDownloadByValue(args); |
| if (file) |
| file->OpenDownload(); |
| + |
| + download_manager_->CheckForFilesRemoval(); |
| } |
| void DownloadsDOMHandler::HandleDrag(const ListValue* args) { |
| @@ -163,46 +159,62 @@ void DownloadsDOMHandler::HandleDrag(const ListValue* args) { |
| gfx::NativeView view = web_ui_->tab_contents()->GetNativeView(); |
| download_util::DragDownload(file, icon, view); |
| } |
| + |
| + download_manager_->CheckForFilesRemoval(); |
| } |
| void DownloadsDOMHandler::HandleSaveDangerous(const ListValue* args) { |
| DownloadItem* file = GetDownloadByValue(args); |
| if (file) |
| download_manager_->DangerousDownloadValidated(file); |
| + |
| + download_manager_->CheckForFilesRemoval(); |
| } |
| void DownloadsDOMHandler::HandleDiscardDangerous(const ListValue* args) { |
| DownloadItem* file = GetDownloadByValue(args); |
| if (file) |
| file->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); |
| + |
| + download_manager_->CheckForFilesRemoval(); |
| } |
| void DownloadsDOMHandler::HandleShow(const ListValue* args) { |
| DownloadItem* file = GetDownloadByValue(args); |
| if (file) |
| file->ShowDownloadInShell(); |
| + |
| + download_manager_->CheckForFilesRemoval(); |
| } |
| void DownloadsDOMHandler::HandlePause(const ListValue* args) { |
| DownloadItem* file = GetDownloadByValue(args); |
| if (file) |
| file->TogglePause(); |
| + |
| + download_manager_->CheckForFilesRemoval(); |
| } |
| void DownloadsDOMHandler::HandleRemove(const ListValue* args) { |
| DownloadItem* file = GetDownloadByValue(args); |
| if (file) |
| file->Remove(); |
| + |
| + download_manager_->CheckForFilesRemoval(); |
| } |
| void DownloadsDOMHandler::HandleCancel(const ListValue* args) { |
| DownloadItem* file = GetDownloadByValue(args); |
| if (file) |
| file->Cancel(true); |
| + |
| + download_manager_->CheckForFilesRemoval(); |
| } |
| void DownloadsDOMHandler::HandleClearAll(const ListValue* args) { |
| download_manager_->RemoveAllDownloads(); |
| + |
| + download_manager_->CheckForFilesRemoval(); |
| } |
| // DownloadsDOMHandler, private: ---------------------------------------------- |