diff options
author | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 02:54:54 +0000 |
---|---|---|
committer | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 02:54:54 +0000 |
commit | d9013fffb12777b7e6e0a61d5adcbd1c2c21736b (patch) | |
tree | d938a84224af1ef97810a4cc28df6bccb149e589 /chrome/browser | |
parent | 47867d38b6a879ac715780d69efe1e072dd32bf0 (diff) | |
download | chromium_src-d9013fffb12777b7e6e0a61d5adcbd1c2c21736b.zip chromium_src-d9013fffb12777b7e6e0a61d5adcbd1c2c21736b.tar.gz chromium_src-d9013fffb12777b7e6e0a61d5adcbd1c2c21736b.tar.bz2 |
Add "Remove from list" for each download in domui page.
A "Remove from list" link would be added to the download items and once clicked, it will remove it from the shelf and list.
BUG=60 (http://crbug.com/60)
TEST=Download a file from the net, CTRL+J. Click on "Remove from list". The item removes from the list and download shelf.
Review URL: http://codereview.chromium.org/155750
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22138 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/dom_ui/downloads_dom_handler.cc | 8 | ||||
-rw-r--r-- | chrome/browser/dom_ui/downloads_dom_handler.h | 4 | ||||
-rw-r--r-- | chrome/browser/dom_ui/downloads_ui.cc | 2 | ||||
-rw-r--r-- | chrome/browser/resources/downloads.html | 12 |
4 files changed, 26 insertions, 0 deletions
diff --git a/chrome/browser/dom_ui/downloads_dom_handler.cc b/chrome/browser/dom_ui/downloads_dom_handler.cc index 66ee916..703d2fb6 100644 --- a/chrome/browser/dom_ui/downloads_dom_handler.cc +++ b/chrome/browser/dom_ui/downloads_dom_handler.cc @@ -87,6 +87,8 @@ void DownloadsDOMHandler::RegisterMessages() { NewCallback(this, &DownloadsDOMHandler::HandlePause)); dom_ui_->RegisterMessageCallback("resume", NewCallback(this, &DownloadsDOMHandler::HandlePause)); + dom_ui_->RegisterMessageCallback("remove", + NewCallback(this, &DownloadsDOMHandler::HandleRemove)); dom_ui_->RegisterMessageCallback("cancel", NewCallback(this, &DownloadsDOMHandler::HandleCancel)); dom_ui_->RegisterMessageCallback("clearAll", @@ -195,6 +197,12 @@ void DownloadsDOMHandler::HandlePause(const Value* value) { file->TogglePause(); } +void DownloadsDOMHandler::HandleRemove(const Value* value) { + DownloadItem* file = GetDownloadByValue(value); + if (file) + file->Remove(false); +} + void DownloadsDOMHandler::HandleCancel(const Value* value) { DownloadItem* file = GetDownloadByValue(value); if (file) diff --git a/chrome/browser/dom_ui/downloads_dom_handler.h b/chrome/browser/dom_ui/downloads_dom_handler.h index a0158c4..cb5063e 100644 --- a/chrome/browser/dom_ui/downloads_dom_handler.h +++ b/chrome/browser/dom_ui/downloads_dom_handler.h @@ -58,6 +58,10 @@ class DownloadsDOMHandler : public DOMMessageHandler, // Callback for the "pause" message - pauses the file download. void HandlePause(const Value* value); + // Callback for the "remove" message - removes the file download from shelf + // and list. + void HandleRemove(const Value* value); + // Callback for the "cancel" message - cancels the download. void HandleCancel(const Value* value); diff --git a/chrome/browser/dom_ui/downloads_ui.cc b/chrome/browser/dom_ui/downloads_ui.cc index aac3a86..f6e8a63 100644 --- a/chrome/browser/dom_ui/downloads_ui.cc +++ b/chrome/browser/dom_ui/downloads_ui.cc @@ -93,6 +93,8 @@ void DownloadsUIHTMLSource::StartDataRequest(const std::string& path, l10n_util::GetString(IDS_DOWNLOAD_LINK_CANCEL)); localized_strings.SetString(L"control_resume", l10n_util::GetString(IDS_DOWNLOAD_LINK_RESUME)); + localized_strings.SetString(L"control_removefromlist", + l10n_util::GetString(IDS_DOWNLOAD_LINK_REMOVE)); SetFontAndTextDirection(&localized_strings); diff --git a/chrome/browser/resources/downloads.html b/chrome/browser/resources/downloads.html index 1616491..2765c1e 100644 --- a/chrome/browser/resources/downloads.html +++ b/chrome/browser/resources/downloads.html @@ -395,6 +395,10 @@ function Download(download) { localStrings.getString('control_resume')); this.nodeControls_.appendChild(this.controlResume_); + this.controlRemove_ = createLink(bind(this.remove_, this), + localStrings.getString('control_removefromlist')); + this.nodeControls_.appendChild(this.controlRemove_); + this.controlCancel_ = createLink(bind(this.cancel_, this), localStrings.getString('control_cancel')); this.nodeControls_.appendChild(this.controlCancel_); @@ -615,6 +619,14 @@ Download.prototype.togglePause_ = function() { } /** + * Tells the backend to remove this download from history and download shelf. + */ + Download.prototype.remove_ = function() { + chrome.send("remove", [this.id_.toString()]); + return false; +} + +/** * Tells the backend to cancel this download. */ Download.prototype.cancel_ = function() { |