| 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.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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "chrome/common/safe_browsing/csd.pb.h" | 16 #include "chrome/common/safe_browsing/csd.pb.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" | 18 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" |
| 19 #include "chrome/renderer/safe_browsing/features.h" | 19 #include "chrome/renderer/safe_browsing/features.h" |
| 20 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" | 20 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" |
| 21 #include "chrome/renderer/safe_browsing/phishing_term_feature_extractor.h" | 21 #include "chrome/renderer/safe_browsing/phishing_term_feature_extractor.h" |
| 22 #include "chrome/renderer/safe_browsing/phishing_url_feature_extractor.h" | 22 #include "chrome/renderer/safe_browsing/phishing_url_feature_extractor.h" |
| 23 #include "chrome/renderer/safe_browsing/scorer.h" | 23 #include "chrome/renderer/safe_browsing/scorer.h" |
| 24 #include "content/public/renderer/render_view.h" | 24 #include "content/public/renderer/render_view.h" |
| 25 #include "crypto/sha2.h" | 25 #include "crypto/sha2.h" |
| 26 #include "net/base/url_constants.h" |
| 26 #include "third_party/WebKit/public/platform/WebURL.h" | 27 #include "third_party/WebKit/public/platform/WebURL.h" |
| 27 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 28 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 28 #include "third_party/WebKit/public/web/WebDataSource.h" | 29 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 29 #include "third_party/WebKit/public/web/WebDocument.h" | 30 #include "third_party/WebKit/public/web/WebDocument.h" |
| 30 #include "third_party/WebKit/public/web/WebFrame.h" | 31 #include "third_party/WebKit/public/web/WebFrame.h" |
| 31 #include "third_party/WebKit/public/web/WebView.h" | 32 #include "third_party/WebKit/public/web/WebView.h" |
| 32 #include "url/gurl.h" | 33 #include "url/gurl.h" |
| 33 | 34 |
| 34 namespace safe_browsing { | 35 namespace safe_browsing { |
| 35 | 36 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 112 |
| 112 blink::WebFrame* frame = web_view->mainFrame(); | 113 blink::WebFrame* frame = web_view->mainFrame(); |
| 113 if (!frame) { | 114 if (!frame) { |
| 114 RunFailureCallback(); | 115 RunFailureCallback(); |
| 115 return; | 116 return; |
| 116 } | 117 } |
| 117 | 118 |
| 118 // Check whether the URL is one that we should classify. | 119 // Check whether the URL is one that we should classify. |
| 119 // Currently, we only classify http: URLs that are GET requests. | 120 // Currently, we only classify http: URLs that are GET requests. |
| 120 GURL url(frame->document().url()); | 121 GURL url(frame->document().url()); |
| 121 if (!url.SchemeIs(content::kHttpScheme)) { | 122 if (!url.SchemeIs(net::kHttpScheme)) { |
| 122 RunFailureCallback(); | 123 RunFailureCallback(); |
| 123 return; | 124 return; |
| 124 } | 125 } |
| 125 | 126 |
| 126 blink::WebDataSource* ds = frame->dataSource(); | 127 blink::WebDataSource* ds = frame->dataSource(); |
| 127 if (!ds || !EqualsASCII(ds->request().httpMethod(), "GET")) { | 128 if (!ds || !EqualsASCII(ds->request().httpMethod(), "GET")) { |
| 128 RunFailureCallback(); | 129 RunFailureCallback(); |
| 129 return; | 130 return; |
| 130 } | 131 } |
| 131 | 132 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 RunCallback(verdict); | 233 RunCallback(verdict); |
| 233 } | 234 } |
| 234 | 235 |
| 235 void PhishingClassifier::Clear() { | 236 void PhishingClassifier::Clear() { |
| 236 page_text_ = NULL; | 237 page_text_ = NULL; |
| 237 done_callback_.Reset(); | 238 done_callback_.Reset(); |
| 238 features_.reset(NULL); | 239 features_.reset(NULL); |
| 239 } | 240 } |
| 240 | 241 |
| 241 } // namespace safe_browsing | 242 } // namespace safe_browsing |
| OLD | NEW |