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 if (danger_level == Dangerous) { | 769 if (danger_level == Dangerous) { |
770 if (auto_open && info->has_user_gesture) { | |
Peter Kasting
2011/01/28 23:51:25
Two nits:
* Can condense this whole block to "ret
| |
771 return false; | |
772 } | |
770 return true; | 773 return true; |
771 } else if (danger_level == AllowOnUserGesture && !info->has_user_gesture) { | 774 } else if (danger_level == AllowOnUserGesture && !info->has_user_gesture) { |
772 return true; | 775 return true; |
773 } else if (info->is_extension_install) { | 776 } else if (info->is_extension_install) { |
774 ExtensionService* service = profile->GetExtensionService(); | 777 ExtensionService* service = profile->GetExtensionService(); |
775 if (!service || | 778 if (!service || |
776 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { | 779 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { |
777 // Extensions that are not from the gallery are considered dangerous. | 780 // Extensions that are not from the gallery are considered dangerous. |
778 return true; | 781 return true; |
779 } | 782 } |
780 } | 783 } |
781 | 784 |
782 return false; | 785 return false; |
783 } | 786 } |
784 | 787 |
785 } // namespace download_util | 788 } // namespace download_util |
OLD | NEW |