| OLD | NEW |
| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 if (!extensions[i].empty() && | 74 if (!extensions[i].empty() && |
| 75 download_util::GetFileDangerLevel(path) == download_util::NotDangerous) | 75 download_util::GetFileDangerLevel(path) == download_util::NotDangerous) |
| 76 auto_open_.insert(path.value()); | 76 auto_open_.insert(path.value()); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 DownloadPrefs::~DownloadPrefs() { | 80 DownloadPrefs::~DownloadPrefs() { |
| 81 } | 81 } |
| 82 | 82 |
| 83 // static | 83 // static |
| 84 void DownloadPrefs::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 84 void DownloadPrefs::RegisterUserPrefs( |
| 85 registry->RegisterBooleanPref(prefs::kPromptForDownload, | 85 user_prefs::PrefRegistrySyncable* registry) { |
| 86 false, | 86 registry->RegisterBooleanPref( |
| 87 PrefRegistrySyncable::SYNCABLE_PREF); | 87 prefs::kPromptForDownload, |
| 88 registry->RegisterStringPref(prefs::kDownloadExtensionsToOpen, | 88 false, |
| 89 std::string(), | 89 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 90 PrefRegistrySyncable::UNSYNCABLE_PREF); | 90 registry->RegisterStringPref( |
| 91 registry->RegisterBooleanPref(prefs::kDownloadDirUpgraded, | 91 prefs::kDownloadExtensionsToOpen, |
| 92 false, | 92 std::string(), |
| 93 PrefRegistrySyncable::UNSYNCABLE_PREF); | 93 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 94 registry->RegisterIntegerPref(prefs::kSaveFileType, | 94 registry->RegisterBooleanPref( |
| 95 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 95 prefs::kDownloadDirUpgraded, |
| 96 PrefRegistrySyncable::UNSYNCABLE_PREF); | 96 false, |
| 97 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 98 registry->RegisterIntegerPref( |
| 99 prefs::kSaveFileType, |
| 100 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
| 101 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 97 | 102 |
| 98 // The default download path is userprofile\download. | 103 // The default download path is userprofile\download. |
| 99 const base::FilePath& default_download_path = | 104 const base::FilePath& default_download_path = |
| 100 download_util::GetDefaultDownloadDirectory(); | 105 download_util::GetDefaultDownloadDirectory(); |
| 101 registry->RegisterFilePathPref(prefs::kDownloadDefaultDirectory, | 106 registry->RegisterFilePathPref( |
| 102 default_download_path, | 107 prefs::kDownloadDefaultDirectory, |
| 103 PrefRegistrySyncable::UNSYNCABLE_PREF); | 108 default_download_path, |
| 109 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 104 | 110 |
| 105 #if defined(OS_CHROMEOS) | 111 #if defined(OS_CHROMEOS) |
| 106 // Ensure that the download directory specified in the preferences exists. | 112 // Ensure that the download directory specified in the preferences exists. |
| 107 BrowserThread::PostTask( | 113 BrowserThread::PostTask( |
| 108 BrowserThread::FILE, FROM_HERE, | 114 BrowserThread::FILE, FROM_HERE, |
| 109 base::Bind(base::IgnoreResult(&file_util::CreateDirectory), | 115 base::Bind(base::IgnoreResult(&file_util::CreateDirectory), |
| 110 default_download_path)); | 116 default_download_path)); |
| 111 #endif // defined(OS_CHROMEOS) | 117 #endif // defined(OS_CHROMEOS) |
| 112 } | 118 } |
| 113 | 119 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 extensions.erase(extensions.size() - 1); | 214 extensions.erase(extensions.size() - 1); |
| 209 | 215 |
| 210 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); | 216 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
| 211 } | 217 } |
| 212 | 218 |
| 213 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( | 219 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |
| 214 const base::FilePath::StringType& a, | 220 const base::FilePath::StringType& a, |
| 215 const base::FilePath::StringType& b) const { | 221 const base::FilePath::StringType& b) const { |
| 216 return base::FilePath::CompareLessIgnoreCase(a, b); | 222 return base::FilePath::CompareLessIgnoreCase(a, b); |
| 217 } | 223 } |
| OLD | NEW |