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

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

Issue 6713084: Move the rest of the renderer->browser messages that belong in content. Also do a bunch of cleanup: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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
OLDNEW
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"
14 #include "chrome/common/safebrowsing_messages.h" 13 #include "chrome/common/safebrowsing_messages.h"
15 #include "chrome/renderer/render_thread.h" 14 #include "chrome/renderer/render_thread.h"
16 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" 15 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h"
17 #include "chrome/renderer/safe_browsing/phishing_classifier.h" 16 #include "chrome/renderer/safe_browsing/phishing_classifier.h"
18 #include "chrome/renderer/safe_browsing/scorer.h" 17 #include "chrome/renderer/safe_browsing/scorer.h"
19 #include "content/renderer/navigation_state.h" 18 #include "content/renderer/navigation_state.h"
20 #include "content/renderer/render_view.h" 19 #include "content/renderer/render_view.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (classifier_->is_ready()) { 143 if (classifier_->is_ready()) {
145 classifier_->CancelPendingClassification(); 144 classifier_->CancelPendingClassification();
146 } 145 }
147 classifier_page_text_.clear(); 146 classifier_page_text_.clear();
148 } 147 }
149 148
150 bool PhishingClassifierDelegate::OnMessageReceived( 149 bool PhishingClassifierDelegate::OnMessageReceived(
151 const IPC::Message& message) { 150 const IPC::Message& message) {
152 bool handled = true; 151 bool handled = true;
153 IPC_BEGIN_MESSAGE_MAP(PhishingClassifierDelegate, message) 152 IPC_BEGIN_MESSAGE_MAP(PhishingClassifierDelegate, message)
154 IPC_MESSAGE_HANDLER(ViewMsg_StartPhishingDetection, 153 IPC_MESSAGE_HANDLER(SafeBrowsingMsg_StartPhishingDetection,
155 OnStartPhishingDetection) 154 OnStartPhishingDetection)
156 IPC_MESSAGE_UNHANDLED(handled = false) 155 IPC_MESSAGE_UNHANDLED(handled = false)
157 IPC_END_MESSAGE_MAP() 156 IPC_END_MESSAGE_MAP()
158 return handled; 157 return handled;
159 } 158 }
160 159
161 void PhishingClassifierDelegate::ClassificationDone(bool is_phishy, 160 void PhishingClassifierDelegate::ClassificationDone(bool is_phishy,
162 double phishy_score) { 161 double phishy_score) {
163 // We no longer need the page text. 162 // We no longer need the page text.
164 classifier_page_text_.clear(); 163 classifier_page_text_.clear();
165 VLOG(2) << "Phishy verdict = " << is_phishy << " score = " << phishy_score; 164 VLOG(2) << "Phishy verdict = " << is_phishy << " score = " << phishy_score;
166 if (!is_phishy) { 165 if (!is_phishy) {
167 return; 166 return;
168 } 167 }
169 168
170 Send(new SafeBrowsingDetectionHostMsg_DetectedPhishingSite( 169 Send(new SafeBrowsingHostMsg_DetectedPhishingSite(
171 routing_id(), 170 routing_id(),
172 last_url_sent_to_classifier_, 171 last_url_sent_to_classifier_,
173 phishy_score)); 172 phishy_score));
174 } 173 }
175 174
176 GURL PhishingClassifierDelegate::StripToplevelUrl() { 175 GURL PhishingClassifierDelegate::StripToplevelUrl() {
177 return StripRef(render_view()->webview()->mainFrame()->url()); 176 return StripRef(render_view()->webview()->mainFrame()->url());
178 } 177 }
179 178
180 void PhishingClassifierDelegate::MaybeStartClassification() { 179 void PhishingClassifierDelegate::MaybeStartClassification() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 234
236 VLOG(2) << "Starting classification for " << last_finished_load_url_; 235 VLOG(2) << "Starting classification for " << last_finished_load_url_;
237 last_url_sent_to_classifier_ = last_finished_load_url_; 236 last_url_sent_to_classifier_ = last_finished_load_url_;
238 last_page_id_sent_to_classifier_ = last_finished_load_id_; 237 last_page_id_sent_to_classifier_ = last_finished_load_id_;
239 classifier_->BeginClassification( 238 classifier_->BeginClassification(
240 &classifier_page_text_, 239 &classifier_page_text_,
241 NewCallback(this, &PhishingClassifierDelegate::ClassificationDone)); 240 NewCallback(this, &PhishingClassifierDelegate::ClassificationDone));
242 } 241 }
243 242
244 } // namespace safe_browsing 243 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698