| 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 <cguid.h> | 8 #include <cguid.h> |
| 9 #include <objbase.h> | 9 #include <objbase.h> |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 if (result == 0 && move_info.fAnyOperationsAborted) | 345 if (result == 0 && move_info.fAnyOperationsAborted) |
| 346 interrupt_reason = DOWNLOAD_INTERRUPT_REASON_FILE_FAILED; | 346 interrupt_reason = DOWNLOAD_INTERRUPT_REASON_FILE_FAILED; |
| 347 else if (result != 0) | 347 else if (result != 0) |
| 348 interrupt_reason = MapShFileOperationCodes(result); | 348 interrupt_reason = MapShFileOperationCodes(result); |
| 349 | 349 |
| 350 if (interrupt_reason != DOWNLOAD_INTERRUPT_REASON_NONE) | 350 if (interrupt_reason != DOWNLOAD_INTERRUPT_REASON_NONE) |
| 351 return LogInterruptReason("SHFileOperation", result, interrupt_reason); | 351 return LogInterruptReason("SHFileOperation", result, interrupt_reason); |
| 352 return interrupt_reason; | 352 return interrupt_reason; |
| 353 } | 353 } |
| 354 | 354 |
| 355 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation() { | 355 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation( |
| 356 const std::string& client_guid, |
| 357 const GURL& source_url, |
| 358 const GURL& referrer_url) { |
| 356 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 359 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 357 DCHECK(!detached_); | 360 DCHECK(!detached_); |
| 358 | 361 |
| 359 bound_net_log_.BeginEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); | 362 bound_net_log_.BeginEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); |
| 360 DownloadInterruptReason result = DOWNLOAD_INTERRUPT_REASON_NONE; | 363 DownloadInterruptReason result = DOWNLOAD_INTERRUPT_REASON_NONE; |
| 361 std::string braces_guid = "{" + client_guid_ + "}"; | 364 std::string braces_guid = "{" + client_guid + "}"; |
| 362 GUID guid = GUID_NULL; | 365 GUID guid = GUID_NULL; |
| 363 if (base::IsValidGUID(client_guid_)) { | 366 if (base::IsValidGUID(client_guid)) { |
| 364 HRESULT hr = CLSIDFromString( | 367 HRESULT hr = CLSIDFromString( |
| 365 base::UTF8ToUTF16(braces_guid).c_str(), &guid); | 368 base::UTF8ToUTF16(braces_guid).c_str(), &guid); |
| 366 if (FAILED(hr)) | 369 if (FAILED(hr)) |
| 367 guid = GUID_NULL; | 370 guid = GUID_NULL; |
| 368 } | 371 } |
| 369 | 372 |
| 370 HRESULT hr = AVScanFile(full_path_, source_url_.spec(), guid); | 373 HRESULT hr = AVScanFile(full_path_, source_url.spec(), guid); |
| 371 | 374 |
| 372 // If the download file is missing after the call, then treat this as an | 375 // If the download file is missing after the call, then treat this as an |
| 373 // interrupted download. | 376 // interrupted download. |
| 374 // | 377 // |
| 375 // If the ScanAndSaveDownloadedFile() call failed, but the downloaded file is | 378 // If the ScanAndSaveDownloadedFile() call failed, but the downloaded file is |
| 376 // still around, then don't interrupt the download. Attachment Execution | 379 // still around, then don't interrupt the download. Attachment Execution |
| 377 // Services deletes the submitted file if the downloaded file is blocked by | 380 // Services deletes the submitted file if the downloaded file is blocked by |
| 378 // policy or if it was found to be infected. | 381 // policy or if it was found to be infected. |
| 379 // | 382 // |
| 380 // If the file is still there, then the error could be due to AES not being | 383 // If the file is still there, then the error could be due to AES not being |
| 381 // available or some other error during the AES invocation. In either case, | 384 // available or some other error during the AES invocation. In either case, |
| 382 // we don't surface the error to the user. | 385 // we don't surface the error to the user. |
| 383 if (!base::PathExists(full_path_)) { | 386 if (!base::PathExists(full_path_)) { |
| 384 DCHECK(FAILED(hr)); | 387 DCHECK(FAILED(hr)); |
| 385 result = MapScanAndSaveErrorCodeToInterruptReason(hr); | 388 result = MapScanAndSaveErrorCodeToInterruptReason(hr); |
| 386 if (result == DOWNLOAD_INTERRUPT_REASON_NONE) { | 389 if (result == DOWNLOAD_INTERRUPT_REASON_NONE) { |
| 387 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT); | 390 RecordDownloadCount(FILE_MISSING_AFTER_SUCCESSFUL_SCAN_COUNT); |
| 388 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED; | 391 result = DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED; |
| 389 } | 392 } |
| 390 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result); | 393 LogInterruptReason("ScanAndSaveDownloadedFile", hr, result); |
| 391 } | 394 } |
| 392 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); | 395 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_ANNOTATED); |
| 393 return result; | 396 return result; |
| 394 } | 397 } |
| 395 | 398 |
| 396 } // namespace content | 399 } // namespace content |
| OLD | NEW |