| 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/browser/safe_browsing/browser_feature_extractor.h" | 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 EXPECT_EQ(5.0, features[features::kPageTransitionType]); | 568 EXPECT_EQ(5.0, features[features::kPageTransitionType]); |
| 569 } | 569 } |
| 570 | 570 |
| 571 TEST_F(BrowserFeatureExtractorTest, SafeBrowsingFeatures) { | 571 TEST_F(BrowserFeatureExtractorTest, SafeBrowsingFeatures) { |
| 572 SimpleNavigateAndCommit(GURL("http://www.foo.com/malware.html")); | 572 SimpleNavigateAndCommit(GURL("http://www.foo.com/malware.html")); |
| 573 ClientPhishingRequest request; | 573 ClientPhishingRequest request; |
| 574 request.set_url("http://www.foo.com/malware.html"); | 574 request.set_url("http://www.foo.com/malware.html"); |
| 575 request.set_client_score(0.5); | 575 request.set_client_score(0.5); |
| 576 | 576 |
| 577 browse_info_->unsafe_resource.reset( | 577 browse_info_->unsafe_resource.reset( |
| 578 new SafeBrowsingUIManager::UnsafeResource); | 578 new security_interstitials::UnsafeResource); |
| 579 browse_info_->unsafe_resource->url = GURL("http://www.malware.com/"); | 579 browse_info_->unsafe_resource->url = GURL("http://www.malware.com/"); |
| 580 browse_info_->unsafe_resource->original_url = GURL("http://www.good.com/"); | 580 browse_info_->unsafe_resource->original_url = GURL("http://www.good.com/"); |
| 581 browse_info_->unsafe_resource->is_subresource = true; | 581 browse_info_->unsafe_resource->is_subresource = true; |
| 582 browse_info_->unsafe_resource->threat_type = SB_THREAT_TYPE_URL_MALWARE; | 582 browse_info_->unsafe_resource->threat_type = SB_THREAT_TYPE_URL_MALWARE; |
| 583 | 583 |
| 584 ExtractFeatures(&request); | 584 ExtractFeatures(&request); |
| 585 std::map<std::string, double> features; | 585 std::map<std::string, double> features; |
| 586 GetFeatureMap(request, &features); | 586 GetFeatureMap(request, &features); |
| 587 EXPECT_TRUE(features.count(base::StringPrintf( | 587 EXPECT_TRUE(features.count(base::StringPrintf( |
| 588 "%s%s", | 588 "%s%s", |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 // First ip is good but all the others are bad. | 652 // First ip is good but all the others are bad. |
| 653 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); | 653 EXPECT_CALL(*db_manager_, MatchMalwareIP(ip)).WillOnce(Return(i > 0)); |
| 654 } | 654 } |
| 655 | 655 |
| 656 ExtractMalwareFeatures(&request); | 656 ExtractMalwareFeatures(&request); |
| 657 // The number of IP matched url we store is capped at 5 IPs per request. | 657 // The number of IP matched url we store is capped at 5 IPs per request. |
| 658 EXPECT_EQ(5, request.bad_ip_url_info_size()); | 658 EXPECT_EQ(5, request.bad_ip_url_info_size()); |
| 659 } | 659 } |
| 660 | 660 |
| 661 } // namespace safe_browsing | 661 } // namespace safe_browsing |
| OLD | NEW |