| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 FilePath::StringType file_name; | 731 FilePath::StringType file_name; |
| 732 base::SStringPrintf( | 732 base::SStringPrintf( |
| 733 &file_name, | 733 &file_name, |
| 734 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), | 734 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), |
| 735 suggested_path.value().c_str()); | 735 suggested_path.value().c_str()); |
| 736 return FilePath(file_name); | 736 return FilePath(file_name); |
| 737 } | 737 } |
| 738 | 738 |
| 739 // TODO(erikkay,phajdan.jr): This is apparently not being exercised in tests. | 739 // TODO(erikkay,phajdan.jr): This is apparently not being exercised in tests. |
| 740 bool IsDangerous(DownloadCreateInfo* info, Profile* profile) { | 740 bool IsDangerous(DownloadCreateInfo* info, Profile* profile) { |
| 741 // Downloads can be marked as dangerous for two reasons: | 741 DownloadDangerLevel danger_level = GetFileDangerLevel( |
| 742 // a) They have a dangerous-looking filename | 742 info->suggested_path.BaseName()); |
| 743 // b) They are an extension that is not from the gallery | 743 |
| 744 if (IsExecutableFile(info->suggested_path.BaseName())) { | 744 if (danger_level == Dangerous) { |
| 745 return true; |
| 746 } else if (danger_level == AllowOnUserGesture && !info->has_user_gesture) { |
| 745 return true; | 747 return true; |
| 746 } else if (info->is_extension_install) { | 748 } else if (info->is_extension_install) { |
| 747 ExtensionsService* service = profile->GetExtensionsService(); | 749 ExtensionsService* service = profile->GetExtensionsService(); |
| 748 if (!service || | 750 if (!service || |
| 749 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { | 751 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { |
| 752 // Extensions that are not from the gallery are considered dangerous. |
| 750 return true; | 753 return true; |
| 751 } | 754 } |
| 752 } | 755 } |
| 756 |
| 753 return false; | 757 return false; |
| 754 } | 758 } |
| 755 | 759 |
| 756 } // namespace download_util | 760 } // namespace download_util |
| 757 | 761 |
| OLD | NEW |