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" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
6 #include "base/macros.h" | 10 #include "base/macros.h" |
7 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
9 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
10 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
11 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
12 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" | 16 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
13 #include "chrome/browser/safe_browsing/client_side_detection_host.h" | |
14 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 17 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
15 #include "chrome/browser/safe_browsing/database_manager.h" | 18 #include "chrome/browser/safe_browsing/database_manager.h" |
16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
17 #include "chrome/browser/safe_browsing/test_database_manager.h" | 20 #include "chrome/browser/safe_browsing/test_database_manager.h" |
18 #include "chrome/browser/safe_browsing/ui_manager.h" | 21 #include "chrome/browser/safe_browsing/ui_manager.h" |
19 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/safe_browsing/csd.pb.h" | 23 #include "chrome/common/safe_browsing/csd.pb.h" |
21 #include "chrome/common/safe_browsing/safebrowsing_messages.h" | 24 #include "chrome/common/safe_browsing/safebrowsing_messages.h" |
22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 25 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
23 #include "chrome/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 93 } |
91 | 94 |
92 ACTION(QuitUIMessageLoop) { | 95 ACTION(QuitUIMessageLoop) { |
93 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 96 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
94 base::MessageLoopForUI::current()->QuitWhenIdle(); | 97 base::MessageLoopForUI::current()->QuitWhenIdle(); |
95 } | 98 } |
96 | 99 |
97 ACTION_P(InvokeDoneCallback, verdict) { | 100 ACTION_P(InvokeDoneCallback, verdict) { |
98 scoped_ptr<ClientPhishingRequest> request(::std::tr1::get<1>(args)); | 101 scoped_ptr<ClientPhishingRequest> request(::std::tr1::get<1>(args)); |
99 request->CopyFrom(*verdict); | 102 request->CopyFrom(*verdict); |
100 ::std::tr1::get<2>(args).Run(true, request.Pass()); | 103 ::std::tr1::get<2>(args).Run(true, std::move(request)); |
101 } | 104 } |
102 | 105 |
103 ACTION_P(InvokeMalwareCallback, verdict) { | 106 ACTION_P(InvokeMalwareCallback, verdict) { |
104 scoped_ptr<ClientMalwareRequest> request(::std::tr1::get<1>(args)); | 107 scoped_ptr<ClientMalwareRequest> request(::std::tr1::get<1>(args)); |
105 request->CopyFrom(*verdict); | 108 request->CopyFrom(*verdict); |
106 ::std::tr1::get<2>(args).Run(true, request.Pass()); | 109 ::std::tr1::get<2>(args).Run(true, std::move(request)); |
107 } | 110 } |
108 | 111 |
109 void EmptyUrlCheckCallback(bool processed) { | 112 void EmptyUrlCheckCallback(bool processed) { |
110 } | 113 } |
111 | 114 |
112 class MockClientSideDetectionService : public ClientSideDetectionService { | 115 class MockClientSideDetectionService : public ClientSideDetectionService { |
113 public: | 116 public: |
114 MockClientSideDetectionService() : ClientSideDetectionService(NULL) {} | 117 MockClientSideDetectionService() : ClientSideDetectionService(NULL) {} |
115 virtual ~MockClientSideDetectionService() {} | 118 virtual ~MockClientSideDetectionService() {} |
116 | 119 |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 EXPECT_EQ(url, resource.url); | 1196 EXPECT_EQ(url, resource.url); |
1194 EXPECT_EQ(url, resource.original_url); | 1197 EXPECT_EQ(url, resource.original_url); |
1195 | 1198 |
1196 ExpectStartPhishingDetection(NULL); | 1199 ExpectStartPhishingDetection(NULL); |
1197 | 1200 |
1198 // Showing a phishing warning will invalidate all the weak pointers which | 1201 // Showing a phishing warning will invalidate all the weak pointers which |
1199 // means we will not extract malware features. | 1202 // means we will not extract malware features. |
1200 ExpectShouldClassifyForMalwareResult(false); | 1203 ExpectShouldClassifyForMalwareResult(false); |
1201 } | 1204 } |
1202 } // namespace safe_browsing | 1205 } // namespace safe_browsing |
OLD | NEW |