OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/scoped_callback_factory.h" | 12 #include "base/scoped_callback_factory.h" |
13 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
| 14 #include "chrome/common/safebrowsing_messages.h" |
14 #include "chrome/renderer/navigation_state.h" | 15 #include "chrome/renderer/navigation_state.h" |
15 #include "chrome/renderer/render_thread.h" | 16 #include "chrome/renderer/render_thread.h" |
16 #include "chrome/renderer/render_view.h" | 17 #include "chrome/renderer/render_view.h" |
17 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" | 18 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" |
18 #include "chrome/renderer/safe_browsing/phishing_classifier.h" | 19 #include "chrome/renderer/safe_browsing/phishing_classifier.h" |
19 #include "chrome/renderer/safe_browsing/scorer.h" | 20 #include "chrome/renderer/safe_browsing/scorer.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
23 | 24 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 160 |
160 void PhishingClassifierDelegate::ClassificationDone(bool is_phishy, | 161 void PhishingClassifierDelegate::ClassificationDone(bool is_phishy, |
161 double phishy_score) { | 162 double phishy_score) { |
162 // We no longer need the page text. | 163 // We no longer need the page text. |
163 classifier_page_text_.clear(); | 164 classifier_page_text_.clear(); |
164 VLOG(2) << "Phishy verdict = " << is_phishy << " score = " << phishy_score; | 165 VLOG(2) << "Phishy verdict = " << is_phishy << " score = " << phishy_score; |
165 if (!is_phishy) { | 166 if (!is_phishy) { |
166 return; | 167 return; |
167 } | 168 } |
168 | 169 |
169 render_view()->Send(new ViewHostMsg_DetectedPhishingSite( | 170 Send(new SafeBrowsingDetectionHostMsg_DetectedPhishingSite( |
170 render_view()->routing_id(), | 171 routing_id(), |
171 last_url_sent_to_classifier_, | 172 last_url_sent_to_classifier_, |
172 phishy_score)); | 173 phishy_score)); |
173 } | 174 } |
174 | 175 |
175 GURL PhishingClassifierDelegate::StripToplevelUrl() { | 176 GURL PhishingClassifierDelegate::StripToplevelUrl() { |
176 return StripRef(render_view()->webview()->mainFrame()->url()); | 177 return StripRef(render_view()->webview()->mainFrame()->url()); |
177 } | 178 } |
178 | 179 |
179 void PhishingClassifierDelegate::MaybeStartClassification() { | 180 void PhishingClassifierDelegate::MaybeStartClassification() { |
180 // We can begin phishing classification when the following conditions are | 181 // We can begin phishing classification when the following conditions are |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 235 |
235 VLOG(2) << "Starting classification for " << last_finished_load_url_; | 236 VLOG(2) << "Starting classification for " << last_finished_load_url_; |
236 last_url_sent_to_classifier_ = last_finished_load_url_; | 237 last_url_sent_to_classifier_ = last_finished_load_url_; |
237 last_page_id_sent_to_classifier_ = last_finished_load_id_; | 238 last_page_id_sent_to_classifier_ = last_finished_load_id_; |
238 classifier_->BeginClassification( | 239 classifier_->BeginClassification( |
239 &classifier_page_text_, | 240 &classifier_page_text_, |
240 NewCallback(this, &PhishingClassifierDelegate::ClassificationDone)); | 241 NewCallback(this, &PhishingClassifierDelegate::ClassificationDone)); |
241 } | 242 } |
242 | 243 |
243 } // namespace safe_browsing | 244 } // namespace safe_browsing |
OLD | NEW |