Skip to content

Commit

Permalink
Add "Remove from list" for download item in the download shelf.
Browse files Browse the repository at this point in the history
This would remove the download list (CTRL+J) as well.

BUG=60 (http://crbug.com/60)
TEST=Download a file from the net, download shelf appears, click the download item's arrow and "Remove from list". The item removes from the shelf and list.
Review URL: http://codereview.chromium.org/155749

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22143 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mhm@chromium.org committed Jul 31, 2009
1 parent b9ceb59 commit 731acac
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions chrome/browser/download/download_shelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ std::wstring DownloadShelfContextMenu::GetItemLabel(int id) const {
return l10n_util::GetString(IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE);
case CANCEL:
return l10n_util::GetString(IDS_DOWNLOAD_MENU_CANCEL);
case REMOVE_ITEM:
return l10n_util::GetString(IDS_DOWNLOAD_MENU_REMOVE_ITEM);
default:
NOTREACHED();
}
Expand All @@ -70,6 +72,8 @@ bool DownloadShelfContextMenu::IsItemCommandEnabled(int id) const {
return download_util::CanOpenDownload(download_);
case CANCEL:
return download_->state() == DownloadItem::IN_PROGRESS;
case REMOVE_ITEM:
return download_->state() == DownloadItem::COMPLETE;
default:
return id > 0 && id < MENU_LAST;
}
Expand All @@ -93,6 +97,9 @@ void DownloadShelfContextMenu::ExecuteItemCommand(int id) {
case CANCEL:
model_->CancelTask();
break;
case REMOVE_ITEM:
download_->Remove(false);
break;
default:
NOTREACHED();
}
Expand Down
9 changes: 5 additions & 4 deletions chrome/browser/download/download_shelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ class DownloadShelfContextMenu {
explicit DownloadShelfContextMenu(BaseDownloadItemModel* download_model);

enum ContextMenuCommands {
SHOW_IN_FOLDER = 1, // Open a file explorer window with the item selected
OPEN_WHEN_COMPLETE, // Open the download when it's finished
ALWAYS_OPEN_TYPE, // Default this file extension to always open
CANCEL, // Cancel the download
SHOW_IN_FOLDER = 1, // Open a file explorer window with the item selected.
OPEN_WHEN_COMPLETE, // Open the download when it's finished.
ALWAYS_OPEN_TYPE, // Default this file extension to always open.
CANCEL, // Cancel the download.
REMOVE_ITEM, // Removes the item from the download shelf.
MENU_LAST
};

Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/gtk/download_item_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ MenuCreateMaterial DownloadShelfContextMenuGtk::finished_download_menu[] = {
{ MENU_SEPARATOR, 0, 0, 0, NULL },
{ MENU_NORMAL, SHOW_IN_FOLDER, IDS_DOWNLOAD_LINK_SHOW, 0, NULL},
{ MENU_SEPARATOR, 0, 0, 0, NULL },
{ MENU_NORMAL, REMOVE_ITEM, IDS_DOWNLOAD_MENU_REMOVE_ITEM, 0, NULL},
{ MENU_NORMAL, CANCEL, IDS_DOWNLOAD_MENU_CANCEL, 0, NULL},
{ MENU_END, 0, 0, 0, NULL },
};
Expand All @@ -153,6 +154,7 @@ MenuCreateMaterial DownloadShelfContextMenuGtk::in_progress_download_menu[] = {
{ MENU_SEPARATOR, 0, 0, 0, NULL },
{ MENU_NORMAL, SHOW_IN_FOLDER, IDS_DOWNLOAD_LINK_SHOW, 0, NULL},
{ MENU_SEPARATOR, 0, 0, 0, NULL },
{ MENU_NORMAL, REMOVE_ITEM, IDS_DOWNLOAD_MENU_REMOVE_ITEM, 0, NULL},
{ MENU_NORMAL, CANCEL, IDS_DOWNLOAD_MENU_CANCEL, 0, NULL},
{ MENU_END, 0, 0, 0, NULL },
};
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/views/download_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class DownloadShelfContextMenuWin : public DownloadShelfContextMenu,
context_menu->AppendSeparator();
context_menu->AppendMenuItem(SHOW_IN_FOLDER, L"", views::Menu::NORMAL);
context_menu->AppendSeparator();
context_menu->AppendMenuItem(REMOVE_ITEM, L"", views::Menu::NORMAL);
context_menu->AppendMenuItem(CANCEL, L"", views::Menu::NORMAL);
context_menu->RunMenuAt(point.x(), point.y());
}
Expand Down

0 comments on commit 731acac

Please sign in to comment.