| 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 <memory> | 7 #include <memory> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 ExpectShouldClassifyForMalwareResult(false); | 1165 ExpectShouldClassifyForMalwareResult(false); |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckHttpsUrl) { | 1168 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckHttpsUrl) { |
| 1169 GURL url("https://host.com/"); | 1169 GURL url("https://host.com/"); |
| 1170 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, | 1170 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, |
| 1171 &kFalse, &kFalse, &kFalse, &kFalse); | 1171 &kFalse, &kFalse, &kFalse, &kFalse); |
| 1172 NavigateAndCommit(url); | 1172 NavigateAndCommit(url); |
| 1173 WaitAndCheckPreClassificationChecks(); | 1173 WaitAndCheckPreClassificationChecks(); |
| 1174 | 1174 |
| 1175 ExpectStartPhishingDetection(&url); |
| 1176 ExpectShouldClassifyForMalwareResult(true); |
| 1177 } |
| 1178 |
| 1179 TEST_F(ClientSideDetectionHostTest, |
| 1180 TestPreClassificationCheckNoneHttpOrHttpsUrl) { |
| 1181 GURL url("file://host.com/"); |
| 1182 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, |
| 1183 &kFalse, &kFalse, &kFalse, &kFalse); |
| 1184 NavigateAndCommit(url); |
| 1185 WaitAndCheckPreClassificationChecks(); |
| 1186 |
| 1175 ExpectStartPhishingDetection(NULL); | 1187 ExpectStartPhishingDetection(NULL); |
| 1176 ExpectShouldClassifyForMalwareResult(true); | 1188 ExpectShouldClassifyForMalwareResult(true); |
| 1177 } | 1189 } |
| 1178 | 1190 |
| 1179 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckValidCached) { | 1191 TEST_F(ClientSideDetectionHostTest, TestPreClassificationCheckValidCached) { |
| 1180 // If result is cached, we will try and display the blocking page directly | 1192 // If result is cached, we will try and display the blocking page directly |
| 1181 // with no start classification message. | 1193 // with no start classification message. |
| 1182 GURL url("http://host8.com/"); | 1194 GURL url("http://host8.com/"); |
| 1183 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, &kTrue, | 1195 ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, &kTrue, |
| 1184 &kFalse, &kFalse, &kFalse); | 1196 &kFalse, &kFalse, &kFalse); |
| 1185 | 1197 |
| 1186 UnsafeResource resource; | 1198 UnsafeResource resource; |
| 1187 EXPECT_CALL(*ui_manager_.get(), DisplayBlockingPage(_)) | 1199 EXPECT_CALL(*ui_manager_.get(), DisplayBlockingPage(_)) |
| 1188 .WillOnce(SaveArg<0>(&resource)); | 1200 .WillOnce(SaveArg<0>(&resource)); |
| 1189 | 1201 |
| 1190 NavigateAndCommit(url); | 1202 NavigateAndCommit(url); |
| 1191 WaitAndCheckPreClassificationChecks(); | 1203 WaitAndCheckPreClassificationChecks(); |
| 1192 EXPECT_EQ(url, resource.url); | 1204 EXPECT_EQ(url, resource.url); |
| 1193 EXPECT_EQ(url, resource.original_url); | 1205 EXPECT_EQ(url, resource.original_url); |
| 1194 | 1206 |
| 1195 ExpectStartPhishingDetection(NULL); | 1207 ExpectStartPhishingDetection(NULL); |
| 1196 | 1208 |
| 1197 // Showing a phishing warning will invalidate all the weak pointers which | 1209 // Showing a phishing warning will invalidate all the weak pointers which |
| 1198 // means we will not extract malware features. | 1210 // means we will not extract malware features. |
| 1199 ExpectShouldClassifyForMalwareResult(false); | 1211 ExpectShouldClassifyForMalwareResult(false); |
| 1200 } | 1212 } |
| 1201 } // namespace safe_browsing | 1213 } // namespace safe_browsing |
| OLD | NEW |