| 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 <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // not have any copy constructor which means it can't be stored in a callback | 121 // not have any copy constructor which means it can't be stored in a callback |
| 122 // easily. Note: check will be deleted automatically when the callback is | 122 // easily. Note: check will be deleted automatically when the callback is |
| 123 // deleted. | 123 // deleted. |
| 124 void OnSafeBrowsingResult( | 124 void OnSafeBrowsingResult( |
| 125 SafeBrowsingDatabaseManager::SafeBrowsingCheck* check) { | 125 SafeBrowsingDatabaseManager::SafeBrowsingCheck* check) { |
| 126 check->client->OnSafeBrowsingResult(*check); | 126 check->client->OnSafeBrowsingResult(*check); |
| 127 } | 127 } |
| 128 | 128 |
| 129 ACTION_P(CheckDownloadUrlDone, threat_type) { | 129 ACTION_P(CheckDownloadUrlDone, threat_type) { |
| 130 SafeBrowsingDatabaseManager::SafeBrowsingCheck* check = | 130 SafeBrowsingDatabaseManager::SafeBrowsingCheck* check = |
| 131 new SafeBrowsingDatabaseManager::SafeBrowsingCheck(); | 131 new SafeBrowsingDatabaseManager::SafeBrowsingCheck( |
| 132 safe_browsing_util::BINURL); |
| 132 check->urls = arg0; | 133 check->urls = arg0; |
| 133 check->is_download = true; | 134 for (std::vector<GURL>::iterator it = check->urls.begin(); |
| 134 check->threat_type = threat_type; | 135 it != check->urls.end(); ++it) { |
| 136 check->url_threats[*it] = threat_type; |
| 137 } |
| 135 check->client = arg1; | 138 check->client = arg1; |
| 136 BrowserThread::PostTask(BrowserThread::IO, | 139 BrowserThread::PostTask(BrowserThread::IO, |
| 137 FROM_HERE, | 140 FROM_HERE, |
| 138 base::Bind(&OnSafeBrowsingResult, | 141 base::Bind(&OnSafeBrowsingResult, |
| 139 base::Owned(check))); | 142 base::Owned(check))); |
| 140 } | 143 } |
| 141 | 144 |
| 142 class DownloadProtectionServiceTest : public testing::Test { | 145 class DownloadProtectionServiceTest : public testing::Test { |
| 143 protected: | 146 protected: |
| 144 virtual void SetUp() { | 147 virtual void SetUp() { |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings); | 909 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings); |
| 907 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit")); | 910 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit")); |
| 908 | 911 |
| 909 cert = ReadTestCertificate("test_c.pem"); | 912 cert = ReadTestCertificate("test_c.pem"); |
| 910 ASSERT_TRUE(cert.get()); | 913 ASSERT_TRUE(cert.get()); |
| 911 whitelist_strings.clear(); | 914 whitelist_strings.clear(); |
| 912 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings); | 915 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings); |
| 913 EXPECT_THAT(whitelist_strings, ElementsAre()); | 916 EXPECT_THAT(whitelist_strings, ElementsAre()); |
| 914 } | 917 } |
| 915 } // namespace safe_browsing | 918 } // namespace safe_browsing |
| OLD | NEW |