| 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/ui/webui/options/certificate_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options/certificate_manager_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 ImportExportCleanup(); | 612 ImportExportCleanup(); |
| 613 return; | 613 return; |
| 614 } | 614 } |
| 615 | 615 |
| 616 // Currently, we don't support exporting more than one at a time. If we do, | 616 // Currently, we don't support exporting more than one at a time. If we do, |
| 617 // this would need to either change this to use UnlockSlotsIfNecessary or | 617 // this would need to either change this to use UnlockSlotsIfNecessary or |
| 618 // change UnlockCertSlotIfNecessary to take a CertificateList. | 618 // change UnlockCertSlotIfNecessary to take a CertificateList. |
| 619 DCHECK_EQ(selected_cert_list_.size(), 1U); | 619 DCHECK_EQ(selected_cert_list_.size(), 1U); |
| 620 | 620 |
| 621 // TODO(mattm): do something smarter about non-extractable keys | 621 // TODO(mattm): do something smarter about non-extractable keys |
| 622 browser::UnlockCertSlotIfNecessary( | 622 chrome::UnlockCertSlotIfNecessary( |
| 623 selected_cert_list_[0].get(), | 623 selected_cert_list_[0].get(), |
| 624 browser::kCryptoModulePasswordCertExport, | 624 chrome::kCryptoModulePasswordCertExport, |
| 625 "", // unused. | 625 "", // unused. |
| 626 base::Bind(&CertificateManagerHandler::ExportPersonalSlotsUnlocked, | 626 base::Bind(&CertificateManagerHandler::ExportPersonalSlotsUnlocked, |
| 627 base::Unretained(this))); | 627 base::Unretained(this))); |
| 628 } | 628 } |
| 629 | 629 |
| 630 void CertificateManagerHandler::ExportPersonalSlotsUnlocked() { | 630 void CertificateManagerHandler::ExportPersonalSlotsUnlocked() { |
| 631 std::string output; | 631 std::string output; |
| 632 int num_exported = certificate_manager_model_->cert_db()->ExportToPKCS12( | 632 int num_exported = certificate_manager_model_->cert_db()->ExportToPKCS12( |
| 633 selected_cert_list_, | 633 selected_cert_list_, |
| 634 password_, | 634 password_, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 file_data_ = data; | 720 file_data_ = data; |
| 721 | 721 |
| 722 if (use_hardware_backed_) { | 722 if (use_hardware_backed_) { |
| 723 module_ = certificate_manager_model_->cert_db()->GetPrivateModule(); | 723 module_ = certificate_manager_model_->cert_db()->GetPrivateModule(); |
| 724 } else { | 724 } else { |
| 725 module_ = certificate_manager_model_->cert_db()->GetPublicModule(); | 725 module_ = certificate_manager_model_->cert_db()->GetPublicModule(); |
| 726 } | 726 } |
| 727 | 727 |
| 728 net::CryptoModuleList modules; | 728 net::CryptoModuleList modules; |
| 729 modules.push_back(module_); | 729 modules.push_back(module_); |
| 730 browser::UnlockSlotsIfNecessary( | 730 chrome::UnlockSlotsIfNecessary( |
| 731 modules, | 731 modules, |
| 732 browser::kCryptoModulePasswordCertImport, | 732 chrome::kCryptoModulePasswordCertImport, |
| 733 "", // unused. | 733 "", // unused. |
| 734 base::Bind(&CertificateManagerHandler::ImportPersonalSlotUnlocked, | 734 base::Bind(&CertificateManagerHandler::ImportPersonalSlotUnlocked, |
| 735 base::Unretained(this))); | 735 base::Unretained(this))); |
| 736 } | 736 } |
| 737 | 737 |
| 738 void CertificateManagerHandler::ImportPersonalSlotUnlocked() { | 738 void CertificateManagerHandler::ImportPersonalSlotUnlocked() { |
| 739 // Determine if the private key should be unextractable after the import. | 739 // Determine if the private key should be unextractable after the import. |
| 740 // We do this by checking the value of |use_hardware_backed_| which is set | 740 // We do this by checking the value of |use_hardware_backed_| which is set |
| 741 // to true if importing into a hardware module. Currently, this only happens | 741 // to true if importing into a hardware module. Currently, this only happens |
| 742 // for Chrome OS when the "Import and Bind" option is chosen. | 742 // for Chrome OS when the "Import and Bind" option is chosen. |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 web_ui()->CallJavascriptFunction("CertificateManager.onCheckTpmTokenReady", | 1086 web_ui()->CallJavascriptFunction("CertificateManager.onCheckTpmTokenReady", |
| 1087 ready); | 1087 ready); |
| 1088 } | 1088 } |
| 1089 #endif | 1089 #endif |
| 1090 | 1090 |
| 1091 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { | 1091 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { |
| 1092 return web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(); | 1092 return web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(); |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 } // namespace options | 1095 } // namespace options |
| OLD | NEW |