OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 5 #include <map> |
6 #include <queue> | 6 #include <queue> |
7 #include <string> | 7 #include <string> |
8 | 8 |
| 9 #include "base/bind.h" |
9 #include "base/callback.h" | 10 #include "base/callback.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
13 #include "base/task.h" | 14 #include "base/task.h" |
14 #include "base/time.h" | 15 #include "base/time.h" |
15 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 16 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
16 #include "chrome/common/safe_browsing/client_model.pb.h" | 17 #include "chrome/common/safe_browsing/client_model.pb.h" |
17 #include "chrome/common/safe_browsing/csd.pb.h" | 18 #include "chrome/common/safe_browsing/csd.pb.h" |
18 #include "content/test/test_browser_thread.h" | 19 #include "content/test/test_browser_thread.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 80 } |
80 | 81 |
81 bool SendClientReportPhishingRequest(const GURL& phishing_url, | 82 bool SendClientReportPhishingRequest(const GURL& phishing_url, |
82 float score) { | 83 float score) { |
83 ClientPhishingRequest* request = new ClientPhishingRequest(); | 84 ClientPhishingRequest* request = new ClientPhishingRequest(); |
84 request->set_url(phishing_url.spec()); | 85 request->set_url(phishing_url.spec()); |
85 request->set_client_score(score); | 86 request->set_client_score(score); |
86 request->set_is_phishing(true); // client thinks the URL is phishing. | 87 request->set_is_phishing(true); // client thinks the URL is phishing. |
87 csd_service_->SendClientReportPhishingRequest( | 88 csd_service_->SendClientReportPhishingRequest( |
88 request, | 89 request, |
89 NewCallback(this, &ClientSideDetectionServiceTest::SendRequestDone)); | 90 base::Bind(&ClientSideDetectionServiceTest::SendRequestDone, |
| 91 base::Unretained(this))); |
90 phishing_url_ = phishing_url; | 92 phishing_url_ = phishing_url; |
91 msg_loop_.Run(); // Waits until callback is called. | 93 msg_loop_.Run(); // Waits until callback is called. |
92 return is_phishing_; | 94 return is_phishing_; |
93 } | 95 } |
94 | 96 |
95 void SetModelFetchResponse(std::string response_data, bool success) { | 97 void SetModelFetchResponse(std::string response_data, bool success) { |
96 factory_->SetFakeResponse(ClientSideDetectionService::kClientModelUrl, | 98 factory_->SetFakeResponse(ClientSideDetectionService::kClientModelUrl, |
97 response_data, success); | 99 response_data, success); |
98 } | 100 } |
99 | 101 |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 EXPECT_TRUE(ClientSideDetectionService::IsFalsePositiveResponse( | 690 EXPECT_TRUE(ClientSideDetectionService::IsFalsePositiveResponse( |
689 url, response)); | 691 url, response)); |
690 | 692 |
691 // If an entry in the whitelist matches the URL it should return true. | 693 // If an entry in the whitelist matches the URL it should return true. |
692 response.clear_whitelist_expression(); | 694 response.clear_whitelist_expression(); |
693 response.add_whitelist_expression("www.google.com/a/b.html"); | 695 response.add_whitelist_expression("www.google.com/a/b.html"); |
694 EXPECT_TRUE(ClientSideDetectionService::IsFalsePositiveResponse( | 696 EXPECT_TRUE(ClientSideDetectionService::IsFalsePositiveResponse( |
695 url, response)); | 697 url, response)); |
696 } | 698 } |
697 } // namespace safe_browsing | 699 } // namespace safe_browsing |
OLD | NEW |