| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/string_split.h" | 8 #include "base/string_split.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 auto_open_.insert(path.value()); | 38 auto_open_.insert(path.value()); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 DownloadPrefs::~DownloadPrefs() { | 42 DownloadPrefs::~DownloadPrefs() { |
| 43 SaveAutoOpenState(); | 43 SaveAutoOpenState(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // static | 46 // static |
| 47 void DownloadPrefs::RegisterUserPrefs(PrefService* prefs) { | 47 void DownloadPrefs::RegisterUserPrefs(PrefService* prefs) { |
| 48 prefs->RegisterBooleanPref(prefs::kPromptForDownload, false); | 48 prefs->RegisterBooleanPref(prefs::kPromptForDownload, |
| 49 prefs->RegisterStringPref(prefs::kDownloadExtensionsToOpen, ""); | 49 false, |
| 50 prefs->RegisterBooleanPref(prefs::kDownloadDirUpgraded, false); | 50 true /* sync pref */); |
| 51 prefs->RegisterStringPref(prefs::kDownloadExtensionsToOpen, |
| 52 "", |
| 53 false /* don't sync pref */); |
| 54 prefs->RegisterBooleanPref(prefs::kDownloadDirUpgraded, |
| 55 false, |
| 56 false /* don't sync pref */); |
| 51 prefs->RegisterIntegerPref(prefs::kSaveFileType, | 57 prefs->RegisterIntegerPref(prefs::kSaveFileType, |
| 52 SavePackage::SAVE_AS_COMPLETE_HTML); | 58 SavePackage::SAVE_AS_COMPLETE_HTML, |
| 59 false /* don't sync pref */); |
| 53 | 60 |
| 54 // The default download path is userprofile\download. | 61 // The default download path is userprofile\download. |
| 55 const FilePath& default_download_path = | 62 const FilePath& default_download_path = |
| 56 download_util::GetDefaultDownloadDirectory(); | 63 download_util::GetDefaultDownloadDirectory(); |
| 57 prefs->RegisterFilePathPref(prefs::kDownloadDefaultDirectory, | 64 prefs->RegisterFilePathPref(prefs::kDownloadDefaultDirectory, |
| 58 default_download_path); | 65 default_download_path, |
| 66 false /* don't sync pref */); |
| 59 | 67 |
| 60 #if defined(OS_CHROMEOS) | 68 #if defined(OS_CHROMEOS) |
| 61 // Ensure that the download directory specified in the preferences exists. | 69 // Ensure that the download directory specified in the preferences exists. |
| 62 BrowserThread::PostTask( | 70 BrowserThread::PostTask( |
| 63 BrowserThread::FILE, FROM_HERE, | 71 BrowserThread::FILE, FROM_HERE, |
| 64 NewRunnableFunction(&file_util::CreateDirectory, default_download_path)); | 72 NewRunnableFunction(&file_util::CreateDirectory, default_download_path)); |
| 65 #endif // defined(OS_CHROMEOS) | 73 #endif // defined(OS_CHROMEOS) |
| 66 | 74 |
| 67 // If the download path is dangerous we forcefully reset it. But if we do | 75 // If the download path is dangerous we forcefully reset it. But if we do |
| 68 // so we set a flag to make sure we only do it once, to avoid fighting | 76 // so we set a flag to make sure we only do it once, to avoid fighting |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 extensions.erase(extensions.size() - 1); | 146 extensions.erase(extensions.size() - 1); |
| 139 | 147 |
| 140 prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions); | 148 prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
| 141 } | 149 } |
| 142 | 150 |
| 143 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( | 151 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |
| 144 const FilePath::StringType& a, | 152 const FilePath::StringType& a, |
| 145 const FilePath::StringType& b) const { | 153 const FilePath::StringType& b) const { |
| 146 return FilePath::CompareLessIgnoreCase(a, b); | 154 return FilePath::CompareLessIgnoreCase(a, b); |
| 147 } | 155 } |
| OLD | NEW |