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

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

Issue 390983004: Merge 281172 "Windows: Add an "Open in Adobe Reader" menu item f..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 5 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
« no previous file with comments | « chrome/browser/download/download_prefs.h ('k') | chrome/browser/download/download_shelf_context_menu.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_prefs.cc
===================================================================
--- chrome/browser/download/download_prefs.cc (revision 283043)
+++ chrome/browser/download/download_prefs.cc (working copy)
@@ -22,6 +22,7 @@
#include "chrome/browser/download/download_extensions.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
+#include "chrome/browser/download/download_target_determiner.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_paths.h"
@@ -37,6 +38,10 @@
#include "chrome/browser/chromeos/file_manager/path_util.h"
#endif
+#if defined(OS_WIN)
+#include "chrome/browser/ui/pdf/adobe_reader_info_win.h"
+#endif
+
using content::BrowserContext;
using content::BrowserThread;
using content::DownloadManager;
@@ -91,7 +96,7 @@
DISALLOW_COPY_AND_ASSIGN(DefaultDownloadDirectory);
};
-static base::LazyInstance<DefaultDownloadDirectory>
+base::LazyInstance<DefaultDownloadDirectory>
g_default_download_directory = LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -126,6 +131,11 @@
GetDefaultDownloadDirectoryForProfile()));
#endif // defined(OS_CHROMEOS)
+#if defined(OS_WIN)
+ should_open_pdf_in_adobe_reader_ =
+ prefs->GetBoolean(prefs::kOpenPdfDownloadInAdobeReader);
+#endif
+
// If the download path is dangerous we forcefully reset it. But if we do
// so we set a flag to make sure we only do it once, to avoid fighting
// the user if he really wants it on an unsafe place such as the desktop.
@@ -194,6 +204,12 @@
prefs::kSaveFileDefaultDirectory,
default_download_path,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+#if defined(OS_WIN)
+ registry->RegisterBooleanPref(
+ prefs::kOpenPdfDownloadInAdobeReader,
+ false,
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+#endif
}
base::FilePath DownloadPrefs::GetDefaultDownloadDirectoryForProfile() const {
@@ -268,6 +284,10 @@
}
bool DownloadPrefs::IsAutoOpenUsed() const {
+#if defined(OS_WIN)
+ if (ShouldOpenPdfInAdobeReader())
+ return true;
+#endif
return !auto_open_.empty();
}
@@ -278,6 +298,12 @@
return false;
DCHECK(extension[0] == base::FilePath::kExtensionSeparator);
extension.erase(0, 1);
+#if defined(OS_WIN)
+ if (extension == FILE_PATH_LITERAL("pdf") &&
+ DownloadTargetDeterminer::IsAdobeReaderUpToDate() &&
+ ShouldOpenPdfInAdobeReader())
+ return true;
+#endif
return auto_open_.find(extension) != auto_open_.end();
}
@@ -305,7 +331,24 @@
SaveAutoOpenState();
}
+#if defined(OS_WIN)
+void DownloadPrefs::SetShouldOpenPdfInAdobeReader(bool should_open) {
+ if (should_open_pdf_in_adobe_reader_ == should_open)
+ return;
+ should_open_pdf_in_adobe_reader_ = should_open;
+ profile_->GetPrefs()->SetBoolean(prefs::kOpenPdfDownloadInAdobeReader,
+ should_open);
+}
+
+bool DownloadPrefs::ShouldOpenPdfInAdobeReader() const {
+ return should_open_pdf_in_adobe_reader_;
+}
+#endif
+
void DownloadPrefs::ResetAutoOpen() {
+#if defined(OS_WIN)
+ SetShouldOpenPdfInAdobeReader(false);
+#endif
auto_open_.clear();
SaveAutoOpenState();
}
« no previous file with comments | « chrome/browser/download/download_prefs.h ('k') | chrome/browser/download/download_shelf_context_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698