Chromium Code Reviews| Index: chrome/browser/download/download_prefs.cc |
| diff --git a/chrome/browser/download/download_prefs.cc b/chrome/browser/download/download_prefs.cc |
| index fbefa3d1afd1db392f5d6a423c128bfb2b07bc63..1ba9031012e823aeb6463085c00cc6bf9bc79f93 100644 |
| --- a/chrome/browser/download/download_prefs.cc |
| +++ b/chrome/browser/download/download_prefs.cc |
| @@ -56,7 +56,9 @@ DownloadPrefs::DownloadPrefs(Profile* profile) : profile_(profile) { |
| prompt_for_download_.Init(prefs::kPromptForDownload, prefs); |
| download_path_.Init(prefs::kDownloadDefaultDirectory, prefs); |
| + save_file_path_.Init(prefs::kSaveFileDefaultDirectory, prefs); |
| save_file_type_.Init(prefs::kSaveFileType, prefs); |
| + incognito_save_file_path_ = *save_file_path_; |
| // We store any file extension that should be opened automatically at |
| // download completion in this pref. |
| @@ -107,6 +109,10 @@ void DownloadPrefs::RegisterUserPrefs( |
| prefs::kDownloadDefaultDirectory, |
| default_download_path, |
| user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| + registry->RegisterFilePathPref( |
| + prefs::kSaveFileDefaultDirectory, |
| + default_download_path, |
| + user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| #if defined(OS_CHROMEOS) |
| // Ensure that the download directory specified in the preferences exists. |
| @@ -144,6 +150,29 @@ base::FilePath DownloadPrefs::DownloadPath() const { |
| return *download_path_; |
| } |
| +void DownloadPrefs::SetDownloadPath(const base::FilePath& path) { |
| + download_path_.SetValue(path); |
|
asanka
2013/05/07 15:15:12
Suggestion: Should this also set save_file_path_ ?
benjhayden
2013/05/17 20:31:54
Done.
|
| +} |
| + |
| +base::FilePath DownloadPrefs::SaveFilePath() const { |
| + return profile_->IsOffTheRecord() ? incognito_save_file_path_ : |
| + *save_file_path_; |
| +} |
| + |
| +void DownloadPrefs::SetSaveFilePath(const base::FilePath& path) { |
| + if (path == SaveFilePath()) |
| + return; |
| + if (profile_->IsOffTheRecord()) { |
|
asanka
2013/05/07 15:15:12
Does this need to be handled this way? Isn't the i
benjhayden
2013/05/17 20:31:54
This is necessary. Without incognito_save_file_pat
|
| + incognito_save_file_path_ = path; |
| + } else { |
| + save_file_path_.SetValue(path); |
| + } |
| +} |
| + |
| +void DownloadPrefs::SetSaveFileType(int type) { |
| + save_file_type_.SetValue(type); |
| +} |
| + |
| bool DownloadPrefs::PromptForDownload() const { |
| // If the DownloadDirectory policy is set, then |prompt_for_download_| should |
| // always be false. |