| 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 "content/browser/download/base_file.h" | 5 #include "content/browser/download/base_file.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED; | 283 return DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED; |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 } // namespace | 287 } // namespace |
| 288 | 288 |
| 289 // Renames a file using the SHFileOperation API to ensure that the target file | 289 // Renames a file using the SHFileOperation API to ensure that the target file |
| 290 // gets the correct default security descriptor in the new path. | 290 // gets the correct default security descriptor in the new path. |
| 291 // Returns a network error, or net::OK for success. | 291 // Returns a network error, or net::OK for success. |
| 292 DownloadInterruptReason BaseFile::MoveFileAndAdjustPermissions( | 292 DownloadInterruptReason BaseFile::MoveFileAndAdjustPermissions( |
| 293 const FilePath& new_path) { | 293 const base::FilePath& new_path) { |
| 294 base::ThreadRestrictions::AssertIOAllowed(); | 294 base::ThreadRestrictions::AssertIOAllowed(); |
| 295 | 295 |
| 296 // The parameters to SHFileOperation must be terminated with 2 NULL chars. | 296 // The parameters to SHFileOperation must be terminated with 2 NULL chars. |
| 297 FilePath::StringType source = full_path_.value(); | 297 base::FilePath::StringType source = full_path_.value(); |
| 298 FilePath::StringType target = new_path.value(); | 298 base::FilePath::StringType target = new_path.value(); |
| 299 | 299 |
| 300 source.append(1, L'\0'); | 300 source.append(1, L'\0'); |
| 301 target.append(1, L'\0'); | 301 target.append(1, L'\0'); |
| 302 | 302 |
| 303 SHFILEOPSTRUCT move_info = {0}; | 303 SHFILEOPSTRUCT move_info = {0}; |
| 304 move_info.wFunc = FO_MOVE; | 304 move_info.wFunc = FO_MOVE; |
| 305 move_info.pFrom = source.c_str(); | 305 move_info.pFrom = source.c_str(); |
| 306 move_info.pTo = target.c_str(); | 306 move_info.pTo = target.c_str(); |
| 307 move_info.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | | 307 move_info.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | |
| 308 FOF_NOCONFIRMMKDIR | FOF_NOCOPYSECURITYATTRIBS; | 308 FOF_NOCONFIRMMKDIR | FOF_NOCOPYSECURITYATTRIBS; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT); | 346 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT); |
| 347 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED; | 347 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED; |
| 348 } | 348 } |
| 349 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result); | 349 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result); |
| 350 } | 350 } |
| 351 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); | 351 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); |
| 352 return result; | 352 return result; |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace content | 355 } // namespace content |
| OLD | NEW |