Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/download/download_util.cc

Issue 6324020: Tweak the auto-open algorithm to permit JNLP to auto-open iff the user has... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« chrome/browser/download/download_util.h ('K') | « chrome/browser/download/download_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698