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

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

Issue 8310014: Only send the client-side phishing model to a renderer if its profile has SafeBrowsing enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a comment as Noe suggested Created 9 years, 2 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) 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/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 PhishingClassifier::~PhishingClassifier() { 47 PhishingClassifier::~PhishingClassifier() {
48 // The RenderView should have called CancelPendingClassification() before 48 // The RenderView should have called CancelPendingClassification() before
49 // we are destroyed. 49 // we are destroyed.
50 CheckNoPendingClassification(); 50 CheckNoPendingClassification();
51 } 51 }
52 52
53 void PhishingClassifier::set_phishing_scorer(const Scorer* scorer) { 53 void PhishingClassifier::set_phishing_scorer(const Scorer* scorer) {
54 CheckNoPendingClassification(); 54 CheckNoPendingClassification();
55 scorer_ = scorer; 55 scorer_ = scorer;
56 url_extractor_.reset(new PhishingUrlFeatureExtractor); 56 if (scorer_) {
57 dom_extractor_.reset( 57 url_extractor_.reset(new PhishingUrlFeatureExtractor);
58 new PhishingDOMFeatureExtractor(render_view_, clock_.get())); 58 dom_extractor_.reset(
59 term_extractor_.reset(new PhishingTermFeatureExtractor( 59 new PhishingDOMFeatureExtractor(render_view_, clock_.get()));
60 &scorer_->page_terms(), 60 term_extractor_.reset(new PhishingTermFeatureExtractor(
61 &scorer_->page_words(), 61 &scorer_->page_terms(),
62 scorer_->max_words_per_term(), 62 &scorer_->page_words(),
63 scorer_->murmurhash3_seed(), 63 scorer_->max_words_per_term(),
64 clock_.get())); 64 scorer_->murmurhash3_seed(),
65 clock_.get()));
66 } else {
67 // We're disabling client-side phishing detection, so tear down all
68 // of the relevant objects.
69 url_extractor_.reset();
70 dom_extractor_.reset();
71 term_extractor_.reset();
72 }
65 } 73 }
66 74
67 bool PhishingClassifier::is_ready() const { 75 bool PhishingClassifier::is_ready() const {
68 return scorer_ != NULL; 76 return scorer_ != NULL;
69 } 77 }
70 78
71 void PhishingClassifier::BeginClassification(const string16* page_text, 79 void PhishingClassifier::BeginClassification(const string16* page_text,
72 DoneCallback* done_callback) { 80 DoneCallback* done_callback) {
73 DCHECK(is_ready()); 81 DCHECK(is_ready());
74 82
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 RunCallback(verdict); 228 RunCallback(verdict);
221 } 229 }
222 230
223 void PhishingClassifier::Clear() { 231 void PhishingClassifier::Clear() {
224 page_text_ = NULL; 232 page_text_ = NULL;
225 done_callback_.reset(NULL); 233 done_callback_.reset(NULL);
226 features_.reset(NULL); 234 features_.reset(NULL);
227 } 235 }
228 236
229 } // namespace safe_browsing 237 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/common/safe_browsing/safebrowsing_messages.h ('k') | chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698