Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3999)

Unified Diff: chrome/browser/download/download_shelf_context_menu.cc

Issue 324593004: Windows: Add an "Open in Adobe Reader" menu item for PDF files in the download shelf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_shelf_context_menu.cc
diff --git a/chrome/browser/download/download_shelf_context_menu.cc b/chrome/browser/download/download_shelf_context_menu.cc
index b7f0858f93e69e75eecebc8dc2a6d85831f75e87..f67863fdbb5cf23cb6242de0973a41f64b06a11e 100644
--- a/chrome/browser/download/download_shelf_context_menu.cc
+++ b/chrome/browser/download/download_shelf_context_menu.cc
@@ -20,15 +20,18 @@
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
+#if defined(OS_WIN)
+#include "chrome/browser/ui/pdf/adobe_reader_info_win.h"
+#endif
+
using content::DownloadItem;
-using extensions::Extension;
namespace {
// Returns true if downloads resumption is enabled.
bool IsDownloadResumptionEnabled() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- return command_line.HasSwitch(switches::kEnableDownloadResumption);
+ return base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableDownloadResumption);
}
} // namespace
@@ -44,6 +47,20 @@ DownloadShelfContextMenu::DownloadShelfContextMenu(
navigator_(navigator) {
DCHECK(download_item_);
download_item_->AddObserver(this);
+
+#if defined(OS_WIN)
+#if defined(ENABLE_PLUGIN_INSTALLATION)
jam 2014/06/09 19:49:09 nit: OS_WIN implies ENABLE_PLUGIN_INSTALLATION...
Lei Zhang 2014/06/12 05:04:26 The PDF UI code we started with has defined(OS_WIN
+ is_pdf_reader_up_to_date_ = false;
+ if (IsDownloadPdf() && IsAdobeReaderDefaultPDFViewer()) {
+ AdobeReaderPluginInfo plugin_info;
+ GetAdobeReaderPluginInfo(NULL, &plugin_info);
jam 2014/06/09 19:49:09 this won't work after we remove NPAPI, which is wh
Lei Zhang 2014/06/12 05:04:26 Ok, I changed this to check the version of the rea
+ is_pdf_reader_up_to_date_ =
+ plugin_info.is_installed && plugin_info.is_secure;
+ }
+#else
+ is_pdf_reader_up_to_date_ = true;
+#endif // defined(ENABLE_PLUGIN_INSTALLATION)
+#endif // defined(OS_WIN)
}
ui::SimpleMenuModel* DownloadShelfContextMenu::GetMenuModel() {
@@ -97,6 +114,7 @@ bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const {
case LEARN_MORE_INTERRUPTED:
return true;
}
+ NOTREACHED();
return false;
}
@@ -203,7 +221,7 @@ base::string16 DownloadShelfContextMenu::GetLabelForCommandId(
return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE);
return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN);
case ALWAYS_OPEN_TYPE:
- return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE);
+ return l10n_util::GetStringUTF16(GetAlwaysOpenCommandId());
case PLATFORM_OPEN:
return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PLATFORM_OPEN);
case CANCEL:
@@ -250,7 +268,7 @@ ui::SimpleMenuModel* DownloadShelfContextMenu::GetInProgressMenuModel() {
in_progress_download_menu_model_->AddCheckItemWithStringId(
OPEN_WHEN_COMPLETE, IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE);
in_progress_download_menu_model_->AddCheckItemWithStringId(
- ALWAYS_OPEN_TYPE, IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE);
+ ALWAYS_OPEN_TYPE, GetAlwaysOpenCommandId());
in_progress_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR);
in_progress_download_menu_model_->AddItemWithStringId(
TOGGLE_PAUSE, IDS_DOWNLOAD_MENU_PAUSE_ITEM);
@@ -272,10 +290,11 @@ ui::SimpleMenuModel* DownloadShelfContextMenu::GetFinishedMenuModel() {
finished_download_menu_model_->AddItemWithStringId(
OPEN_WHEN_COMPLETE, IDS_DOWNLOAD_MENU_OPEN);
finished_download_menu_model_->AddCheckItemWithStringId(
- ALWAYS_OPEN_TYPE, IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE);
- if (DownloadItemModel(download_item_).ShouldPreferOpeningInBrowser())
+ ALWAYS_OPEN_TYPE, GetAlwaysOpenCommandId());
+ if (DownloadItemModel(download_item_).ShouldPreferOpeningInBrowser()) {
finished_download_menu_model_->AddItemWithStringId(
PLATFORM_OPEN, IDS_DOWNLOAD_MENU_PLATFORM_OPEN);
+ }
finished_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR);
finished_download_menu_model_->AddItemWithStringId(
SHOW_IN_FOLDER, IDS_DOWNLOAD_MENU_SHOW);
@@ -333,8 +352,7 @@ ui::SimpleMenuModel* DownloadShelfContextMenu::GetMaybeMaliciousMenuModel() {
return maybe_malicious_download_menu_model_.get();
}
-ui::SimpleMenuModel*
-DownloadShelfContextMenu::GetMaliciousMenuModel() {
+ui::SimpleMenuModel* DownloadShelfContextMenu::GetMaliciousMenuModel() {
if (malicious_download_menu_model_)
return malicious_download_menu_model_.get();
@@ -346,3 +364,18 @@ DownloadShelfContextMenu::GetMaliciousMenuModel() {
return malicious_download_menu_model_.get();
}
+
+int DownloadShelfContextMenu::GetAlwaysOpenCommandId() const {
asanka 2014/06/09 21:22:22 Nit: This returns a string ID, not a command ID.
Lei Zhang 2014/06/12 05:04:26 Done.
+#if defined(OS_WIN)
+ if (is_pdf_reader_up_to_date_)
+ return IDS_DOWNLOAD_MENU_ALWAYS_OPEN_PDF_IN_READER;
+#endif
+ return IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE;
+}
+
+#if defined(OS_WIN)
+bool DownloadShelfContextMenu::IsDownloadPdf() const {
+ base::FilePath path = download_item_->GetTargetFilePath();
+ return path.Extension() == FILE_PATH_LITERAL(".pdf");
+}
+#endif

Powered by Google App Engine
This is Rietveld 408576698