Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 if (!prefs->GetBoolean(prefs::kDownloadDirUpgraded)) { | 149 if (!prefs->GetBoolean(prefs::kDownloadDirUpgraded)) { |
| 150 base::FilePath current_download_dir = prefs->GetFilePath( | 150 base::FilePath current_download_dir = prefs->GetFilePath( |
| 151 prefs::kDownloadDefaultDirectory); | 151 prefs::kDownloadDefaultDirectory); |
| 152 if (DownloadPathIsDangerous(current_download_dir)) { | 152 if (DownloadPathIsDangerous(current_download_dir)) { |
| 153 prefs->SetFilePath(prefs::kDownloadDefaultDirectory, | 153 prefs->SetFilePath(prefs::kDownloadDefaultDirectory, |
| 154 GetDefaultDownloadDirectoryForProfile()); | 154 GetDefaultDownloadDirectoryForProfile()); |
| 155 } | 155 } |
| 156 prefs->SetBoolean(prefs::kDownloadDirUpgraded, true); | 156 prefs->SetBoolean(prefs::kDownloadDirUpgraded, true); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Ignore "Always prompt for download location" preference on Android. | |
| 160 #if defined(OS_ANDROID) | |
| 161 prompt_for_download_.SetValue(false); | |
|
asanka
2016/10/07 16:10:18
I don't think we can set the pref without initiali
qinmin
2016/10/07 16:25:14
Good catch. Switched to always return false in Dow
| |
| 162 #else | |
| 159 prompt_for_download_.Init(prefs::kPromptForDownload, prefs); | 163 prompt_for_download_.Init(prefs::kPromptForDownload, prefs); |
| 164 #endif | |
| 160 download_path_.Init(prefs::kDownloadDefaultDirectory, prefs); | 165 download_path_.Init(prefs::kDownloadDefaultDirectory, prefs); |
| 161 save_file_path_.Init(prefs::kSaveFileDefaultDirectory, prefs); | 166 save_file_path_.Init(prefs::kSaveFileDefaultDirectory, prefs); |
| 162 save_file_type_.Init(prefs::kSaveFileType, prefs); | 167 save_file_type_.Init(prefs::kSaveFileType, prefs); |
| 163 | 168 |
| 164 // We store any file extension that should be opened automatically at | 169 // We store any file extension that should be opened automatically at |
| 165 // download completion in this pref. | 170 // download completion in this pref. |
| 166 std::string extensions_to_open = | 171 std::string extensions_to_open = |
| 167 prefs->GetString(prefs::kDownloadExtensionsToOpen); | 172 prefs->GetString(prefs::kDownloadExtensionsToOpen); |
| 168 | 173 |
| 169 for (const auto& extension_string : base::SplitString( | 174 for (const auto& extension_string : base::SplitString( |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 extensions.erase(extensions.size() - 1); | 393 extensions.erase(extensions.size() - 1); |
| 389 | 394 |
| 390 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); | 395 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
| 391 } | 396 } |
| 392 | 397 |
| 393 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( | 398 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |
| 394 const base::FilePath::StringType& a, | 399 const base::FilePath::StringType& a, |
| 395 const base::FilePath::StringType& b) const { | 400 const base::FilePath::StringType& b) const { |
| 396 return base::FilePath::CompareLessIgnoreCase(a, b); | 401 return base::FilePath::CompareLessIgnoreCase(a, b); |
| 397 } | 402 } |
| OLD | NEW |