diff options
author | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-04 21:14:31 +0000 |
---|---|---|
committer | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-04 21:14:31 +0000 |
commit | aec6ad64baed1efb092adcc53bf2a1473a584876 (patch) | |
tree | 1a27caff548e6602d26208bac7e027a87dcca25e /chrome | |
parent | 13e2edee5394104e38ea6713b57eb8e79e030e1c (diff) | |
download | chromium_src-aec6ad64baed1efb092adcc53bf2a1473a584876.zip chromium_src-aec6ad64baed1efb092adcc53bf2a1473a584876.tar.gz chromium_src-aec6ad64baed1efb092adcc53bf2a1473a584876.tar.bz2 |
Include Pause/Resume in the context menu for the item in the download shelf.
The pause and resume context item will only appear when the download is in progress. It will not show on the context menu if the download has been cancelled or completed.
It is a toggle state, either pause or resume, not both.
BUG=16929 (http://www.crbug.com/16929)
TEST=Download a large file, right click pause, then resume. As well, download a small file, wait till finishes, right click, you will see no pause/resume.
Review URL: http://codereview.chromium.org/159844
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/generated_resources.grd | 8 | ||||
-rw-r--r-- | chrome/browser/download/download_shelf.cc | 15 | ||||
-rw-r--r-- | chrome/browser/download/download_shelf.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/download_item_view.cc | 2 |
4 files changed, 26 insertions, 0 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index dc83d77..f6a0983 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -1784,6 +1784,14 @@ each locale. --> desc="Download context menu remove"> &Remove from list </message> + <message name="IDS_DOWNLOAD_MENU_PAUSE_ITEM" + desc="Download context menu pause download"> + &Pause + </message> + <message name="IDS_DOWNLOAD_MENU_RESUME_ITEM" + desc="Download context menu resume download"> + &Resume + </message> <!-- Remove in-progress downloads confirmation dialog --> <message name="IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_TITLE" desc="Title of the dialog asking for user confirmation to close the browser when one download is in-progress."> diff --git a/chrome/browser/download/download_shelf.cc b/chrome/browser/download/download_shelf.cc index b4d7701..70db47a 100644 --- a/chrome/browser/download/download_shelf.cc +++ b/chrome/browser/download/download_shelf.cc @@ -57,6 +57,12 @@ std::wstring DownloadShelfContextMenu::GetItemLabel(int id) const { return l10n_util::GetString(IDS_DOWNLOAD_MENU_CANCEL); case REMOVE_ITEM: return l10n_util::GetString(IDS_DOWNLOAD_MENU_REMOVE_ITEM); + case TOGGLE_PAUSE: { + if (download_->is_paused()) + return l10n_util::GetString(IDS_DOWNLOAD_MENU_RESUME_ITEM); + else + return l10n_util::GetString(IDS_DOWNLOAD_MENU_PAUSE_ITEM); + } default: NOTREACHED(); } @@ -75,6 +81,8 @@ bool DownloadShelfContextMenu::IsItemCommandEnabled(int id) const { case REMOVE_ITEM: return download_->state() == DownloadItem::COMPLETE || download_->state() == DownloadItem::CANCELLED; + case TOGGLE_PAUSE: + return download_->state() == DownloadItem::IN_PROGRESS; default: return id > 0 && id < MENU_LAST; } @@ -101,6 +109,13 @@ void DownloadShelfContextMenu::ExecuteItemCommand(int id) { case REMOVE_ITEM: download_->Remove(false); break; + case TOGGLE_PAUSE: + // It is possible for the download to complete before the user clicks the + // menu item, recheck if the download is in progress state before toggling + // pause. + if (download_->state() == DownloadItem::IN_PROGRESS) + download_->TogglePause(); + break; default: NOTREACHED(); } diff --git a/chrome/browser/download/download_shelf.h b/chrome/browser/download/download_shelf.h index 6718a9b..fad559a 100644 --- a/chrome/browser/download/download_shelf.h +++ b/chrome/browser/download/download_shelf.h @@ -56,6 +56,7 @@ class DownloadShelfContextMenu { ALWAYS_OPEN_TYPE, // Default this file extension to always open. CANCEL, // Cancel the download. REMOVE_ITEM, // Removes the item from the download shelf. + TOGGLE_PAUSE, // Temporarily pause a download. MENU_LAST }; diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc index 760585d..bbf053d 100644 --- a/chrome/browser/views/download_item_view.cc +++ b/chrome/browser/views/download_item_view.cc @@ -96,6 +96,8 @@ class DownloadShelfContextMenuWin : public DownloadShelfContextMenu, } context_menu->AppendMenuItem(ALWAYS_OPEN_TYPE, L"", views::Menu::CHECKBOX); context_menu->AppendSeparator(); + if (download_->state() == DownloadItem::IN_PROGRESS) + context_menu->AppendMenuItem(TOGGLE_PAUSE, L"", views::Menu::NORMAL); context_menu->AppendMenuItem(SHOW_IN_FOLDER, L"", views::Menu::NORMAL); context_menu->AppendSeparator(); context_menu->AppendMenuItem(REMOVE_ITEM, L"", views::Menu::NORMAL); |