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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // allows us to specify the referrer and page_transition_type. | 93 // allows us to specify the referrer and page_transition_type. |
94 void NavigateAndCommit(const GURL& url, | 94 void NavigateAndCommit(const GURL& url, |
95 const GURL& referrer, | 95 const GURL& referrer, |
96 content::PageTransition type) { | 96 content::PageTransition type) { |
97 contents()->GetController().LoadURL( | 97 contents()->GetController().LoadURL( |
98 url, content::Referrer(referrer, WebKit::WebReferrerPolicyDefault), | 98 url, content::Referrer(referrer, WebKit::WebReferrerPolicyDefault), |
99 type, std::string()); | 99 type, std::string()); |
100 | 100 |
101 static int page_id = 0; | 101 static int page_id = 0; |
102 content::RenderViewHost* rvh = | 102 content::RenderViewHost* rvh = |
103 WebContentsTester::For(contents())->pending_rvh(); | 103 WebContentsTester::For(contents())->GetPendingRenderViewHost(); |
104 if (!rvh) { | 104 if (!rvh) { |
105 rvh = contents()->GetRenderViewHost(); | 105 rvh = contents()->GetRenderViewHost(); |
106 } | 106 } |
107 WebContentsTester::For(contents())->ProceedWithCrossSiteNavigation(); | 107 WebContentsTester::For(contents())->ProceedWithCrossSiteNavigation(); |
108 WebContentsTester::For(contents())->TestDidNavigateWithReferrer( | 108 WebContentsTester::For(contents())->TestDidNavigateWithReferrer( |
109 rvh, ++page_id, url, | 109 rvh, ++page_id, url, |
110 content::Referrer(referrer, WebKit::WebReferrerPolicyDefault), type); | 110 content::Referrer(referrer, WebKit::WebReferrerPolicyDefault), type); |
111 } | 111 } |
112 | 112 |
113 bool ExtractFeatures(ClientPhishingRequest* request) { | 113 bool ExtractFeatures(ClientPhishingRequest* request) { |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 EXPECT_TRUE(features.count(StringPrintf("%s%s", | 499 EXPECT_TRUE(features.count(StringPrintf("%s%s", |
500 features::kSafeBrowsingMaliciousUrl, | 500 features::kSafeBrowsingMaliciousUrl, |
501 "http://www.malware.com/"))); | 501 "http://www.malware.com/"))); |
502 EXPECT_TRUE(features.count(StringPrintf("%s%s", | 502 EXPECT_TRUE(features.count(StringPrintf("%s%s", |
503 features::kSafeBrowsingOriginalUrl, | 503 features::kSafeBrowsingOriginalUrl, |
504 "http://www.good.com/"))); | 504 "http://www.good.com/"))); |
505 EXPECT_DOUBLE_EQ(1.0, features[features::kSafeBrowsingIsSubresource]); | 505 EXPECT_DOUBLE_EQ(1.0, features[features::kSafeBrowsingIsSubresource]); |
506 EXPECT_DOUBLE_EQ(2.0, features[features::kSafeBrowsingThreatType]); | 506 EXPECT_DOUBLE_EQ(2.0, features[features::kSafeBrowsingThreatType]); |
507 } | 507 } |
508 } // namespace safe_browsing | 508 } // namespace safe_browsing |
OLD | NEW |