summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/download_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/download/download_util.cc')
-rw-r--r--chrome/browser/download/download_util.cc184
1 files changed, 0 insertions, 184 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 4933945..27e078e 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -31,194 +31,10 @@
namespace download_util {
-// BaseContextMenu -------------------------------------------------------------
-
-BaseContextMenu::BaseContextMenu(DownloadItem* download) : download_(download) {
-}
-
-BaseContextMenu::~BaseContextMenu() {
-}
-
// How many times to cycle the complete animation. This should be an odd number
// so that the animation ends faded out.
static const int kCompleteAnimationCycles = 5;
-bool BaseContextMenu::IsItemChecked(int id) const {
- switch (id) {
- case OPEN_WHEN_COMPLETE:
- return download_->open_when_complete();
- case ALWAYS_OPEN_TYPE: {
- const FilePath::StringType extension =
- file_util::GetFileExtensionFromPath(download_->full_path());
- return download_->manager()->ShouldOpenFileExtension(extension);
- }
- }
- return false;
-}
-
-bool BaseContextMenu::IsItemDefault(int id) const {
- return false;
-}
-
-std::wstring BaseContextMenu::GetLabel(int id) const {
- switch (id) {
- case SHOW_IN_FOLDER:
- return l10n_util::GetString(IDS_DOWNLOAD_LINK_SHOW);
- case COPY_LINK:
- return l10n_util::GetString(IDS_CONTENT_CONTEXT_COPYLINKLOCATION);
- case COPY_PATH:
- return l10n_util::GetString(IDS_DOWNLOAD_MENU_COPY_PATH);
- case COPY_FILE:
- return l10n_util::GetString(IDS_DOWNLOAD_MENU_COPY_FILE);
- case OPEN_WHEN_COMPLETE:
- if (download_->state() == DownloadItem::IN_PROGRESS)
- return l10n_util::GetString(IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE);
- return l10n_util::GetString(IDS_DOWNLOAD_MENU_OPEN);
- case ALWAYS_OPEN_TYPE:
- return l10n_util::GetString(IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE);
- case REMOVE_ITEM:
- return l10n_util::GetString(IDS_DOWNLOAD_MENU_REMOVE_ITEM);
- case CANCEL:
- return l10n_util::GetString(IDS_DOWNLOAD_MENU_CANCEL);
- default:
- NOTREACHED();
- }
- return std::wstring();
-}
-
-bool BaseContextMenu::SupportsCommand(int id) const {
- return id > 0 && id < MENU_LAST;
-}
-
-bool BaseContextMenu::IsCommandEnabled(int id) const {
- switch (id) {
- case SHOW_IN_FOLDER:
- case COPY_PATH:
- case COPY_FILE:
- case OPEN_WHEN_COMPLETE:
- return download_->state() != DownloadItem::CANCELLED;
- case ALWAYS_OPEN_TYPE:
- return CanOpenDownload(download_);
- case CANCEL:
- return download_->state() == DownloadItem::IN_PROGRESS;
- default:
- return id > 0 && id < MENU_LAST;
- }
-}
-
-void BaseContextMenu::ExecuteCommand(int id) {
- ScopedClipboardWriter scw(g_browser_process->clipboard_service());
- switch (id) {
- case SHOW_IN_FOLDER:
- download_->manager()->ShowDownloadInShell(download_);
- break;
- case COPY_LINK:
- scw.WriteText(UTF8ToUTF16(download_->url().spec()));
- break;
- case COPY_PATH:
- scw.WriteText(WideToUTF16(download_->full_path().ToWStringHack()));
- break;
- case COPY_FILE:
- // TODO(paulg): Move to OSExchangeData when implementing drag and drop?
- scw.WriteFile(download_->full_path());
- break;
- case OPEN_WHEN_COMPLETE:
- OpenDownload(download_);
- break;
- case ALWAYS_OPEN_TYPE: {
- const FilePath::StringType extension =
- file_util::GetFileExtensionFromPath(download_->full_path());
- download_->manager()->OpenFilesOfExtension(
- extension, !IsItemChecked(ALWAYS_OPEN_TYPE));
- break;
- }
- case REMOVE_ITEM:
- download_->Remove(false);
- break;
- case CANCEL:
- download_->Cancel(true);
- break;
- default:
- NOTREACHED();
- }
-}
-
-// DownloadShelfContextMenu ----------------------------------------------------
-
-DownloadShelfContextMenu::DownloadShelfContextMenu(
- DownloadItem* download,
- HWND window,
- BaseDownloadItemModel* model,
- const CPoint& point)
- : BaseContextMenu(download),
- model_(model) {
- DCHECK(model_);
-
- // The menu's anchor point is determined based on the UI layout.
- Menu::AnchorPoint anchor_point;
- if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
- anchor_point = Menu::TOPRIGHT;
- else
- anchor_point = Menu::TOPLEFT;
-
- Menu context_menu(this, anchor_point, window);
- if (download->state() == DownloadItem::COMPLETE)
- context_menu.AppendMenuItem(OPEN_WHEN_COMPLETE, L"", Menu::NORMAL);
- else
- context_menu.AppendMenuItem(OPEN_WHEN_COMPLETE, L"", Menu::CHECKBOX);
- context_menu.AppendMenuItem(ALWAYS_OPEN_TYPE, L"", Menu::CHECKBOX);
- context_menu.AppendSeparator();
- context_menu.AppendMenuItem(SHOW_IN_FOLDER, L"", Menu::NORMAL);
- context_menu.AppendSeparator();
- context_menu.AppendMenuItem(CANCEL, L"", Menu::NORMAL);
- context_menu.RunMenuAt(point.x, point.y);
-}
-
-DownloadShelfContextMenu::~DownloadShelfContextMenu() {
-}
-
-bool DownloadShelfContextMenu::IsItemDefault(int id) const {
- return id == OPEN_WHEN_COMPLETE;
-}
-
-void DownloadShelfContextMenu::ExecuteCommand(int id) {
- if (id == CANCEL)
- model_->CancelTask();
- else
- BaseContextMenu::ExecuteCommand(id);
-}
-
-// DownloadDestinationContextMenu ----------------------------------------------
-
-DownloadDestinationContextMenu::DownloadDestinationContextMenu(
- DownloadItem* download,
- HWND window,
- const CPoint& point)
- : BaseContextMenu(download) {
- // The menu's anchor point is determined based on the UI layout.
- Menu::AnchorPoint anchor_point;
- if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
- anchor_point = Menu::TOPRIGHT;
- else
- anchor_point = Menu::TOPLEFT;
-
- Menu context_menu(this, anchor_point, window);
- context_menu.AppendMenuItem(SHOW_IN_FOLDER, L"", Menu::NORMAL);
- context_menu.AppendSeparator();
- context_menu.AppendMenuItem(COPY_LINK, L"", Menu::NORMAL);
- context_menu.AppendMenuItem(COPY_PATH, L"", Menu::NORMAL);
- context_menu.AppendMenuItem(COPY_FILE, L"", Menu::NORMAL);
- context_menu.AppendSeparator();
- context_menu.AppendMenuItem(OPEN_WHEN_COMPLETE, L"", Menu::CHECKBOX);
- context_menu.AppendMenuItem(ALWAYS_OPEN_TYPE, L"", Menu::CHECKBOX);
- context_menu.AppendSeparator();
- context_menu.AppendMenuItem(REMOVE_ITEM, L"", Menu::NORMAL);
- context_menu.RunMenuAt(point.x, point.y);
-}
-
-DownloadDestinationContextMenu::~DownloadDestinationContextMenu() {
-}
-
// Download opening ------------------------------------------------------------
bool CanOpenDownload(DownloadItem* download) {