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_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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 content::RenderView* render_view, PhishingClassifier* classifier) { | 82 content::RenderView* render_view, PhishingClassifier* classifier) { |
83 // Private constructor and public static Create() method to facilitate | 83 // Private constructor and public static Create() method to facilitate |
84 // stubbing out this class for binary-size reduction purposes. | 84 // stubbing out this class for binary-size reduction purposes. |
85 return new PhishingClassifierDelegate(render_view, classifier); | 85 return new PhishingClassifierDelegate(render_view, classifier); |
86 } | 86 } |
87 | 87 |
88 PhishingClassifierDelegate::PhishingClassifierDelegate( | 88 PhishingClassifierDelegate::PhishingClassifierDelegate( |
89 content::RenderView* render_view, | 89 content::RenderView* render_view, |
90 PhishingClassifier* classifier) | 90 PhishingClassifier* classifier) |
91 : content::RenderViewObserver(render_view), | 91 : content::RenderViewObserver(render_view), |
92 last_main_frame_transition_(PageTransition::LINK), | 92 last_main_frame_transition_(content::PAGE_TRANSITION_LINK), |
93 have_page_text_(false), | 93 have_page_text_(false), |
94 is_classifying_(false) { | 94 is_classifying_(false) { |
95 g_delegates.Get().insert(this); | 95 g_delegates.Get().insert(this); |
96 if (!classifier) { | 96 if (!classifier) { |
97 classifier = new PhishingClassifier(render_view, | 97 classifier = new PhishingClassifier(render_view, |
98 new FeatureExtractorClock()); | 98 new FeatureExtractorClock()); |
99 } | 99 } |
100 | 100 |
101 classifier_.reset(classifier); | 101 classifier_.reset(classifier); |
102 | 102 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // | 225 // |
226 // Note that if we determine that this particular navigation should not be | 226 // Note that if we determine that this particular navigation should not be |
227 // classified at all (as opposed to deferring it until we get an IPC or the | 227 // classified at all (as opposed to deferring it until we get an IPC or the |
228 // load completes), we discard the page text since it won't be needed. | 228 // load completes), we discard the page text since it won't be needed. |
229 if (!classifier_->is_ready()) { | 229 if (!classifier_->is_ready()) { |
230 VLOG(2) << "Not starting classification, no Scorer created."; | 230 VLOG(2) << "Not starting classification, no Scorer created."; |
231 // Keep classifier_page_text_, in case a Scorer is set later. | 231 // Keep classifier_page_text_, in case a Scorer is set later. |
232 return; | 232 return; |
233 } | 233 } |
234 | 234 |
235 if (last_main_frame_transition_ & PageTransition::FORWARD_BACK) { | 235 if (last_main_frame_transition_ & content::PAGE_TRANSITION_FORWARD_BACK) { |
236 // Skip loads from session history navigation. However, update the | 236 // Skip loads from session history navigation. However, update the |
237 // last URL sent to the classifier, so that we'll properly detect | 237 // last URL sent to the classifier, so that we'll properly detect |
238 // in-page navigations. | 238 // in-page navigations. |
239 VLOG(2) << "Not starting classification for back/forward navigation"; | 239 VLOG(2) << "Not starting classification for back/forward navigation"; |
240 last_url_sent_to_classifier_ = last_finished_load_url_; | 240 last_url_sent_to_classifier_ = last_finished_load_url_; |
241 classifier_page_text_.clear(); // we won't need this. | 241 classifier_page_text_.clear(); // we won't need this. |
242 have_page_text_ = false; | 242 have_page_text_ = false; |
243 return; | 243 return; |
244 } | 244 } |
245 | 245 |
(...skipping 28 matching lines...) Expand all Loading... |
274 | 274 |
275 VLOG(2) << "Starting classification for " << last_finished_load_url_; | 275 VLOG(2) << "Starting classification for " << last_finished_load_url_; |
276 last_url_sent_to_classifier_ = last_finished_load_url_; | 276 last_url_sent_to_classifier_ = last_finished_load_url_; |
277 is_classifying_ = true; | 277 is_classifying_ = true; |
278 classifier_->BeginClassification( | 278 classifier_->BeginClassification( |
279 &classifier_page_text_, | 279 &classifier_page_text_, |
280 NewCallback(this, &PhishingClassifierDelegate::ClassificationDone)); | 280 NewCallback(this, &PhishingClassifierDelegate::ClassificationDone)); |
281 } | 281 } |
282 | 282 |
283 } // namespace safe_browsing | 283 } // namespace safe_browsing |
OLD | NEW |