| 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_path_reservation_tracker.h" | 5 #include "chrome/browser/download/download_path_reservation_tracker.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 // Create target_dir if necessary and appropriate. target_dir may be the last | 177 // Create target_dir if necessary and appropriate. target_dir may be the last |
| 178 // directory that the user selected in a FilePicker; if that directory has | 178 // directory that the user selected in a FilePicker; if that directory has |
| 179 // since been removed, do NOT automatically re-create it. Only automatically | 179 // since been removed, do NOT automatically re-create it. Only automatically |
| 180 // create the directory if it is the default Downloads directory or if the | 180 // create the directory if it is the default Downloads directory or if the |
| 181 // caller explicitly requested automatic directory creation. | 181 // caller explicitly requested automatic directory creation. |
| 182 if (!base::DirectoryExists(target_dir) && | 182 if (!base::DirectoryExists(target_dir) && |
| 183 (create_directory || | 183 (create_directory || |
| 184 (!default_download_path.empty() && | 184 (!default_download_path.empty() && |
| 185 (default_download_path == target_dir)))) { | 185 (default_download_path == target_dir)))) { |
| 186 file_util::CreateDirectory(target_dir); | 186 base::CreateDirectory(target_dir); |
| 187 } | 187 } |
| 188 | 188 |
| 189 // Check writability of the suggested path. If we can't write to it, default | 189 // Check writability of the suggested path. If we can't write to it, default |
| 190 // to the user's "My Documents" directory. We'll prompt them in this case. | 190 // to the user's "My Documents" directory. We'll prompt them in this case. |
| 191 if (!base::PathIsWritable(target_dir)) { | 191 if (!base::PathIsWritable(target_dir)) { |
| 192 DVLOG(1) << "Unable to write to directory \"" << target_dir.value() << "\""; | 192 DVLOG(1) << "Unable to write to directory \"" << target_dir.value() << "\""; |
| 193 is_path_writeable = false; | 193 is_path_writeable = false; |
| 194 PathService::Get(chrome::DIR_USER_DOCUMENTS, &target_dir); | 194 PathService::Get(chrome::DIR_USER_DOCUMENTS, &target_dir); |
| 195 target_path = target_dir.Append(filename); | 195 target_path = target_dir.Append(filename); |
| 196 } | 196 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 create_directory, | 357 create_directory, |
| 358 conflict_action, | 358 conflict_action, |
| 359 callback)); | 359 callback)); |
| 360 } | 360 } |
| 361 | 361 |
| 362 // static | 362 // static |
| 363 bool DownloadPathReservationTracker::IsPathInUseForTesting( | 363 bool DownloadPathReservationTracker::IsPathInUseForTesting( |
| 364 const base::FilePath& path) { | 364 const base::FilePath& path) { |
| 365 return IsPathInUse(path); | 365 return IsPathInUse(path); |
| 366 } | 366 } |
| OLD | NEW |