Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/options/certificate_manager_handler.h" | 5 #include "chrome/browser/dom_ui/options/certificate_manager_handler.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/l10n_util_collator.h" | 8 #include "app/l10n_util_collator.h" |
| 9 #include "base/file_util.h" // for FileAccessProvider | 9 #include "base/file_util.h" // for FileAccessProvider |
| 10 #include "base/safe_strerror_posix.h" | 10 #include "base/safe_strerror_posix.h" |
| 11 #include "base/scoped_vector.h" | 11 #include "base/scoped_vector.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browser_thread.h" // for FileAccessProvider | 15 #include "chrome/browser/browser_thread.h" // for FileAccessProvider |
| 16 #include "chrome/browser/certificate_manager_model.h" | 16 #include "chrome/browser/certificate_manager_model.h" |
| 17 #include "chrome/browser/certificate_viewer.h" | 17 #include "chrome/browser/certificate_viewer.h" |
| 18 #include "chrome/browser/gtk/certificate_dialogs.h" | 18 #include "chrome/browser/gtk/certificate_dialogs.h" |
| 19 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
| 20 #include "chrome/browser/tab_contents/tab_contents_view.h" | 20 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 21 #include "chrome/browser/ui/pk11_password_dialog.h" | 21 #include "chrome/browser/ui/crypto_module_password_dialog.h" |
| 22 #include "chrome/common/net/x509_certificate_model.h" | |
|
wtc
2011/01/15 17:40:40
Just curious: why do we need to include x509_certi
mattm
2011/01/19 00:59:34
It snuck in from a different change. Removed.
| |
| 22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 23 #include "net/base/crypto_module.h" | 24 #include "net/base/crypto_module.h" |
| 24 #include "net/base/x509_certificate.h" | 25 #include "net/base/x509_certificate.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 static const char kKeyId[] = "id"; | 29 static const char kKeyId[] = "id"; |
| 29 static const char kSubNodesId[] = "subnodes"; | 30 static const char kSubNodesId[] = "subnodes"; |
| 30 static const char kNameId[] = "name"; | 31 static const char kNameId[] = "name"; |
| 31 static const char kReadOnlyId[] = "readonly"; | 32 static const char kReadOnlyId[] = "readonly"; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 return; | 532 return; |
| 532 } | 533 } |
| 533 | 534 |
| 534 // Currently, we don't support exporting more than one at a time. If we do, | 535 // 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. | 536 // this would need some cleanup to handle unlocking multiple slots. |
| 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::kPK11PasswordCertExport, | 542 browser::kCryptoModulePasswordCertExport, |
| 542 "", // unused. | 543 "", // unused. |
| 543 NewCallback(this, | 544 NewCallback(this, |
| 544 &CertificateManagerHandler::ExportPersonalSlotsUnlocked)); | 545 &CertificateManagerHandler::ExportPersonalSlotsUnlocked)); |
| 545 } | 546 } |
| 546 | 547 |
| 547 void CertificateManagerHandler::ExportPersonalSlotsUnlocked() { | 548 void CertificateManagerHandler::ExportPersonalSlotsUnlocked() { |
| 548 std::string output; | 549 std::string output; |
| 549 int num_exported = certificate_manager_model_->cert_db().ExportToPKCS12( | 550 int num_exported = certificate_manager_model_->cert_db().ExportToPKCS12( |
| 550 selected_cert_list_, | 551 selected_cert_list_, |
| 551 password_, | 552 password_, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 browser::UnlockSlotIfNecessary( |
| 633 module_.get(), | 634 module_.get(), |
| 634 browser::kPK11PasswordCertImport, | 635 browser::kCryptoModulePasswordCertImport, |
| 635 "", // unused. | 636 "", // unused. |
| 636 NewCallback(this, | 637 NewCallback(this, |
| 637 &CertificateManagerHandler::ImportPersonalSlotUnlocked)); | 638 &CertificateManagerHandler::ImportPersonalSlotUnlocked)); |
| 638 } | 639 } |
| 639 | 640 |
| 640 void CertificateManagerHandler::ImportPersonalSlotUnlocked() { | 641 void CertificateManagerHandler::ImportPersonalSlotUnlocked() { |
| 641 int result = certificate_manager_model_->ImportFromPKCS12( | 642 int result = certificate_manager_model_->ImportFromPKCS12( |
| 642 module_, file_data_, password_); | 643 module_, file_data_, password_); |
| 643 ImportExportCleanup(); | 644 ImportExportCleanup(); |
| 644 dom_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss"); | 645 dom_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss"); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 929 StringValue error_value(error); | 930 StringValue error_value(error); |
| 930 dom_ui_->CallJavascriptFunction(L"CertificateImportErrorOverlay.show", | 931 dom_ui_->CallJavascriptFunction(L"CertificateImportErrorOverlay.show", |
| 931 title_value, | 932 title_value, |
| 932 error_value, | 933 error_value, |
| 933 cert_error_list); | 934 cert_error_list); |
| 934 } | 935 } |
| 935 | 936 |
| 936 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { | 937 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { |
| 937 return dom_ui_->tab_contents()->view()->GetTopLevelNativeWindow(); | 938 return dom_ui_->tab_contents()->view()->GetTopLevelNativeWindow(); |
| 938 } | 939 } |
| OLD | NEW |