Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service_unittest.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 ACTION_P(SetCertificateContents, contents) { 112 ACTION_P(SetCertificateContents, contents) {
113 arg1->add_certificate_chain()->add_element()->set_certificate(contents); 113 arg1->add_certificate_chain()->add_element()->set_certificate(contents);
114 } 114 }
115 115
116 ACTION_P(TrustSignature, certificate_file) { 116 ACTION_P(TrustSignature, certificate_file) {
117 arg1->set_trusted(true); 117 arg1->set_trusted(true);
118 // Add a certificate chain. Note that we add the certificate twice so that 118 // Add a certificate chain. Note that we add the certificate twice so that
119 // it appears as its own issuer. 119 // it appears as its own issuer.
120 std::string cert_data; 120 std::string cert_data;
121 ASSERT_TRUE(file_util::ReadFileToString(certificate_file, &cert_data)); 121 ASSERT_TRUE(base::ReadFileToString(certificate_file, &cert_data));
122 ClientDownloadRequest_CertificateChain* chain = 122 ClientDownloadRequest_CertificateChain* chain =
123 arg1->add_certificate_chain(); 123 arg1->add_certificate_chain();
124 chain->add_element()->set_certificate(cert_data); 124 chain->add_element()->set_certificate(cert_data);
125 chain->add_element()->set_certificate(cert_data); 125 chain->add_element()->set_certificate(cert_data);
126 } 126 }
127 127
128 // We can't call OnSafeBrowsingResult directly because SafeBrowsingCheck does 128 // We can't call OnSafeBrowsingResult directly because SafeBrowsingCheck does
129 // not have any copy constructor which means it can't be stored in a callback 129 // not have any copy constructor which means it can't be stored in a callback
130 // easily. Note: check will be deleted automatically when the callback is 130 // easily. Note: check will be deleted automatically when the callback is
131 // deleted. 131 // deleted.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 std::vector<std::string>* whitelist_strings) { 232 std::vector<std::string>* whitelist_strings) {
233 DownloadProtectionService::GetCertificateWhitelistStrings( 233 DownloadProtectionService::GetCertificateWhitelistStrings(
234 certificate, issuer, whitelist_strings); 234 certificate, issuer, whitelist_strings);
235 } 235 }
236 236
237 // Reads a single PEM-encoded certificate from the testdata directory. 237 // Reads a single PEM-encoded certificate from the testdata directory.
238 // Returns NULL on failure. 238 // Returns NULL on failure.
239 scoped_refptr<net::X509Certificate> ReadTestCertificate( 239 scoped_refptr<net::X509Certificate> ReadTestCertificate(
240 const std::string& filename) { 240 const std::string& filename) {
241 std::string cert_data; 241 std::string cert_data;
242 if (!file_util::ReadFileToString(testdata_path_.AppendASCII(filename), 242 if (!base::ReadFileToString(testdata_path_.AppendASCII(filename),
243 &cert_data)) { 243 &cert_data)) {
244 return NULL; 244 return NULL;
245 } 245 }
246 net::CertificateList certs = 246 net::CertificateList certs =
247 net::X509Certificate::CreateCertificateListFromBytes( 247 net::X509Certificate::CreateCertificateListFromBytes(
248 cert_data.data(), 248 cert_data.data(),
249 cert_data.size(), 249 cert_data.size(),
250 net::X509Certificate::FORMAT_PEM_CERT_SEQUENCE); 250 net::X509Certificate::FORMAT_PEM_CERT_SEQUENCE);
251 return certs.empty() ? NULL : certs[0]; 251 return certs.empty() ? NULL : certs[0];
252 } 252 }
253 253
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit")); 1170 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit"));
1171 1171
1172 cert = ReadTestCertificate("test_c.pem"); 1172 cert = ReadTestCertificate("test_c.pem");
1173 ASSERT_TRUE(cert.get()); 1173 ASSERT_TRUE(cert.get());
1174 whitelist_strings.clear(); 1174 whitelist_strings.clear();
1175 GetCertificateWhitelistStrings( 1175 GetCertificateWhitelistStrings(
1176 *cert.get(), *issuer_cert.get(), &whitelist_strings); 1176 *cert.get(), *issuer_cert.get(), &whitelist_strings);
1177 EXPECT_THAT(whitelist_strings, ElementsAre()); 1177 EXPECT_THAT(whitelist_strings, ElementsAre());
1178 } 1178 }
1179 } // namespace safe_browsing 1179 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698