| 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" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); | 259 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); |
| 260 EXPECT_EQ(0U, features.features().size()); | 260 EXPECT_EQ(0U, features.features().size()); |
| 261 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); | 261 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); |
| 262 | 262 |
| 263 // Extraction should also fail for this case because the URL is not http. | 263 // Extraction should also fail for this case because the URL is not http. |
| 264 net::SpawnedTestServer https_server( | 264 net::SpawnedTestServer https_server( |
| 265 net::SpawnedTestServer::TYPE_HTTPS, | 265 net::SpawnedTestServer::TYPE_HTTPS, |
| 266 net::SpawnedTestServer::kLocalhost, | 266 net::SpawnedTestServer::kLocalhost, |
| 267 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 267 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
| 268 ASSERT_TRUE(https_server.Start()); | 268 ASSERT_TRUE(https_server.Start()); |
| 269 std::string host_str("host.net"); // Must outlive replace_host. | |
| 270 GURL::Replacements replace_host; | 269 GURL::Replacements replace_host; |
| 271 replace_host.SetHostStr(host_str); | 270 replace_host.SetHostStr("host.net"); |
| 272 GURL test_url = https_server.GetURL("/files/title1.html"); | 271 GURL test_url = https_server.GetURL("/files/title1.html"); |
| 273 ui_test_utils::NavigateToURL(browser(), | 272 ui_test_utils::NavigateToURL(browser(), |
| 274 test_url.ReplaceComponents(replace_host)); | 273 test_url.ReplaceComponents(replace_host)); |
| 275 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); | 274 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); |
| 276 EXPECT_EQ(0U, features.features().size()); | 275 EXPECT_EQ(0U, features.features().size()); |
| 277 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); | 276 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); |
| 278 | 277 |
| 279 // Extraction should fail for this case because the URL is a POST request. | 278 // Extraction should fail for this case because the URL is a POST request. |
| 280 LoadHtmlPost("host.net", "<html><body>content</body></html>"); | 279 LoadHtmlPost("host.net", "<html><body>content</body></html>"); |
| 281 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); | 280 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 296 // Now set the scorer. | 295 // Now set the scorer. |
| 297 classifier_->set_phishing_scorer(scorer_.get()); | 296 classifier_->set_phishing_scorer(scorer_.get()); |
| 298 EXPECT_TRUE(classifier_->is_ready()); | 297 EXPECT_TRUE(classifier_->is_ready()); |
| 299 | 298 |
| 300 // Set a NULL scorer, which turns detection back off. | 299 // Set a NULL scorer, which turns detection back off. |
| 301 classifier_->set_phishing_scorer(NULL); | 300 classifier_->set_phishing_scorer(NULL); |
| 302 EXPECT_FALSE(classifier_->is_ready()); | 301 EXPECT_FALSE(classifier_->is_ready()); |
| 303 } | 302 } |
| 304 | 303 |
| 305 } // namespace safe_browsing | 304 } // namespace safe_browsing |
| OLD | NEW |