Roll v8-i18n 181:182.
[chromium-blink-merge.git] / chromeos / network / certificate_handler.cc
blobd471813a47c8de16e25578856d7a00e6fba810a2
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromeos/network/certificate_handler.h"
7 #include "base/values.h"
8 #include "chromeos/network/onc/onc_certificate_importer.h"
9 #include "chromeos/network/onc/onc_utils.h"
11 namespace chromeos {
13 CertificateHandler::CertificateHandler() {
16 CertificateHandler::~CertificateHandler() {
19 bool CertificateHandler::ImportCertificates(
20 const base::ListValue& certificates,
21 onc::ONCSource source,
22 net::CertificateList* onc_trusted_certificates) {
23 VLOG(2) << "ONC file has " << certificates.GetSize() << " certificates";
25 // Web trust is only granted to certificates imported by the user.
26 bool allow_trust_imports = source == onc::ONC_SOURCE_USER_IMPORT;
27 onc::CertificateImporter cert_importer(allow_trust_imports);
28 if (cert_importer.ParseAndStoreCertificates(
29 certificates, onc_trusted_certificates) !=
30 onc::CertificateImporter::IMPORT_OK) {
31 LOG(ERROR) << "Cannot parse some of the certificates in the ONC from "
32 << onc::GetSourceAsString(source);
33 return false;
35 return true;
38 } // namespace chromeos