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 // File method ordering: Methods in this file are in the same order as | 5 // File method ordering: Methods in this file are in the same order as |
6 // in download_item_impl.h, with the following exception: The public | 6 // in download_item_impl.h, with the following exception: The public |
7 // interface Start is placed in chronological order with the other | 7 // interface Start is placed in chronological order with the other |
8 // (private) routines that together define a DownloadItem's state | 8 // (private) routines that together define a DownloadItem's state |
9 // transitions as the download progresses. See "Download progression | 9 // transitions as the download progresses. See "Download progression |
10 // cascade" later in this file. | 10 // cascade" later in this file. |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 this, base::Bind(&DownloadItemImpl::OnDownloadTargetDetermined, | 1163 this, base::Bind(&DownloadItemImpl::OnDownloadTargetDetermined, |
1164 weak_ptr_factory_.GetWeakPtr())); | 1164 weak_ptr_factory_.GetWeakPtr())); |
1165 } | 1165 } |
1166 | 1166 |
1167 // Called by delegate_ when the download target path has been | 1167 // Called by delegate_ when the download target path has been |
1168 // determined. | 1168 // determined. |
1169 void DownloadItemImpl::OnDownloadTargetDetermined( | 1169 void DownloadItemImpl::OnDownloadTargetDetermined( |
1170 const base::FilePath& target_path, | 1170 const base::FilePath& target_path, |
1171 TargetDisposition disposition, | 1171 TargetDisposition disposition, |
1172 DownloadDangerType danger_type, | 1172 DownloadDangerType danger_type, |
1173 const base::FilePath& intermediate_path) { | 1173 const base::FilePath& intermediate_path, |
| 1174 bool hide_file_extension) { |
1174 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1175 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1175 | 1176 |
1176 // If the |target_path| is empty, then we consider this download to be | 1177 // If the |target_path| is empty, then we consider this download to be |
1177 // canceled. | 1178 // canceled. |
1178 if (target_path.empty()) { | 1179 if (target_path.empty()) { |
1179 Cancel(true); | 1180 Cancel(true); |
1180 return; | 1181 return; |
1181 } | 1182 } |
1182 | 1183 |
1183 // TODO(rdsmith,asanka): We are ignoring the possibility that the download | 1184 // TODO(rdsmith,asanka): We are ignoring the possibility that the download |
(...skipping 29 matching lines...) Expand all Loading... |
1213 return; | 1214 return; |
1214 } | 1215 } |
1215 | 1216 |
1216 // Rename to intermediate name. | 1217 // Rename to intermediate name. |
1217 // TODO(asanka): Skip this rename if AllDataSaved() is true. This avoids a | 1218 // TODO(asanka): Skip this rename if AllDataSaved() is true. This avoids a |
1218 // spurious rename when we can just rename to the final | 1219 // spurious rename when we can just rename to the final |
1219 // filename. Unnecessary renames may cause bugs like | 1220 // filename. Unnecessary renames may cause bugs like |
1220 // http://crbug.com/74187. | 1221 // http://crbug.com/74187. |
1221 DCHECK(!is_save_package_download_); | 1222 DCHECK(!is_save_package_download_); |
1222 DCHECK(download_file_.get()); | 1223 DCHECK(download_file_.get()); |
| 1224 if (hide_file_extension) { |
| 1225 download_file_.get()->SetHideFileExtension(true); |
| 1226 SetDisplayName(target_path_.BaseName().RemoveExtension()); |
| 1227 } |
1223 DownloadFile::RenameCompletionCallback callback = | 1228 DownloadFile::RenameCompletionCallback callback = |
1224 base::Bind(&DownloadItemImpl::OnDownloadRenamedToIntermediateName, | 1229 base::Bind(&DownloadItemImpl::OnDownloadRenamedToIntermediateName, |
1225 weak_ptr_factory_.GetWeakPtr()); | 1230 weak_ptr_factory_.GetWeakPtr()); |
1226 BrowserThread::PostTask( | 1231 BrowserThread::PostTask( |
1227 BrowserThread::FILE, FROM_HERE, | 1232 BrowserThread::FILE, FROM_HERE, |
1228 base::Bind(&DownloadFile::RenameAndUniquify, | 1233 base::Bind(&DownloadFile::RenameAndUniquify, |
1229 // Safe because we control download file lifetime. | 1234 // Safe because we control download file lifetime. |
1230 base::Unretained(download_file_.get()), | 1235 base::Unretained(download_file_.get()), |
1231 intermediate_path, callback)); | 1236 intermediate_path, callback)); |
1232 } | 1237 } |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 case RESUME_MODE_USER_CONTINUE: | 1802 case RESUME_MODE_USER_CONTINUE: |
1798 return "USER_CONTINUE"; | 1803 return "USER_CONTINUE"; |
1799 case RESUME_MODE_USER_RESTART: | 1804 case RESUME_MODE_USER_RESTART: |
1800 return "USER_RESTART"; | 1805 return "USER_RESTART"; |
1801 } | 1806 } |
1802 NOTREACHED() << "Unknown resume mode " << mode; | 1807 NOTREACHED() << "Unknown resume mode " << mode; |
1803 return "unknown"; | 1808 return "unknown"; |
1804 } | 1809 } |
1805 | 1810 |
1806 } // namespace content | 1811 } // namespace content |
OLD | NEW |