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

Side by Side Diff: chrome/renderer/safe_browsing/phishing_classifier_delegate.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
« no previous file with comments | « chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_delegate.h" 5 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 const IPC::Message& message) { 58 const IPC::Message& message) {
59 bool handled = true; 59 bool handled = true;
60 IPC_BEGIN_MESSAGE_MAP(PhishingClassifierFilter, message) 60 IPC_BEGIN_MESSAGE_MAP(PhishingClassifierFilter, message)
61 IPC_MESSAGE_HANDLER(SafeBrowsingMsg_SetPhishingModel, OnSetPhishingModel) 61 IPC_MESSAGE_HANDLER(SafeBrowsingMsg_SetPhishingModel, OnSetPhishingModel)
62 IPC_MESSAGE_UNHANDLED(handled = false) 62 IPC_MESSAGE_UNHANDLED(handled = false)
63 IPC_END_MESSAGE_MAP() 63 IPC_END_MESSAGE_MAP()
64 return handled; 64 return handled;
65 } 65 }
66 66
67 void PhishingClassifierFilter::OnSetPhishingModel(const std::string& model) { 67 void PhishingClassifierFilter::OnSetPhishingModel(const std::string& model) {
68 safe_browsing::Scorer* scorer = safe_browsing::Scorer::Create(model); 68 safe_browsing::Scorer* scorer = NULL;
69 if (!scorer) { 69 // An empty model string means we should disable client-side phishing
70 DLOG(ERROR) << "Unable to create a PhishingScorer - corrupt model?"; 70 // detection.
71 return; 71 if (!model.empty()) {
72 scorer = safe_browsing::Scorer::Create(model);
73 if (!scorer) {
74 DLOG(ERROR) << "Unable to create a PhishingScorer - corrupt model?";
75 return;
76 }
72 } 77 }
73 PhishingClassifierDelegates::iterator i; 78 PhishingClassifierDelegates::iterator i;
74 for (i = g_delegates.Get().begin(); i != g_delegates.Get().end(); ++i) { 79 for (i = g_delegates.Get().begin(); i != g_delegates.Get().end(); ++i) {
75 (*i)->SetPhishingScorer(scorer); 80 (*i)->SetPhishingScorer(scorer);
76 } 81 }
77 g_phishing_scorer.Get().reset(scorer); 82 g_phishing_scorer.Get().reset(scorer);
78 } 83 }
79 84
80 // static 85 // static
81 PhishingClassifierDelegate* PhishingClassifierDelegate::Create( 86 PhishingClassifierDelegate* PhishingClassifierDelegate::Create(
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 279
275 VLOG(2) << "Starting classification for " << last_finished_load_url_; 280 VLOG(2) << "Starting classification for " << last_finished_load_url_;
276 last_url_sent_to_classifier_ = last_finished_load_url_; 281 last_url_sent_to_classifier_ = last_finished_load_url_;
277 is_classifying_ = true; 282 is_classifying_ = true;
278 classifier_->BeginClassification( 283 classifier_->BeginClassification(
279 &classifier_page_text_, 284 &classifier_page_text_,
280 NewCallback(this, &PhishingClassifierDelegate::ClassificationDone)); 285 NewCallback(this, &PhishingClassifierDelegate::ClassificationDone));
281 } 286 }
282 287
283 } // namespace safe_browsing 288 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698