| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/file_select_helper.h" | 5 #include "chrome/browser/file_select_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool IsValidProfile(Profile* profile) { | 84 bool IsValidProfile(Profile* profile) { |
| 85 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 85 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 86 return g_browser_process->profile_manager()->IsValidProfile(profile); | 86 return g_browser_process->profile_manager()->IsValidProfile(profile); |
| 87 } | 87 } |
| 88 | 88 |
| 89 #if defined(FULL_SAFE_BROWSING) | 89 #if defined(FULL_SAFE_BROWSING) |
| 90 | 90 |
| 91 bool IsDownloadAllowedBySafeBrowsing( | 91 bool IsDownloadAllowedBySafeBrowsing( |
| 92 safe_browsing::DownloadProtectionService::DownloadCheckResult result) { | 92 safe_browsing::DownloadProtectionService::DownloadCheckResult result, |
| 93 const std::string& token_unused) { |
| 93 using Result = safe_browsing::DownloadProtectionService::DownloadCheckResult; | 94 using Result = safe_browsing::DownloadProtectionService::DownloadCheckResult; |
| 94 switch (result) { | 95 switch (result) { |
| 95 // Only allow downloads that are marked as SAFE or UNKNOWN by SafeBrowsing. | 96 // Only allow downloads that are marked as SAFE or UNKNOWN by SafeBrowsing. |
| 96 // All other types are going to be blocked. UNKNOWN could be the result of a | 97 // All other types are going to be blocked. UNKNOWN could be the result of a |
| 97 // failed safe browsing ping. | 98 // failed safe browsing ping. |
| 98 case Result::UNKNOWN: | 99 case Result::UNKNOWN: |
| 99 case Result::SAFE: | 100 case Result::SAFE: |
| 100 return true; | 101 return true; |
| 101 | 102 |
| 102 case Result::DANGEROUS: | 103 case Result::DANGEROUS: |
| 103 case Result::UNCOMMON: | 104 case Result::UNCOMMON: |
| 104 case Result::DANGEROUS_HOST: | 105 case Result::DANGEROUS_HOST: |
| 105 case Result::POTENTIALLY_UNWANTED: | 106 case Result::POTENTIALLY_UNWANTED: |
| 106 return false; | 107 return false; |
| 107 } | 108 } |
| 108 NOTREACHED(); | 109 NOTREACHED(); |
| 109 return false; | 110 return false; |
| 110 } | 111 } |
| 111 | 112 |
| 112 void InterpretSafeBrowsingVerdict( | 113 void InterpretSafeBrowsingVerdict( |
| 113 const base::Callback<void(bool)>& recipient, | 114 const base::Callback<void(bool)>& recipient, |
| 114 safe_browsing::DownloadProtectionService::DownloadCheckResult result) { | 115 safe_browsing::DownloadProtectionService::DownloadCheckResult result, |
| 115 recipient.Run(IsDownloadAllowedBySafeBrowsing(result)); | 116 const std::string& token) { |
| 117 recipient.Run(IsDownloadAllowedBySafeBrowsing(result, token)); |
| 116 } | 118 } |
| 117 | 119 |
| 118 #endif | 120 #endif |
| 119 | 121 |
| 120 } // namespace | 122 } // namespace |
| 121 | 123 |
| 122 struct FileSelectHelper::ActiveDirectoryEnumeration { | 124 struct FileSelectHelper::ActiveDirectoryEnumeration { |
| 123 ActiveDirectoryEnumeration() : rvh_(NULL) {} | 125 ActiveDirectoryEnumeration() : rvh_(NULL) {} |
| 124 | 126 |
| 125 std::unique_ptr<DirectoryListerDispatchDelegate> delegate_; | 127 std::unique_ptr<DirectoryListerDispatchDelegate> delegate_; |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 | 687 |
| 686 // static | 688 // static |
| 687 base::FilePath FileSelectHelper::GetSanitizedFileName( | 689 base::FilePath FileSelectHelper::GetSanitizedFileName( |
| 688 const base::FilePath& suggested_filename) { | 690 const base::FilePath& suggested_filename) { |
| 689 if (suggested_filename.empty()) | 691 if (suggested_filename.empty()) |
| 690 return base::FilePath(); | 692 return base::FilePath(); |
| 691 return net::GenerateFileName( | 693 return net::GenerateFileName( |
| 692 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), | 694 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), |
| 693 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); | 695 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); |
| 694 } | 696 } |
| OLD | NEW |