Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/platform_keys/platform_keys_service.h" | 5 #include "chrome/browser/chromeos/platform_keys/platform_keys_service.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 // will be empty. If an error occurred, |matches| will be null and | 491 // will be empty. If an error occurred, |matches| will be null and |
| 492 // |error_message| contain an error message. | 492 // |error_message| contain an error message. |
| 493 void GotMatchingCerts(scoped_ptr<net::CertificateList> matches, | 493 void GotMatchingCerts(scoped_ptr<net::CertificateList> matches, |
| 494 const std::string& error_message) { | 494 const std::string& error_message) { |
| 495 if (!error_message.empty()) { | 495 if (!error_message.empty()) { |
| 496 next_step_ = Step::DONE; | 496 next_step_ = Step::DONE; |
| 497 callback_.Run(nullptr /* no certificates */, error_message); | 497 callback_.Run(nullptr /* no certificates */, error_message); |
| 498 DoStep(); | 498 DoStep(); |
| 499 return; | 499 return; |
| 500 } | 500 } |
| 501 matches_.swap(*matches); | 501 |
| 502 // If the type field does not contain any entries, all certificate types | |
| 503 // shall be returned. | |
| 504 if (request_.certificate_key_types.size() == 0) { | |
| 505 matches_.swap(*matches); | |
| 506 DoStep(); | |
| 507 return; | |
| 508 } | |
| 509 | |
| 510 // Filter the retrieved certificates allowing only those whose type is | |
| 511 // contained in the type list of the certificate request. | |
| 512 for (scoped_refptr<net::X509Certificate>& certificate : *matches) { | |
| 513 net::X509Certificate::PublicKeyType key_type_tmp = | |
|
pneubeck (no reviews)
2015/05/19 10:09:00
maybe key_type_tmp -> actual_key_type
cschuet (SLOW)
2015/05/19 11:36:23
Done.
| |
| 514 net::X509Certificate::kPublicKeyTypeUnknown; | |
| 515 size_t key_size_bits_tmp = 0; | |
|
pneubeck (no reviews)
2015/05/19 10:09:00
maybe s/_tmp//
or maybe call it unused_key_size
cschuet (SLOW)
2015/05/19 11:36:23
Done.
| |
| 516 net::X509Certificate::GetPublicKeyInfo(certificate->os_cert_handle(), | |
| 517 &key_size_bits_tmp, &key_type_tmp); | |
| 518 const std::vector<net::X509Certificate::PublicKeyType>& accepted_types = | |
| 519 request_.certificate_key_types; | |
| 520 if (std::find(accepted_types.begin(), accepted_types.end(), | |
| 521 key_type_tmp) != accepted_types.end()) { | |
| 522 matches_.push_back(certificate.Pass()); | |
| 523 } | |
| 524 } | |
| 502 DoStep(); | 525 DoStep(); |
| 503 } | 526 } |
| 504 | 527 |
| 505 // Calls |service_->select_delegate_->Select()| to select a cert from | 528 // Calls |service_->select_delegate_->Select()| to select a cert from |
| 506 // |matches_|, which will be stored in |selected_cert_|. | 529 // |matches_|, which will be stored in |selected_cert_|. |
| 507 // Will call back to |GotSelection()|. | 530 // Will call back to |GotSelection()|. |
| 508 void SelectCerts() { | 531 void SelectCerts() { |
| 509 CHECK(interactive_); | 532 CHECK(interactive_); |
| 510 if (matches_.empty()) { | 533 if (matches_.empty()) { |
| 511 // Don't show a select dialog if no certificate is matching. | 534 // Don't show a select dialog if no certificate is matching. |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 const GetPlatformKeysCallback& callback, | 784 const GetPlatformKeysCallback& callback, |
| 762 scoped_ptr<base::Value> value) { | 785 scoped_ptr<base::Value> value) { |
| 763 scoped_ptr<KeyEntries> key_entries(new KeyEntries); | 786 scoped_ptr<KeyEntries> key_entries(new KeyEntries); |
| 764 if (value) | 787 if (value) |
| 765 key_entries = KeyEntriesFromState(*value); | 788 key_entries = KeyEntriesFromState(*value); |
| 766 | 789 |
| 767 callback.Run(key_entries.Pass()); | 790 callback.Run(key_entries.Pass()); |
| 768 } | 791 } |
| 769 | 792 |
| 770 } // namespace chromeos | 793 } // namespace chromeos |
| OLD | NEW |