| 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/webui/options/certificate_manager_handler.h" | 5 #include "chrome/browser/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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 | 525 |
| 526 void CertificateManagerHandler::ExportPersonalPasswordSelected( | 526 void CertificateManagerHandler::ExportPersonalPasswordSelected( |
| 527 const ListValue* args) { | 527 const ListValue* args) { |
| 528 if (!args->GetString(0, &password_)){ | 528 if (!args->GetString(0, &password_)){ |
| 529 web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss"); | 529 web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss"); |
| 530 ImportExportCleanup(); | 530 ImportExportCleanup(); |
| 531 return; | 531 return; |
| 532 } | 532 } |
| 533 | 533 |
| 534 // Currently, we don't support exporting more than one at a time. If we do, | 534 // Currently, we don't support exporting more than one at a time. If we do, |
| 535 // this would need some cleanup to handle unlocking multiple slots. | 535 // this would need to either change this to use UnlockSlotsIfNecessary or |
| 536 // change UnlockCertSlotIfNecessary to take a CertificateList. |
| 536 DCHECK_EQ(selected_cert_list_.size(), 1U); | 537 DCHECK_EQ(selected_cert_list_.size(), 1U); |
| 537 | 538 |
| 538 // TODO(mattm): do something smarter about non-extractable keys | 539 // TODO(mattm): do something smarter about non-extractable keys |
| 539 browser::UnlockCertSlotIfNecessary( | 540 browser::UnlockCertSlotIfNecessary( |
| 540 selected_cert_list_[0].get(), | 541 selected_cert_list_[0].get(), |
| 541 browser::kCryptoModulePasswordCertExport, | 542 browser::kCryptoModulePasswordCertExport, |
| 542 "", // unused. | 543 "", // unused. |
| 543 NewCallback(this, | 544 NewCallback(this, |
| 544 &CertificateManagerHandler::ExportPersonalSlotsUnlocked)); | 545 &CertificateManagerHandler::ExportPersonalSlotsUnlocked)); |
| 545 } | 546 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 l10n_util::GetStringFUTF8(IDS_CERT_MANAGER_READ_ERROR_FORMAT, | 623 l10n_util::GetStringFUTF8(IDS_CERT_MANAGER_READ_ERROR_FORMAT, |
| 623 UTF8ToUTF16(safe_strerror(read_errno)))); | 624 UTF8ToUTF16(safe_strerror(read_errno)))); |
| 624 return; | 625 return; |
| 625 } | 626 } |
| 626 | 627 |
| 627 file_data_ = data; | 628 file_data_ = data; |
| 628 | 629 |
| 629 // TODO(mattm): allow user to choose a slot to import to. | 630 // TODO(mattm): allow user to choose a slot to import to. |
| 630 module_ = certificate_manager_model_->cert_db().GetDefaultModule(); | 631 module_ = certificate_manager_model_->cert_db().GetDefaultModule(); |
| 631 | 632 |
| 632 browser::UnlockSlotIfNecessary( | 633 net::CryptoModuleList modules; |
| 633 module_.get(), | 634 modules.push_back(module_); |
| 635 browser::UnlockSlotsIfNecessary( |
| 636 modules, |
| 634 browser::kCryptoModulePasswordCertImport, | 637 browser::kCryptoModulePasswordCertImport, |
| 635 "", // unused. | 638 "", // unused. |
| 636 NewCallback(this, | 639 NewCallback(this, |
| 637 &CertificateManagerHandler::ImportPersonalSlotUnlocked)); | 640 &CertificateManagerHandler::ImportPersonalSlotUnlocked)); |
| 638 } | 641 } |
| 639 | 642 |
| 640 void CertificateManagerHandler::ImportPersonalSlotUnlocked() { | 643 void CertificateManagerHandler::ImportPersonalSlotUnlocked() { |
| 641 int result = certificate_manager_model_->ImportFromPKCS12( | 644 int result = certificate_manager_model_->ImportFromPKCS12( |
| 642 module_, file_data_, password_); | 645 module_, file_data_, password_); |
| 643 ImportExportCleanup(); | 646 ImportExportCleanup(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 StringValue error_value(error); | 932 StringValue error_value(error); |
| 930 web_ui_->CallJavascriptFunction(L"CertificateImportErrorOverlay.show", | 933 web_ui_->CallJavascriptFunction(L"CertificateImportErrorOverlay.show", |
| 931 title_value, | 934 title_value, |
| 932 error_value, | 935 error_value, |
| 933 cert_error_list); | 936 cert_error_list); |
| 934 } | 937 } |
| 935 | 938 |
| 936 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { | 939 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { |
| 937 return web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(); | 940 return web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(); |
| 938 } | 941 } |
| OLD | NEW |