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

Side by Side Diff: chrome/renderer/safe_browsing/phishing_classifier.cc

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixes comments by eroman Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 2010 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/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/sha2.h"
13 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "crypto/sha2.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" 15 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h"
16 #include "chrome/renderer/safe_browsing/features.h" 16 #include "chrome/renderer/safe_browsing/features.h"
17 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" 17 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h"
18 #include "chrome/renderer/safe_browsing/phishing_term_feature_extractor.h" 18 #include "chrome/renderer/safe_browsing/phishing_term_feature_extractor.h"
19 #include "chrome/renderer/safe_browsing/phishing_url_feature_extractor.h" 19 #include "chrome/renderer/safe_browsing/phishing_url_feature_extractor.h"
20 #include "chrome/renderer/safe_browsing/scorer.h" 20 #include "chrome/renderer/safe_browsing/scorer.h"
21 #include "content/renderer/render_view.h" 21 #include "content/renderer/render_view.h"
22 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void PhishingClassifier::TermExtractionFinished(bool success) { 153 void PhishingClassifier::TermExtractionFinished(bool success) {
154 if (success) { 154 if (success) {
155 // Hash all of the features so that they match the model, then compute 155 // Hash all of the features so that they match the model, then compute
156 // the score. 156 // the score.
157 FeatureMap hashed_features; 157 FeatureMap hashed_features;
158 for (base::hash_map<std::string, double>::const_iterator it = 158 for (base::hash_map<std::string, double>::const_iterator it =
159 features_->features().begin(); 159 features_->features().begin();
160 it != features_->features().end(); ++it) { 160 it != features_->features().end(); ++it) {
161 VLOG(2) << "Feature: " << it->first << " = " << it->second; 161 VLOG(2) << "Feature: " << it->first << " = " << it->second;
162 bool result = hashed_features.AddRealFeature( 162 bool result = hashed_features.AddRealFeature(
163 base::SHA256HashString(it->first), it->second); 163 crypto::SHA256HashString(it->first), it->second);
164 DCHECK(result); 164 DCHECK(result);
165 } 165 }
166 166
167 double score = scorer_->ComputeScore(hashed_features); 167 double score = scorer_->ComputeScore(hashed_features);
168 RunCallback(score >= kPhishyThreshold, score); 168 RunCallback(score >= kPhishyThreshold, score);
169 } else { 169 } else {
170 RunFailureCallback(); 170 RunFailureCallback();
171 } 171 }
172 } 172 }
173 173
(...skipping 15 matching lines...) Expand all
189 RunCallback(false /* not phishy */, kInvalidScore); 189 RunCallback(false /* not phishy */, kInvalidScore);
190 } 190 }
191 191
192 void PhishingClassifier::Clear() { 192 void PhishingClassifier::Clear() {
193 page_text_ = NULL; 193 page_text_ = NULL;
194 done_callback_.reset(NULL); 194 done_callback_.reset(NULL);
195 features_.reset(NULL); 195 features_.reset(NULL);
196 } 196 }
197 197
198 } // namespace safe_browsing 198 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/render_process_impl.cc ('k') | chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698