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