Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: chrome/renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc

Issue 2649413002: Use explicit WebString conversions in chrome/renderer/safe_browsing (Closed)
Patch Set: addressed comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/safe_browsing/phishing_classifier.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_dom_feature_extractor.h" 5 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 "Please check url_to_frame_domain_map_ setup."; 86 "Please check url_to_frame_domain_map_ setup.";
87 return true; 87 return true;
88 } 88 }
89 } 89 }
90 90
91 // For similar reason as above, PhishingDOMFeatureExtractor::CompeteURL(..) 91 // For similar reason as above, PhishingDOMFeatureExtractor::CompeteURL(..)
92 // always returns empty WebURL. Overriding this CompeteURL(..) to work around 92 // always returns empty WebURL. Overriding this CompeteURL(..) to work around
93 // this issue. 93 // this issue.
94 blink::WebURL CompleteURL(const blink::WebElement& element, 94 blink::WebURL CompleteURL(const blink::WebElement& element,
95 const blink::WebString& partial_url) override { 95 const blink::WebString& partial_url) override {
96 GURL parsed_url(GURL(partial_url.utf8())); 96 GURL parsed_url = blink::WebStringToGURL(partial_url);
97 GURL full_url; 97 GURL full_url;
98 if (parsed_url.has_scheme()) { 98 if (parsed_url.has_scheme()) {
99 // This is already a complete URL. 99 // This is already a complete URL.
100 full_url = GURL(blink::WebStringToGURL(partial_url)); 100 full_url = parsed_url;
101 } else if (!base_domain_.empty()) { 101 } else if (!base_domain_.empty()) {
102 // This is a partial URL and only one frame in testing html. 102 // This is a partial URL and only one frame in testing html.
103 full_url = GURL("http://" + base_domain_).Resolve(partial_url); 103 full_url = GURL("http://" + base_domain_).Resolve(partial_url.utf8());
104 } else { 104 } else {
105 auto it = url_to_frame_domain_map_.find(partial_url.utf8()); 105 auto it = url_to_frame_domain_map_.find(partial_url.utf8());
106 if (it != url_to_frame_domain_map_.end()) { 106 if (it != url_to_frame_domain_map_.end()) {
107 const std::string frame_domain = it->second; 107 const std::string frame_domain = it->second;
108 full_url = GURL("http://" + it->second).Resolve(partial_url.utf8()); 108 full_url = GURL("http://" + it->second).Resolve(partial_url.utf8());
109 url_to_frame_domain_map_[full_url.spec()] = it->second; 109 url_to_frame_domain_map_[full_url.spec()] = it->second;
110 } else { 110 } else {
111 NOTREACHED() << "Testing input setup is incorrect. " 111 NOTREACHED() << "Testing input setup is incorrect. "
112 "Please check url_to_frame_domain_map_ setup."; 112 "Please check url_to_frame_domain_map_ setup.";
113 } 113 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 "<html><head></head><body>" 569 "<html><head></head><body>"
570 "<iframe src=\"" + 570 "<iframe src=\"" +
571 net::EscapeForHTML(iframe1_url.spec()) + 571 net::EscapeForHTML(iframe1_url.spec()) +
572 "\" id=\"frame1\"></iframe>" 572 "\" id=\"frame1\"></iframe>"
573 "<form></form></body></html>"); 573 "<form></form></body></html>");
574 ExtractFeatures("host.com", html, &features); 574 ExtractFeatures("host.com", html, &features);
575 ExpectFeatureMapsAreEqual(features, expected_features); 575 ExpectFeatureMapsAreEqual(features, expected_features);
576 } 576 }
577 577
578 } // namespace safe_browsing 578 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/safe_browsing/phishing_classifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698