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/safe_browsing/browser_feature_extractor.h" | 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 DVLOG(2) << "Added url info for bad ip: " << ip; | 101 DVLOG(2) << "Added url info for bad ip: " << ip; |
102 } | 102 } |
103 | 103 |
104 static void AddNavigationFeatures( | 104 static void AddNavigationFeatures( |
105 const std::string& feature_prefix, | 105 const std::string& feature_prefix, |
106 const NavigationController& controller, | 106 const NavigationController& controller, |
107 int index, | 107 int index, |
108 const std::vector<GURL>& redirect_chain, | 108 const std::vector<GURL>& redirect_chain, |
109 ClientPhishingRequest* request) { | 109 ClientPhishingRequest* request) { |
110 NavigationEntry* entry = controller.GetEntryAtIndex(index); | 110 NavigationEntry* entry = controller.GetEntryAtIndex(index); |
111 bool is_secure_referrer = entry->GetReferrer().url.SchemeIsSecure(); | 111 bool is_secure_referrer = entry->GetReferrer().url.SchemeIsCryptographic(); |
112 if (!is_secure_referrer) { | 112 if (!is_secure_referrer) { |
113 AddFeature(base::StringPrintf("%s%s=%s", | 113 AddFeature(base::StringPrintf("%s%s=%s", |
114 feature_prefix.c_str(), | 114 feature_prefix.c_str(), |
115 features::kReferrer, | 115 features::kReferrer, |
116 entry->GetReferrer().url.spec().c_str()), | 116 entry->GetReferrer().url.spec().c_str()), |
117 1.0, | 117 1.0, |
118 request); | 118 request); |
119 } | 119 } |
120 AddFeature(feature_prefix + features::kHasSSLReferrer, | 120 AddFeature(feature_prefix + features::kHasSSLReferrer, |
121 is_secure_referrer ? 1.0 : 0.0, | 121 is_secure_referrer ? 1.0 : 0.0, |
(...skipping 21 matching lines...) Expand all Loading... |
143 DLOG(WARNING) << "Expected:" << entry->GetURL() | 143 DLOG(WARNING) << "Expected:" << entry->GetURL() |
144 << " Actual:" << redirect_chain.back(); | 144 << " Actual:" << redirect_chain.back(); |
145 AddFeature(feature_prefix + features::kRedirectUrlMismatch, | 145 AddFeature(feature_prefix + features::kRedirectUrlMismatch, |
146 1.0, | 146 1.0, |
147 request); | 147 request); |
148 return; | 148 return; |
149 } | 149 } |
150 // We skip the last element since it should just be the current url. | 150 // We skip the last element since it should just be the current url. |
151 for (size_t i = 0; i < redirect_chain.size() - 1; i++) { | 151 for (size_t i = 0; i < redirect_chain.size() - 1; i++) { |
152 std::string printable_redirect = redirect_chain[i].spec(); | 152 std::string printable_redirect = redirect_chain[i].spec(); |
153 if (redirect_chain[i].SchemeIsSecure()) { | 153 if (redirect_chain[i].SchemeIsCryptographic()) { |
154 printable_redirect = features::kSecureRedirectValue; | 154 printable_redirect = features::kSecureRedirectValue; |
155 } | 155 } |
156 AddFeature(base::StringPrintf("%s%s[%" PRIuS "]=%s", | 156 AddFeature(base::StringPrintf("%s%s[%" PRIuS "]=%s", |
157 feature_prefix.c_str(), | 157 feature_prefix.c_str(), |
158 features::kRedirect, | 158 features::kRedirect, |
159 i, | 159 i, |
160 printable_redirect.c_str()), | 160 printable_redirect.c_str()), |
161 1.0, | 161 1.0, |
162 request); | 162 request); |
163 } | 163 } |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 // Limit the number of matched bad IPs in one request to control | 482 // Limit the number of matched bad IPs in one request to control |
483 // the request's size | 483 // the request's size |
484 if (matched_bad_ips >= kMaxMalwareIPPerRequest) { | 484 if (matched_bad_ips >= kMaxMalwareIPPerRequest) { |
485 break; | 485 break; |
486 } | 486 } |
487 } | 487 } |
488 callback.Run(true, request.Pass()); | 488 callback.Run(true, request.Pass()); |
489 } | 489 } |
490 | 490 |
491 } // namespace safe_browsing | 491 } // namespace safe_browsing |
OLD | NEW |