| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 SetRedirectChain(redirect_chain, true); | 122 SetRedirectChain(redirect_chain, true); |
| 123 NavigateAndCommit(url, GURL(), content::PAGE_TRANSITION_LINK); | 123 NavigateAndCommit(url, GURL(), content::PAGE_TRANSITION_LINK); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // This is similar to NavigateAndCommit that is in WebContentsTester, but | 126 // This is similar to NavigateAndCommit that is in WebContentsTester, but |
| 127 // allows us to specify the referrer and page_transition_type. | 127 // allows us to specify the referrer and page_transition_type. |
| 128 void NavigateAndCommit(const GURL& url, | 128 void NavigateAndCommit(const GURL& url, |
| 129 const GURL& referrer, | 129 const GURL& referrer, |
| 130 content::PageTransition type) { | 130 content::PageTransition type) { |
| 131 web_contents()->GetController().LoadURL( | 131 web_contents()->GetController().LoadURL( |
| 132 url, content::Referrer(referrer, WebKit::WebReferrerPolicyDefault), | 132 url, content::Referrer(referrer, blink::WebReferrerPolicyDefault), |
| 133 type, std::string()); | 133 type, std::string()); |
| 134 | 134 |
| 135 static int page_id = 0; | 135 static int page_id = 0; |
| 136 content::RenderViewHost* rvh = | 136 content::RenderViewHost* rvh = |
| 137 WebContentsTester::For(web_contents())->GetPendingRenderViewHost(); | 137 WebContentsTester::For(web_contents())->GetPendingRenderViewHost(); |
| 138 if (!rvh) { | 138 if (!rvh) { |
| 139 rvh = web_contents()->GetRenderViewHost(); | 139 rvh = web_contents()->GetRenderViewHost(); |
| 140 } | 140 } |
| 141 WebContentsTester::For(web_contents())->ProceedWithCrossSiteNavigation(); | 141 WebContentsTester::For(web_contents())->ProceedWithCrossSiteNavigation(); |
| 142 WebContentsTester::For(web_contents())->TestDidNavigateWithReferrer( | 142 WebContentsTester::For(web_contents())->TestDidNavigateWithReferrer( |
| 143 rvh, ++page_id, url, | 143 rvh, ++page_id, url, |
| 144 content::Referrer(referrer, WebKit::WebReferrerPolicyDefault), type); | 144 content::Referrer(referrer, blink::WebReferrerPolicyDefault), type); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool ExtractFeatures(ClientPhishingRequest* request) { | 147 bool ExtractFeatures(ClientPhishingRequest* request) { |
| 148 StartExtractFeatures(request); | 148 StartExtractFeatures(request); |
| 149 base::MessageLoop::current()->Run(); | 149 base::MessageLoop::current()->Run(); |
| 150 EXPECT_EQ(1U, success_.count(request)); | 150 EXPECT_EQ(1U, success_.count(request)); |
| 151 return success_.count(request) ? success_[request] : false; | 151 return success_.count(request) ? success_[request] : false; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void StartExtractFeatures(ClientPhishingRequest* request) { | 154 void StartExtractFeatures(ClientPhishingRequest* request) { |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 | 652 |
| 653 ExtractMalwareFeatures(&request); | 653 ExtractMalwareFeatures(&request); |
| 654 std::map<std::string, std::set<std::string> > features; | 654 std::map<std::string, std::set<std::string> > features; |
| 655 GetMalwareFeatureMap(request, &features); | 655 GetMalwareFeatureMap(request, &features); |
| 656 | 656 |
| 657 // The number of IP match features we store is capped at 5 IPs per request. | 657 // The number of IP match features we store is capped at 5 IPs per request. |
| 658 EXPECT_EQ(5U, features.size()); | 658 EXPECT_EQ(5U, features.size()); |
| 659 } | 659 } |
| 660 | 660 |
| 661 } // namespace safe_browsing | 661 } // namespace safe_browsing |
| OLD | NEW |