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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 FilePath GetCrDownloadPath(const FilePath& suggested_path) { | 755 FilePath GetCrDownloadPath(const FilePath& suggested_path) { |
756 FilePath::StringType file_name; | 756 FilePath::StringType file_name; |
757 base::SStringPrintf( | 757 base::SStringPrintf( |
758 &file_name, | 758 &file_name, |
759 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), | 759 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), |
760 suggested_path.value().c_str()); | 760 suggested_path.value().c_str()); |
761 return FilePath(file_name); | 761 return FilePath(file_name); |
762 } | 762 } |
763 | 763 |
764 // TODO(erikkay,phajdan.jr): This is apparently not being exercised in tests. | 764 // TODO(erikkay,phajdan.jr): This is apparently not being exercised in tests. |
765 bool IsDangerous(DownloadCreateInfo* info, Profile* profile) { | 765 bool IsDangerous(DownloadCreateInfo* info, Profile* profile, bool auto_open) { |
766 DownloadDangerLevel danger_level = GetFileDangerLevel( | 766 DownloadDangerLevel danger_level = GetFileDangerLevel( |
767 info->suggested_path.BaseName()); | 767 info->suggested_path.BaseName()); |
768 | 768 |
| 769 bool ret = false; |
769 if (danger_level == Dangerous) { | 770 if (danger_level == Dangerous) { |
770 return true; | 771 ret = !(auto_open && info->has_user_gesture); |
771 } else if (danger_level == AllowOnUserGesture && !info->has_user_gesture) { | 772 } else if (danger_level == AllowOnUserGesture && !info->has_user_gesture) { |
772 return true; | 773 ret = true; |
773 } else if (info->is_extension_install) { | 774 } else if (info->is_extension_install) { |
774 ExtensionService* service = profile->GetExtensionService(); | 775 ExtensionService* service = profile->GetExtensionService(); |
775 if (!service || | 776 if (!service || |
776 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { | 777 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { |
777 // Extensions that are not from the gallery are considered dangerous. | 778 // Extensions that are not from the gallery are considered dangerous. |
778 return true; | 779 ret = true; |
779 } | 780 } |
780 } | 781 } |
781 | 782 |
782 return false; | 783 return ret; |
783 } | 784 } |
784 | 785 |
785 } // namespace download_util | 786 } // namespace download_util |
OLD | NEW |