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

Side by Side Diff: chrome/browser/download/download_prefs.cc

Issue 2669773002: Revert changes to DownloadPrefs regarding PDF auto open. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/download/download_prefs.h" 5 #include "chrome/browser/download/download_prefs.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 // Ensure that the default download directory exists. 132 // Ensure that the default download directory exists.
133 BrowserThread::PostTask( 133 BrowserThread::PostTask(
134 BrowserThread::FILE, FROM_HERE, 134 BrowserThread::FILE, FROM_HERE,
135 base::Bind(base::IgnoreResult(&base::CreateDirectory), 135 base::Bind(base::IgnoreResult(&base::CreateDirectory),
136 GetDefaultDownloadDirectoryForProfile())); 136 GetDefaultDownloadDirectoryForProfile()));
137 #endif // defined(OS_CHROMEOS) 137 #endif // defined(OS_CHROMEOS)
138 138
139 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX) 139 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX)
140 should_open_pdf_in_system_reader_ = 140 should_open_pdf_in_system_reader_ =
141 prefs->GetBoolean(prefs::kOpenPdfDownloadInSystemReader) || 141 prefs->GetBoolean(prefs::kOpenPdfDownloadInSystemReader);
142 prefs->GetBoolean(prefs::kPluginsAlwaysOpenPdfExternally);
143 disable_adobe_version_check_for_tests_ = false;
144 #endif 142 #endif
145 143
146 // If the download path is dangerous we forcefully reset it. But if we do 144 // If the download path is dangerous we forcefully reset it. But if we do
147 // so we set a flag to make sure we only do it once, to avoid fighting 145 // so we set a flag to make sure we only do it once, to avoid fighting
148 // the user if they really want it on an unsafe place such as the desktop. 146 // the user if they really want it on an unsafe place such as the desktop.
149 if (!prefs->GetBoolean(prefs::kDownloadDirUpgraded)) { 147 if (!prefs->GetBoolean(prefs::kDownloadDirUpgraded)) {
150 base::FilePath current_download_dir = prefs->GetFilePath( 148 base::FilePath current_download_dir = prefs->GetFilePath(
151 prefs::kDownloadDefaultDirectory); 149 prefs::kDownloadDefaultDirectory);
152 if (DownloadPathIsDangerous(current_download_dir)) { 150 if (DownloadPathIsDangerous(current_download_dir)) {
153 prefs->SetFilePath(prefs::kDownloadDefaultDirectory, 151 prefs->SetFilePath(prefs::kDownloadDefaultDirectory,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 if (extension.empty()) 333 if (extension.empty())
336 return; 334 return;
337 DCHECK(extension[0] == base::FilePath::kExtensionSeparator); 335 DCHECK(extension[0] == base::FilePath::kExtensionSeparator);
338 extension.erase(0, 1); 336 extension.erase(0, 1);
339 auto_open_.erase(extension); 337 auto_open_.erase(extension);
340 SaveAutoOpenState(); 338 SaveAutoOpenState();
341 } 339 }
342 340
343 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX) 341 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX)
344 void DownloadPrefs::SetShouldOpenPdfInSystemReader(bool should_open) { 342 void DownloadPrefs::SetShouldOpenPdfInSystemReader(bool should_open) {
345 should_open_pdf_in_system_reader_ = should_open || 343 if (should_open_pdf_in_system_reader_ == should_open)
346 profile_->GetPrefs()->GetBoolean(prefs::kPluginsAlwaysOpenPdfExternally); 344 return;
345 should_open_pdf_in_system_reader_ = should_open;
347 profile_->GetPrefs()->SetBoolean(prefs::kOpenPdfDownloadInSystemReader, 346 profile_->GetPrefs()->SetBoolean(prefs::kOpenPdfDownloadInSystemReader,
348 should_open); 347 should_open);
349 } 348 }
350 349
351 bool DownloadPrefs::ShouldOpenPdfInSystemReader() const { 350 bool DownloadPrefs::ShouldOpenPdfInSystemReader() const {
352 #if defined(OS_WIN) 351 #if defined(OS_WIN)
353 if (!disable_adobe_version_check_for_tests_ && 352 if (IsAdobeReaderDefaultPDFViewer() &&
354 IsAdobeReaderDefaultPDFViewer() &&
355 !DownloadTargetDeterminer::IsAdobeReaderUpToDate()) { 353 !DownloadTargetDeterminer::IsAdobeReaderUpToDate()) {
356 return false; 354 return false;
357 } 355 }
358 #endif 356 #endif
359 return should_open_pdf_in_system_reader_; 357 return should_open_pdf_in_system_reader_;
360 } 358 }
361
362 void DownloadPrefs::DisableAdobeVersionCheckForTests() {
363 disable_adobe_version_check_for_tests_ = true;
364 }
365 #endif 359 #endif
366 360
367 void DownloadPrefs::ResetAutoOpen() { 361 void DownloadPrefs::ResetAutoOpen() {
368 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX) 362 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX)
369 SetShouldOpenPdfInSystemReader(false); 363 SetShouldOpenPdfInSystemReader(false);
370 #endif 364 #endif
371 auto_open_.clear(); 365 auto_open_.clear();
372 SaveAutoOpenState(); 366 SaveAutoOpenState();
373 } 367 }
374 368
(...skipping 13 matching lines...) Expand all
388 extensions.erase(extensions.size() - 1); 382 extensions.erase(extensions.size() - 1);
389 383
390 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); 384 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions);
391 } 385 }
392 386
393 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( 387 bool DownloadPrefs::AutoOpenCompareFunctor::operator()(
394 const base::FilePath::StringType& a, 388 const base::FilePath::StringType& a,
395 const base::FilePath::StringType& b) const { 389 const base::FilePath::StringType& b) const {
396 return base::FilePath::CompareLessIgnoreCase(a, b); 390 return base::FilePath::CompareLessIgnoreCase(a, b);
397 } 391 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_prefs.h ('k') | chrome/browser/download/download_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698