| 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 // Note that although this is not a "browser" test, it runs as part of | 5 // Note that although this is not a "browser" test, it runs as part of |
| 6 // browser_tests. This is because WebKit does not work properly if it is | 6 // browser_tests. This is because WebKit does not work properly if it is |
| 7 // shutdown and re-initialized. Since browser_tests runs each test in a | 7 // shutdown and re-initialized. Since browser_tests runs each test in a |
| 8 // new process, this avoids the problem. | 8 // new process, this avoids the problem. |
| 9 | 9 |
| 10 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" | 10 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" |
| 11 | 11 |
| 12 #include <stdint.h> | 12 #include <stdint.h> |
| 13 #include <utility> |
| 14 |
| 13 #include "base/bind.h" | 15 #include "base/bind.h" |
| 14 #include "base/callback.h" | 16 #include "base/callback.h" |
| 15 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 16 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 17 #include "base/location.h" | 19 #include "base/location.h" |
| 18 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 19 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 22 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 std::map<std::string, std::string>::const_iterator it = | 148 std::map<std::string, std::string>::const_iterator it = |
| 147 responses_.find(url); | 149 responses_.find(url); |
| 148 if (it == responses_.end()) | 150 if (it == responses_.end()) |
| 149 return scoped_ptr<net::test_server::HttpResponse>(); | 151 return scoped_ptr<net::test_server::HttpResponse>(); |
| 150 | 152 |
| 151 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 153 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 152 new net::test_server::BasicHttpResponse()); | 154 new net::test_server::BasicHttpResponse()); |
| 153 http_response->set_code(net::HTTP_OK); | 155 http_response->set_code(net::HTTP_OK); |
| 154 http_response->set_content_type("text/html"); | 156 http_response->set_content_type("text/html"); |
| 155 http_response->set_content(it->second); | 157 http_response->set_content(it->second); |
| 156 return http_response.Pass(); | 158 return std::move(http_response); |
| 157 } | 159 } |
| 158 | 160 |
| 159 GURL GetURL(const std::string& host, const std::string& path) { | 161 GURL GetURL(const std::string& host, const std::string& path) { |
| 160 GURL::Replacements replace; | 162 GURL::Replacements replace; |
| 161 replace.SetHostStr(host); | 163 replace.SetHostStr(host); |
| 162 replace.SetPathStr(path); | 164 replace.SetPathStr(path); |
| 163 return embedded_test_server()->base_url().ReplaceComponents(replace); | 165 return embedded_test_server()->base_url().ReplaceComponents(replace); |
| 164 } | 166 } |
| 165 | 167 |
| 166 // Returns the URL that was loaded. | 168 // Returns the URL that was loaded. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 LoadHtml( | 542 LoadHtml( |
| 541 "host.com", | 543 "host.com", |
| 542 "<html><head></head><body>" | 544 "<html><head></head><body>" |
| 543 "<iframe src=\"frame.html\" id=\"frame1\"></iframe>" | 545 "<iframe src=\"frame.html\" id=\"frame1\"></iframe>" |
| 544 "<form></form></body></html>"); | 546 "<form></form></body></html>"); |
| 545 ASSERT_TRUE(ExtractFeatures(&features)); | 547 ASSERT_TRUE(ExtractFeatures(&features)); |
| 546 ExpectFeatureMapsAreEqual(features, expected_features); | 548 ExpectFeatureMapsAreEqual(features, expected_features); |
| 547 } | 549 } |
| 548 | 550 |
| 549 } // namespace safe_browsing | 551 } // namespace safe_browsing |
| OLD | NEW |