| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/certificate_provider/certificate_provide
r_api.h" | 5 #include "chrome/browser/extensions/api/certificate_provider/certificate_provide
r_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/linked_ptr.h" | |
| 14 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 15 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv
ice.h" | 14 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv
ice.h" |
| 16 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv
ice_factory.h" | 15 #include "chrome/browser/chromeos/certificate_provider/certificate_provider_serv
ice_factory.h" |
| 17 #include "chrome/common/extensions/api/certificate_provider.h" | 16 #include "chrome/common/extensions/api/certificate_provider.h" |
| 18 #include "chrome/common/extensions/api/certificate_provider_internal.h" | 17 #include "chrome/common/extensions/api/certificate_provider_internal.h" |
| 19 #include "content/public/common/console_message_level.h" | 18 #include "content/public/common/console_message_level.h" |
| 20 #include "net/cert/x509_certificate.h" | 19 #include "net/cert/x509_certificate.h" |
| 21 #include "net/ssl/ssl_private_key.h" | 20 #include "net/ssl/ssl_private_key.h" |
| 22 | 21 |
| 23 namespace extensions { | 22 namespace extensions { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 52 | 51 |
| 53 if (!params->certificates) { | 52 if (!params->certificates) { |
| 54 // In the public API, the certificates parameter is mandatory. We only run | 53 // In the public API, the certificates parameter is mandatory. We only run |
| 55 // into this case, if the custom binding rejected the reply by the | 54 // into this case, if the custom binding rejected the reply by the |
| 56 // extension. | 55 // extension. |
| 57 return RespondNow(Error(kErrorAborted)); | 56 return RespondNow(Error(kErrorAborted)); |
| 58 } | 57 } |
| 59 | 58 |
| 60 chromeos::certificate_provider::CertificateInfoList cert_infos; | 59 chromeos::certificate_provider::CertificateInfoList cert_infos; |
| 61 std::vector<std::vector<char>> rejected_certificates; | 60 std::vector<std::vector<char>> rejected_certificates; |
| 62 for (linked_ptr<api_cp::CertificateInfo> input_cert_info : | 61 for (const api_cp::CertificateInfo& input_cert_info : *params->certificates) { |
| 63 *params->certificates) { | |
| 64 chromeos::certificate_provider::CertificateInfo parsed_cert_info; | 62 chromeos::certificate_provider::CertificateInfo parsed_cert_info; |
| 65 | 63 |
| 66 if (ParseCertificateInfo(*input_cert_info, &parsed_cert_info)) | 64 if (ParseCertificateInfo(input_cert_info, &parsed_cert_info)) |
| 67 cert_infos.push_back(parsed_cert_info); | 65 cert_infos.push_back(parsed_cert_info); |
| 68 else | 66 else |
| 69 rejected_certificates.push_back(input_cert_info->certificate); | 67 rejected_certificates.push_back(input_cert_info.certificate); |
| 70 } | 68 } |
| 71 | 69 |
| 72 if (service->SetCertificatesProvidedByExtension( | 70 if (service->SetCertificatesProvidedByExtension( |
| 73 extension_id(), params->request_id, cert_infos)) { | 71 extension_id(), params->request_id, cert_infos)) { |
| 74 return RespondNow(ArgumentList( | 72 return RespondNow(ArgumentList( |
| 75 api_cpi::ReportCertificates::Results::Create(rejected_certificates))); | 73 api_cpi::ReportCertificates::Results::Create(rejected_certificates))); |
| 76 } else { | 74 } else { |
| 77 // The custom binding already checks for multiple reports to the same | 75 // The custom binding already checks for multiple reports to the same |
| 78 // request. The only remaining case, why this reply can fail is that the | 76 // request. The only remaining case, why this reply can fail is that the |
| 79 // request timed out. | 77 // request timed out. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 std::vector<uint8_t> signature; | 165 std::vector<uint8_t> signature; |
| 168 // If an error occurred, |signature| will not be set. | 166 // If an error occurred, |signature| will not be set. |
| 169 if (params->signature) | 167 if (params->signature) |
| 170 signature.assign(params->signature->begin(), params->signature->end()); | 168 signature.assign(params->signature->begin(), params->signature->end()); |
| 171 | 169 |
| 172 service->ReplyToSignRequest(extension_id(), params->request_id, signature); | 170 service->ReplyToSignRequest(extension_id(), params->request_id, signature); |
| 173 return RespondNow(NoArguments()); | 171 return RespondNow(NoArguments()); |
| 174 } | 172 } |
| 175 | 173 |
| 176 } // namespace extensions | 174 } // namespace extensions |
| OLD | NEW |