OLD | NEW |
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 #include "chrome/renderer/safe_browsing/phishing_classifier.h" | 5 #include "chrome/renderer/safe_browsing/phishing_classifier.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 // Hash all of the features so that they match the model, then compute | 187 // Hash all of the features so that they match the model, then compute |
188 // the score. | 188 // the score. |
189 FeatureMap hashed_features; | 189 FeatureMap hashed_features; |
190 ClientPhishingRequest verdict; | 190 ClientPhishingRequest verdict; |
191 verdict.set_model_version(scorer_->model_version()); | 191 verdict.set_model_version(scorer_->model_version()); |
192 verdict.set_url(main_frame->document().url().spec()); | 192 verdict.set_url(main_frame->document().url().spec()); |
193 for (base::hash_map<std::string, double>::const_iterator it = | 193 for (base::hash_map<std::string, double>::const_iterator it = |
194 features_->features().begin(); | 194 features_->features().begin(); |
195 it != features_->features().end(); ++it) { | 195 it != features_->features().end(); ++it) { |
196 VLOG(2) << "Feature: " << it->first << " = " << it->second; | 196 DVLOG(2) << "Feature: " << it->first << " = " << it->second; |
197 bool result = hashed_features.AddRealFeature( | 197 bool result = hashed_features.AddRealFeature( |
198 crypto::SHA256HashString(it->first), it->second); | 198 crypto::SHA256HashString(it->first), it->second); |
199 DCHECK(result); | 199 DCHECK(result); |
200 ClientPhishingRequest::Feature* feature = verdict.add_feature_map(); | 200 ClientPhishingRequest::Feature* feature = verdict.add_feature_map(); |
201 feature->set_name(it->first); | 201 feature->set_name(it->first); |
202 feature->set_value(it->second); | 202 feature->set_value(it->second); |
203 } | 203 } |
204 for (std::set<uint32>::const_iterator it = shingle_hashes_->begin(); | 204 for (std::set<uint32>::const_iterator it = shingle_hashes_->begin(); |
205 it != shingle_hashes_->end(); ++it) { | 205 it != shingle_hashes_->end(); ++it) { |
206 verdict.add_shingle_hashes(*it); | 206 verdict.add_shingle_hashes(*it); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 241 } |
242 | 242 |
243 void PhishingClassifier::Clear() { | 243 void PhishingClassifier::Clear() { |
244 page_text_ = NULL; | 244 page_text_ = NULL; |
245 done_callback_.Reset(); | 245 done_callback_.Reset(); |
246 features_.reset(NULL); | 246 features_.reset(NULL); |
247 shingle_hashes_.reset(NULL); | 247 shingle_hashes_.reset(NULL); |
248 } | 248 } |
249 | 249 |
250 } // namespace safe_browsing | 250 } // namespace safe_browsing |
OLD | NEW |