| 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/download_protection_service.h" | 5 #include "chrome/browser/safe_browsing/download_protection_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 RunLoop run_loop; | 1072 RunLoop run_loop; |
| 1073 download_service_->CheckClientDownload( | 1073 download_service_->CheckClientDownload( |
| 1074 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 1074 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
| 1075 base::Unretained(this), run_loop.QuitClosure())); | 1075 base::Unretained(this), run_loop.QuitClosure())); |
| 1076 run_loop.Run(); | 1076 run_loop.Run(); |
| 1077 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 1077 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
| 1078 EXPECT_TRUE(HasClientDownloadRequest()); | 1078 EXPECT_TRUE(HasClientDownloadRequest()); |
| 1079 ClearClientDownloadRequest(); | 1079 ClearClientDownloadRequest(); |
| 1080 } | 1080 } |
| 1081 { | 1081 { |
| 1082 // Invalid response should result in UNKNOWN. | 1082 // Invalid response should result in SAFE (default value in proto). |
| 1083 ClientDownloadResponse invalid_response; | 1083 ClientDownloadResponse invalid_response; |
| 1084 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(), | 1084 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(), |
| 1085 invalid_response.SerializePartialAsString(), | 1085 invalid_response.SerializePartialAsString(), |
| 1086 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 1086 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 1087 RunLoop run_loop; | 1087 RunLoop run_loop; |
| 1088 download_service_->CheckClientDownload( | 1088 download_service_->CheckClientDownload( |
| 1089 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 1089 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
| 1090 base::Unretained(this), run_loop.QuitClosure())); | 1090 base::Unretained(this), run_loop.QuitClosure())); |
| 1091 run_loop.Run(); | 1091 run_loop.Run(); |
| 1092 EXPECT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); | 1092 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
| 1093 EXPECT_TRUE(HasClientDownloadRequest()); | 1093 EXPECT_TRUE(HasClientDownloadRequest()); |
| 1094 ClearClientDownloadRequest(); | 1094 ClearClientDownloadRequest(); |
| 1095 EXPECT_FALSE(DownloadFeedbackService::GetPingsForDownloadForTesting( | 1095 EXPECT_FALSE(DownloadFeedbackService::GetPingsForDownloadForTesting( |
| 1096 item, &feedback_ping, &feedback_response)); | 1096 item, &feedback_ping, &feedback_response)); |
| 1097 } | 1097 } |
| 1098 { | 1098 { |
| 1099 // If the response is dangerous the result should also be marked as | 1099 // If the response is dangerous the result should also be marked as |
| 1100 // dangerous. | 1100 // dangerous. |
| 1101 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, | 1101 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, |
| 1102 net::URLRequestStatus::SUCCESS); | 1102 net::URLRequestStatus::SUCCESS); |
| (...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2364 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 2364 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
| 2365 base::Unretained(this), run_loop.QuitClosure())); | 2365 base::Unretained(this), run_loop.QuitClosure())); |
| 2366 run_loop.Run(); | 2366 run_loop.Run(); |
| 2367 | 2367 |
| 2368 EXPECT_FALSE(HasClientDownloadRequest()); | 2368 EXPECT_FALSE(HasClientDownloadRequest()); |
| 2369 // Overriden by flag: | 2369 // Overriden by flag: |
| 2370 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | 2370 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
| 2371 } | 2371 } |
| 2372 | 2372 |
| 2373 } // namespace safe_browsing | 2373 } // namespace safe_browsing |
| OLD | NEW |