| 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/client_side_detection_host.h" | 5 #include "chrome/browser/safe_browsing/client_side_detection_host.h" |
| 6 | 6 |
| 7 #include <tuple> |
| 7 #include <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 15 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 16 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" | 17 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 323 |
| 323 void ExpectShouldClassifyForMalwareResult(bool should_classify) { | 324 void ExpectShouldClassifyForMalwareResult(bool should_classify) { |
| 324 EXPECT_EQ(should_classify, csd_host_->should_classify_for_malware_); | 325 EXPECT_EQ(should_classify, csd_host_->should_classify_for_malware_); |
| 325 } | 326 } |
| 326 | 327 |
| 327 void ExpectStartPhishingDetection(const GURL* url) { | 328 void ExpectStartPhishingDetection(const GURL* url) { |
| 328 const IPC::Message* msg = process()->sink().GetFirstMessageMatching( | 329 const IPC::Message* msg = process()->sink().GetFirstMessageMatching( |
| 329 SafeBrowsingMsg_StartPhishingDetection::ID); | 330 SafeBrowsingMsg_StartPhishingDetection::ID); |
| 330 if (url) { | 331 if (url) { |
| 331 ASSERT_TRUE(msg); | 332 ASSERT_TRUE(msg); |
| 332 base::Tuple<GURL> actual_url; | 333 std::tuple<GURL> actual_url; |
| 333 SafeBrowsingMsg_StartPhishingDetection::Read(msg, &actual_url); | 334 SafeBrowsingMsg_StartPhishingDetection::Read(msg, &actual_url); |
| 334 EXPECT_EQ(*url, base::get<0>(actual_url)); | 335 EXPECT_EQ(*url, std::get<0>(actual_url)); |
| 335 EXPECT_EQ(main_rfh()->GetRoutingID(), msg->routing_id()); | 336 EXPECT_EQ(main_rfh()->GetRoutingID(), msg->routing_id()); |
| 336 process()->sink().ClearMessages(); | 337 process()->sink().ClearMessages(); |
| 337 } else { | 338 } else { |
| 338 ASSERT_FALSE(msg); | 339 ASSERT_FALSE(msg); |
| 339 } | 340 } |
| 340 } | 341 } |
| 341 | 342 |
| 342 void TestUnsafeResourceCopied(const UnsafeResource& resource) { | 343 void TestUnsafeResourceCopied(const UnsafeResource& resource) { |
| 343 ASSERT_TRUE(csd_host_->unsafe_resource_.get()); | 344 ASSERT_TRUE(csd_host_->unsafe_resource_.get()); |
| 344 // Test that the resource from OnSafeBrowsingHit notification was copied | 345 // Test that the resource from OnSafeBrowsingHit notification was copied |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 EXPECT_EQ(url, resource.url); | 1199 EXPECT_EQ(url, resource.url); |
| 1199 EXPECT_EQ(url, resource.original_url); | 1200 EXPECT_EQ(url, resource.original_url); |
| 1200 | 1201 |
| 1201 ExpectStartPhishingDetection(NULL); | 1202 ExpectStartPhishingDetection(NULL); |
| 1202 | 1203 |
| 1203 // Showing a phishing warning will invalidate all the weak pointers which | 1204 // Showing a phishing warning will invalidate all the weak pointers which |
| 1204 // means we will not extract malware features. | 1205 // means we will not extract malware features. |
| 1205 ExpectShouldClassifyForMalwareResult(false); | 1206 ExpectShouldClassifyForMalwareResult(false); |
| 1206 } | 1207 } |
| 1207 } // namespace safe_browsing | 1208 } // namespace safe_browsing |
| OLD | NEW |