OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/safe_browsing/unverified_download_field_trial.h" | 5 #include "chrome/browser/safe_browsing/unverified_download_field_trial.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/safe_browsing/download_protection_util.h" | 15 #include "chrome/common/safe_browsing/file_type_policies.h" |
16 #include "components/variations/variations_associated_data.h" | 16 #include "components/variations/variations_associated_data.h" |
17 | 17 |
18 namespace safe_browsing { | 18 namespace safe_browsing { |
19 | 19 |
20 const char kUnverifiedDownloadFieldTrialName[] = | 20 const char kUnverifiedDownloadFieldTrialName[] = |
21 "SafeBrowsingUnverifiedDownloads"; | 21 "SafeBrowsingUnverifiedDownloads"; |
22 | 22 |
23 const char kUnverifiedDownloadFieldTrialDisableByParameter[] = | 23 const char kUnverifiedDownloadFieldTrialDisableByParameter[] = |
24 "DisableByParameter"; | 24 "DisableByParameter"; |
25 | 25 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 bool IsUnverifiedDownloadAllowedByFieldTrial(const base::FilePath& file) { | 63 bool IsUnverifiedDownloadAllowedByFieldTrial(const base::FilePath& file) { |
64 std::string group_name = | 64 std::string group_name = |
65 base::FieldTrialList::FindFullName(kUnverifiedDownloadFieldTrialName); | 65 base::FieldTrialList::FindFullName(kUnverifiedDownloadFieldTrialName); |
66 | 66 |
67 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 67 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
68 switches::kAllowUncheckedDangerousDownloads)) | 68 switches::kAllowUncheckedDangerousDownloads)) |
69 return true; | 69 return true; |
70 | 70 |
71 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 71 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
72 switches::kDisallowUncheckedDangerousDownloads) && | 72 switches::kDisallowUncheckedDangerousDownloads) && |
73 download_protection_util::IsSupportedBinaryFile(file)) | 73 FileTypePolicies::GetInstance()->IsCheckedBinaryFile(file)) |
74 return false; | 74 return false; |
75 | 75 |
76 if (base::StartsWith(group_name, | 76 if (base::StartsWith(group_name, |
77 kUnverifiedDownloadFieldTrialDisableByParameter, | 77 kUnverifiedDownloadFieldTrialDisableByParameter, |
78 base::CompareCase::SENSITIVE)) { | 78 base::CompareCase::SENSITIVE)) { |
79 std::map<std::string, std::string> parameters; | 79 std::map<std::string, std::string> parameters; |
80 variations::GetVariationParams(kUnverifiedDownloadFieldTrialName, | 80 variations::GetVariationParams(kUnverifiedDownloadFieldTrialName, |
81 ¶meters); | 81 ¶meters); |
82 | 82 |
83 if (parameters.count(kUnverifiedDownloadFieldTrialBlacklistParam) && | 83 if (parameters.count(kUnverifiedDownloadFieldTrialBlacklistParam) && |
84 MatchesExtensionList( | 84 MatchesExtensionList( |
85 file, parameters[kUnverifiedDownloadFieldTrialBlacklistParam])) | 85 file, parameters[kUnverifiedDownloadFieldTrialBlacklistParam])) |
86 return false; | 86 return false; |
87 | 87 |
88 if (parameters.count(kUnverifiedDownloadFieldTrialWhitelistParam) && | 88 if (parameters.count(kUnverifiedDownloadFieldTrialWhitelistParam) && |
89 MatchesExtensionList( | 89 MatchesExtensionList( |
90 file, parameters[kUnverifiedDownloadFieldTrialWhitelistParam])) | 90 file, parameters[kUnverifiedDownloadFieldTrialWhitelistParam])) |
91 return true; | 91 return true; |
92 | 92 |
93 if (parameters.count(kUnverifiedDownloadFieldTrialBlockSBTypesParam) && | 93 if (parameters.count(kUnverifiedDownloadFieldTrialBlockSBTypesParam) && |
94 !parameters[kUnverifiedDownloadFieldTrialBlockSBTypesParam].empty() && | 94 !parameters[kUnverifiedDownloadFieldTrialBlockSBTypesParam].empty() && |
95 download_protection_util::IsSupportedBinaryFile(file)) | 95 FileTypePolicies::GetInstance()->IsCheckedBinaryFile(file)) |
96 return false; | 96 return false; |
97 } | 97 } |
98 | 98 |
99 return true; | 99 return true; |
100 } | 100 } |
101 | 101 |
102 } // namespace safe_browsing | 102 } // namespace safe_browsing |
OLD | NEW |