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

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

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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
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/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 content::RenderView* render_view, PhishingClassifier* classifier) { 89 content::RenderView* render_view, PhishingClassifier* classifier) {
90 // Private constructor and public static Create() method to facilitate 90 // Private constructor and public static Create() method to facilitate
91 // stubbing out this class for binary-size reduction purposes. 91 // stubbing out this class for binary-size reduction purposes.
92 return new PhishingClassifierDelegate(render_view, classifier); 92 return new PhishingClassifierDelegate(render_view, classifier);
93 } 93 }
94 94
95 PhishingClassifierDelegate::PhishingClassifierDelegate( 95 PhishingClassifierDelegate::PhishingClassifierDelegate(
96 content::RenderView* render_view, 96 content::RenderView* render_view,
97 PhishingClassifier* classifier) 97 PhishingClassifier* classifier)
98 : content::RenderViewObserver(render_view), 98 : content::RenderViewObserver(render_view),
99 last_main_frame_transition_(content::PAGE_TRANSITION_LINK), 99 last_main_frame_transition_(ui::PAGE_TRANSITION_LINK),
100 have_page_text_(false), 100 have_page_text_(false),
101 is_classifying_(false) { 101 is_classifying_(false) {
102 g_delegates.Get().insert(this); 102 g_delegates.Get().insert(this);
103 if (!classifier) { 103 if (!classifier) {
104 classifier = new PhishingClassifier(render_view, 104 classifier = new PhishingClassifier(render_view,
105 new FeatureExtractorClock()); 105 new FeatureExtractorClock());
106 } 106 }
107 107
108 classifier_.reset(classifier); 108 classifier_.reset(classifier);
109 109
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // 233 //
234 // Note that if we determine that this particular navigation should not be 234 // Note that if we determine that this particular navigation should not be
235 // classified at all (as opposed to deferring it until we get an IPC or the 235 // classified at all (as opposed to deferring it until we get an IPC or the
236 // load completes), we discard the page text since it won't be needed. 236 // load completes), we discard the page text since it won't be needed.
237 if (!classifier_->is_ready()) { 237 if (!classifier_->is_ready()) {
238 VLOG(2) << "Not starting classification, no Scorer created."; 238 VLOG(2) << "Not starting classification, no Scorer created.";
239 // Keep classifier_page_text_, in case a Scorer is set later. 239 // Keep classifier_page_text_, in case a Scorer is set later.
240 return; 240 return;
241 } 241 }
242 242
243 if (last_main_frame_transition_ & content::PAGE_TRANSITION_FORWARD_BACK) { 243 if (last_main_frame_transition_ & ui::PAGE_TRANSITION_FORWARD_BACK) {
244 // Skip loads from session history navigation. However, update the 244 // Skip loads from session history navigation. However, update the
245 // last URL sent to the classifier, so that we'll properly detect 245 // last URL sent to the classifier, so that we'll properly detect
246 // in-page navigations. 246 // in-page navigations.
247 VLOG(2) << "Not starting classification for back/forward navigation"; 247 VLOG(2) << "Not starting classification for back/forward navigation";
248 last_url_sent_to_classifier_ = last_finished_load_url_; 248 last_url_sent_to_classifier_ = last_finished_load_url_;
249 classifier_page_text_.clear(); // we won't need this. 249 classifier_page_text_.clear(); // we won't need this.
250 have_page_text_ = false; 250 have_page_text_ = false;
251 return; 251 return;
252 } 252 }
253 253
(...skipping 29 matching lines...) Expand all
283 VLOG(2) << "Starting classification for " << last_finished_load_url_; 283 VLOG(2) << "Starting classification for " << last_finished_load_url_;
284 last_url_sent_to_classifier_ = last_finished_load_url_; 284 last_url_sent_to_classifier_ = last_finished_load_url_;
285 is_classifying_ = true; 285 is_classifying_ = true;
286 classifier_->BeginClassification( 286 classifier_->BeginClassification(
287 &classifier_page_text_, 287 &classifier_page_text_,
288 base::Bind(&PhishingClassifierDelegate::ClassificationDone, 288 base::Bind(&PhishingClassifierDelegate::ClassificationDone,
289 base::Unretained(this))); 289 base::Unretained(this)));
290 } 290 }
291 291
292 } // namespace safe_browsing 292 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/safe_browsing/phishing_classifier_delegate.h ('k') | chrome/test/base/browser_with_test_window_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698