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

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

Issue 63273002: Rename WebKit namespace to blink (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // asynchronously, rather than directly from this method. To ensure that 96 // asynchronously, rather than directly from this method. To ensure that
97 // this is the case, post a task to begin feature extraction on the next 97 // this is the case, post a task to begin feature extraction on the next
98 // iteration of the message loop. 98 // iteration of the message loop.
99 base::MessageLoop::current()->PostTask( 99 base::MessageLoop::current()->PostTask(
100 FROM_HERE, 100 FROM_HERE,
101 base::Bind(&PhishingClassifier::BeginFeatureExtraction, 101 base::Bind(&PhishingClassifier::BeginFeatureExtraction,
102 weak_factory_.GetWeakPtr())); 102 weak_factory_.GetWeakPtr()));
103 } 103 }
104 104
105 void PhishingClassifier::BeginFeatureExtraction() { 105 void PhishingClassifier::BeginFeatureExtraction() {
106 WebKit::WebView* web_view = render_view_->GetWebView(); 106 blink::WebView* web_view = render_view_->GetWebView();
107 if (!web_view) { 107 if (!web_view) {
108 RunFailureCallback(); 108 RunFailureCallback();
109 return; 109 return;
110 } 110 }
111 111
112 WebKit::WebFrame* frame = web_view->mainFrame(); 112 blink::WebFrame* frame = web_view->mainFrame();
113 if (!frame) { 113 if (!frame) {
114 RunFailureCallback(); 114 RunFailureCallback();
115 return; 115 return;
116 } 116 }
117 117
118 // Check whether the URL is one that we should classify. 118 // Check whether the URL is one that we should classify.
119 // Currently, we only classify http: URLs that are GET requests. 119 // Currently, we only classify http: URLs that are GET requests.
120 GURL url(frame->document().url()); 120 GURL url(frame->document().url());
121 if (!url.SchemeIs(content::kHttpScheme)) { 121 if (!url.SchemeIs(content::kHttpScheme)) {
122 RunFailureCallback(); 122 RunFailureCallback();
123 return; 123 return;
124 } 124 }
125 125
126 WebKit::WebDataSource* ds = frame->dataSource(); 126 blink::WebDataSource* ds = frame->dataSource();
127 if (!ds || !EqualsASCII(ds->request().httpMethod(), "GET")) { 127 if (!ds || !EqualsASCII(ds->request().httpMethod(), "GET")) {
128 RunFailureCallback(); 128 RunFailureCallback();
129 return; 129 return;
130 } 130 }
131 131
132 features_.reset(new FeatureMap); 132 features_.reset(new FeatureMap);
133 if (!url_extractor_->ExtractFeatures(url, features_.get())) { 133 if (!url_extractor_->ExtractFeatures(url, features_.get())) {
134 RunFailureCallback(); 134 RunFailureCallback();
135 return; 135 return;
136 } 136 }
(...skipping 25 matching lines...) Expand all
162 features_.get(), 162 features_.get(),
163 base::Bind(&PhishingClassifier::TermExtractionFinished, 163 base::Bind(&PhishingClassifier::TermExtractionFinished,
164 base::Unretained(this))); 164 base::Unretained(this)));
165 } else { 165 } else {
166 RunFailureCallback(); 166 RunFailureCallback();
167 } 167 }
168 } 168 }
169 169
170 void PhishingClassifier::TermExtractionFinished(bool success) { 170 void PhishingClassifier::TermExtractionFinished(bool success) {
171 if (success) { 171 if (success) {
172 WebKit::WebView* web_view = render_view_->GetWebView(); 172 blink::WebView* web_view = render_view_->GetWebView();
173 if (!web_view) { 173 if (!web_view) {
174 RunFailureCallback(); 174 RunFailureCallback();
175 return; 175 return;
176 } 176 }
177 WebKit::WebFrame* main_frame = web_view->mainFrame(); 177 blink::WebFrame* main_frame = web_view->mainFrame();
178 if (!main_frame) { 178 if (!main_frame) {
179 RunFailureCallback(); 179 RunFailureCallback();
180 return; 180 return;
181 } 181 }
182 182
183 // Hash all of the features so that they match the model, then compute 183 // Hash all of the features so that they match the model, then compute
184 // the score. 184 // the score.
185 FeatureMap hashed_features; 185 FeatureMap hashed_features;
186 ClientPhishingRequest verdict; 186 ClientPhishingRequest verdict;
187 verdict.set_model_version(scorer_->model_version()); 187 verdict.set_model_version(scorer_->model_version());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 RunCallback(verdict); 232 RunCallback(verdict);
233 } 233 }
234 234
235 void PhishingClassifier::Clear() { 235 void PhishingClassifier::Clear() {
236 page_text_ = NULL; 236 page_text_ = NULL;
237 done_callback_.Reset(); 237 done_callback_.Reset();
238 features_.reset(NULL); 238 features_.reset(NULL);
239 } 239 }
240 240
241 } // namespace safe_browsing 241 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/safe_browsing/malware_dom_details.cc ('k') | chrome/renderer/safe_browsing/phishing_classifier_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698