| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/safe_browsing/client_model.pb.h" | 15 #include "chrome/common/safe_browsing/client_model.pb.h" |
| 16 #include "chrome/common/safe_browsing/csd.pb.h" | 16 #include "chrome/common/safe_browsing/csd.pb.h" |
| 17 #include "chrome/renderer/safe_browsing/features.h" | 17 #include "chrome/renderer/safe_browsing/features.h" |
| 18 #include "chrome/renderer/safe_browsing/mock_feature_extractor_clock.h" | 18 #include "chrome/renderer/safe_browsing/mock_feature_extractor_clock.h" |
| 19 #include "chrome/renderer/safe_browsing/murmurhash3_util.h" | 19 #include "chrome/renderer/safe_browsing/murmurhash3_util.h" |
| 20 #include "chrome/renderer/safe_browsing/scorer.h" | 20 #include "chrome/renderer/safe_browsing/scorer.h" |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
| 22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "content/public/renderer/render_view.h" | 23 #include "content/public/renderer/render_view.h" |
| 24 #include "content/public/test/routing_id_mangling_disabler.h" |
| 24 #include "crypto/sha2.h" | 25 #include "crypto/sha2.h" |
| 25 #include "net/dns/mock_host_resolver.h" | 26 #include "net/dns/mock_host_resolver.h" |
| 26 #include "net/test/embedded_test_server/embedded_test_server.h" | 27 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 27 #include "net/test/embedded_test_server/http_response.h" | 28 #include "net/test/embedded_test_server/http_response.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 29 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 30 | 31 |
| 31 using ::testing::AllOf; | 32 using ::testing::AllOf; |
| 32 using ::testing::Contains; | 33 using ::testing::Contains; |
| 33 using ::testing::Not; | 34 using ::testing::Not; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 http_response->set_code(net::HTTP_OK); | 193 http_response->set_code(net::HTTP_OK); |
| 193 http_response->set_content_type("text/html"); | 194 http_response->set_content_type("text/html"); |
| 194 http_response->set_content(response_content_); | 195 http_response->set_content(response_content_); |
| 195 return http_response.Pass(); | 196 return http_response.Pass(); |
| 196 } | 197 } |
| 197 | 198 |
| 198 std::string response_content_; | 199 std::string response_content_; |
| 199 scoped_ptr<Scorer> scorer_; | 200 scoped_ptr<Scorer> scorer_; |
| 200 scoped_ptr<PhishingClassifier> classifier_; | 201 scoped_ptr<PhishingClassifier> classifier_; |
| 201 MockFeatureExtractorClock* clock_; // Owned by classifier_. | 202 MockFeatureExtractorClock* clock_; // Owned by classifier_. |
| 203 content::RoutingIDManglingDisabler mangling_disabler_; |
| 202 | 204 |
| 203 // Features that are in the model. | 205 // Features that are in the model. |
| 204 const std::string url_tld_token_net_; | 206 const std::string url_tld_token_net_; |
| 205 const std::string page_link_domain_phishing_; | 207 const std::string page_link_domain_phishing_; |
| 206 const std::string page_term_login_; | 208 const std::string page_term_login_; |
| 207 }; | 209 }; |
| 208 | 210 |
| 209 // This test flakes on Mac with force compositing mode. | 211 // This test flakes on Mac with force compositing mode. |
| 210 // http://crbug.com/316709 | 212 // http://crbug.com/316709 |
| 211 #if defined(OS_MACOSX) | 213 #if defined(OS_MACOSX) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // Now set the scorer. | 297 // Now set the scorer. |
| 296 classifier_->set_phishing_scorer(scorer_.get()); | 298 classifier_->set_phishing_scorer(scorer_.get()); |
| 297 EXPECT_TRUE(classifier_->is_ready()); | 299 EXPECT_TRUE(classifier_->is_ready()); |
| 298 | 300 |
| 299 // Set a NULL scorer, which turns detection back off. | 301 // Set a NULL scorer, which turns detection back off. |
| 300 classifier_->set_phishing_scorer(NULL); | 302 classifier_->set_phishing_scorer(NULL); |
| 301 EXPECT_FALSE(classifier_->is_ready()); | 303 EXPECT_FALSE(classifier_->is_ready()); |
| 302 } | 304 } |
| 303 | 305 |
| 304 } // namespace safe_browsing | 306 } // namespace safe_browsing |
| OLD | NEW |