OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download utility implementation | 5 // Download utility implementation |
6 | 6 |
7 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <shobjidl.h> | 10 #include <shobjidl.h> |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 file_value->SetInteger("percent", | 657 file_value->SetInteger("percent", |
658 static_cast<int>(download->PercentComplete())); | 658 static_cast<int>(download->PercentComplete())); |
659 file_value->SetInteger("received", | 659 file_value->SetInteger("received", |
660 static_cast<int>(download->received_bytes())); | 660 static_cast<int>(download->received_bytes())); |
661 } else if (download->IsCancelled()) { | 661 } else if (download->IsCancelled()) { |
662 file_value->SetString("state", "CANCELLED"); | 662 file_value->SetString("state", "CANCELLED"); |
663 } else if (download->IsComplete()) { | 663 } else if (download->IsComplete()) { |
664 if (download->safety_state() == DownloadItem::DANGEROUS) { | 664 if (download->safety_state() == DownloadItem::DANGEROUS) { |
665 file_value->SetString("state", "DANGEROUS"); | 665 file_value->SetString("state", "DANGEROUS"); |
666 } else { | 666 } else { |
667 file_value->SetString("state", "COMPLETE"); | 667 bool path_exists = true; |
668 #if defined(OS_WIN) | |
669 if (GetFileAttributes( | |
670 download->GetTargetFilePath().value().c_str()) == | |
671 INVALID_FILE_ATTRIBUTES) | |
672 path_exists = false; | |
673 #elif defined(OS_POSIX) | |
674 if (access(download->GetTargetFilePath().value().c_str(), F_OK) != 0) | |
675 path_exists = false; | |
676 #else | |
677 NOTIMPLEMENTED(); | |
678 #endif | |
679 file_value->SetString("state", path_exists ? "COMPLETE" : "REMOVED"); | |
Randy Smith (Not in Mondays)
2011/04/27 18:21:21
All file system accesses need to happen on the FIL
Paweł Hajdan Jr.
2011/04/29 08:43:41
Exactly. And using SetAllow... or re-implementing
| |
668 } | 680 } |
669 } | 681 } |
670 | 682 |
671 file_value->SetInteger("total", | 683 file_value->SetInteger("total", |
672 static_cast<int>(download->total_bytes())); | 684 static_cast<int>(download->total_bytes())); |
673 | 685 |
674 return file_value; | 686 return file_value; |
675 } | 687 } |
676 | 688 |
677 string16 GetProgressStatusText(DownloadItem* download) { | 689 string16 GetProgressStatusText(DownloadItem* download) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
890 // Extensions that are not from the gallery are considered dangerous. | 902 // Extensions that are not from the gallery are considered dangerous. |
891 ExtensionService* service = profile->GetExtensionService(); | 903 ExtensionService* service = profile->GetExtensionService(); |
892 if (!service || | 904 if (!service || |
893 !service->IsDownloadFromGallery(info->url(), info->referrer_url)) | 905 !service->IsDownloadFromGallery(info->url(), info->referrer_url)) |
894 return true; | 906 return true; |
895 } | 907 } |
896 return false; | 908 return false; |
897 } | 909 } |
898 | 910 |
899 } // namespace download_util | 911 } // namespace download_util |
OLD | NEW |