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

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, 10 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
« no previous file with comments | « chrome/browser/download/download_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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
OLDNEW
« no previous file with comments | « chrome/browser/download/download_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698