| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const FilePath& default_download_path = | 74 const FilePath& default_download_path = |
| 75 download_util::GetDefaultDownloadDirectory(); | 75 download_util::GetDefaultDownloadDirectory(); |
| 76 prefs->RegisterFilePathPref(prefs::kDownloadDefaultDirectory, | 76 prefs->RegisterFilePathPref(prefs::kDownloadDefaultDirectory, |
| 77 default_download_path, | 77 default_download_path, |
| 78 PrefService::UNSYNCABLE_PREF); | 78 PrefService::UNSYNCABLE_PREF); |
| 79 | 79 |
| 80 #if defined(OS_CHROMEOS) | 80 #if defined(OS_CHROMEOS) |
| 81 // Ensure that the download directory specified in the preferences exists. | 81 // Ensure that the download directory specified in the preferences exists. |
| 82 BrowserThread::PostTask( | 82 BrowserThread::PostTask( |
| 83 BrowserThread::FILE, FROM_HERE, | 83 BrowserThread::FILE, FROM_HERE, |
| 84 NewRunnableFunction(&file_util::CreateDirectory, default_download_path)); | 84 base::Bind(base::IgnoreResult(&file_util::CreateDirectory), |
| 85 default_download_path)); |
| 85 #endif // defined(OS_CHROMEOS) | 86 #endif // defined(OS_CHROMEOS) |
| 86 | 87 |
| 87 // If the download path is dangerous we forcefully reset it. But if we do | 88 // If the download path is dangerous we forcefully reset it. But if we do |
| 88 // so we set a flag to make sure we only do it once, to avoid fighting | 89 // so we set a flag to make sure we only do it once, to avoid fighting |
| 89 // the user if he really wants it on an unsafe place such as the desktop. | 90 // the user if he really wants it on an unsafe place such as the desktop. |
| 90 if (!prefs->GetBoolean(prefs::kDownloadDirUpgraded)) { | 91 if (!prefs->GetBoolean(prefs::kDownloadDirUpgraded)) { |
| 91 FilePath current_download_dir = prefs->GetFilePath( | 92 FilePath current_download_dir = prefs->GetFilePath( |
| 92 prefs::kDownloadDefaultDirectory); | 93 prefs::kDownloadDefaultDirectory); |
| 93 if (download_util::DownloadPathIsDangerous(current_download_dir)) { | 94 if (download_util::DownloadPathIsDangerous(current_download_dir)) { |
| 94 prefs->SetFilePath(prefs::kDownloadDefaultDirectory, | 95 prefs->SetFilePath(prefs::kDownloadDefaultDirectory, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 extensions.erase(extensions.size() - 1); | 179 extensions.erase(extensions.size() - 1); |
| 179 | 180 |
| 180 prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions); | 181 prefs_->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
| 181 } | 182 } |
| 182 | 183 |
| 183 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( | 184 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |
| 184 const FilePath::StringType& a, | 185 const FilePath::StringType& a, |
| 185 const FilePath::StringType& b) const { | 186 const FilePath::StringType& b) const { |
| 186 return FilePath::CompareLessIgnoreCase(a, b); | 187 return FilePath::CompareLessIgnoreCase(a, b); |
| 187 } | 188 } |
| OLD | NEW |