| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_util.h" // for FileAccessProvider | 7 #include "base/file_util.h" // for FileAccessProvider |
| 8 #include "base/safe_strerror_posix.h" | 8 #include "base/safe_strerror_posix.h" |
| 9 #include "base/scoped_vector.h" | 9 #include "base/scoped_vector.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 533 |
| 534 void CertificateManagerHandler::ExportPersonalPasswordSelected( | 534 void CertificateManagerHandler::ExportPersonalPasswordSelected( |
| 535 const ListValue* args) { | 535 const ListValue* args) { |
| 536 if (!args->GetString(0, &password_)){ | 536 if (!args->GetString(0, &password_)){ |
| 537 web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss"); | 537 web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss"); |
| 538 ImportExportCleanup(); | 538 ImportExportCleanup(); |
| 539 return; | 539 return; |
| 540 } | 540 } |
| 541 | 541 |
| 542 // Currently, we don't support exporting more than one at a time. If we do, | 542 // Currently, we don't support exporting more than one at a time. If we do, |
| 543 // this would need some cleanup to handle unlocking multiple slots. | 543 // this would need to either change this to use UnlockSlotsIfNecessary or |
| 544 // change UnlockCertSlotIfNecessary to take a CertificateList. |
| 544 DCHECK_EQ(selected_cert_list_.size(), 1U); | 545 DCHECK_EQ(selected_cert_list_.size(), 1U); |
| 545 | 546 |
| 546 // TODO(mattm): do something smarter about non-extractable keys | 547 // TODO(mattm): do something smarter about non-extractable keys |
| 547 browser::UnlockCertSlotIfNecessary( | 548 browser::UnlockCertSlotIfNecessary( |
| 548 selected_cert_list_[0].get(), | 549 selected_cert_list_[0].get(), |
| 549 browser::kCryptoModulePasswordCertExport, | 550 browser::kCryptoModulePasswordCertExport, |
| 550 "", // unused. | 551 "", // unused. |
| 551 NewCallback(this, | 552 NewCallback(this, |
| 552 &CertificateManagerHandler::ExportPersonalSlotsUnlocked)); | 553 &CertificateManagerHandler::ExportPersonalSlotsUnlocked)); |
| 553 } | 554 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 l10n_util::GetStringFUTF8(IDS_CERT_MANAGER_READ_ERROR_FORMAT, | 631 l10n_util::GetStringFUTF8(IDS_CERT_MANAGER_READ_ERROR_FORMAT, |
| 631 UTF8ToUTF16(safe_strerror(read_errno)))); | 632 UTF8ToUTF16(safe_strerror(read_errno)))); |
| 632 return; | 633 return; |
| 633 } | 634 } |
| 634 | 635 |
| 635 file_data_ = data; | 636 file_data_ = data; |
| 636 | 637 |
| 637 // TODO(mattm): allow user to choose a slot to import to. | 638 // TODO(mattm): allow user to choose a slot to import to. |
| 638 module_ = certificate_manager_model_->cert_db().GetDefaultModule(); | 639 module_ = certificate_manager_model_->cert_db().GetDefaultModule(); |
| 639 | 640 |
| 640 browser::UnlockSlotIfNecessary( | 641 net::CryptoModuleList modules; |
| 641 module_.get(), | 642 modules.push_back(module_); |
| 643 browser::UnlockSlotsIfNecessary( |
| 644 modules, |
| 642 browser::kCryptoModulePasswordCertImport, | 645 browser::kCryptoModulePasswordCertImport, |
| 643 "", // unused. | 646 "", // unused. |
| 644 NewCallback(this, | 647 NewCallback(this, |
| 645 &CertificateManagerHandler::ImportPersonalSlotUnlocked)); | 648 &CertificateManagerHandler::ImportPersonalSlotUnlocked)); |
| 646 } | 649 } |
| 647 | 650 |
| 648 void CertificateManagerHandler::ImportPersonalSlotUnlocked() { | 651 void CertificateManagerHandler::ImportPersonalSlotUnlocked() { |
| 649 int result = certificate_manager_model_->ImportFromPKCS12( | 652 int result = certificate_manager_model_->ImportFromPKCS12( |
| 650 module_, file_data_, password_); | 653 module_, file_data_, password_); |
| 651 ImportExportCleanup(); | 654 ImportExportCleanup(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 StringValue error_value(error); | 940 StringValue error_value(error); |
| 938 web_ui_->CallJavascriptFunction(L"CertificateImportErrorOverlay.show", | 941 web_ui_->CallJavascriptFunction(L"CertificateImportErrorOverlay.show", |
| 939 title_value, | 942 title_value, |
| 940 error_value, | 943 error_value, |
| 941 cert_error_list); | 944 cert_error_list); |
| 942 } | 945 } |
| 943 | 946 |
| 944 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { | 947 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { |
| 945 return web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(); | 948 return web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(); |
| 946 } | 949 } |
| OLD | NEW |