| 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/views/crypto_module_password_dialog_view.h" | 5 #include "chrome/browser/ui/views/crypto_module_password_dialog_view.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "grit/generated_resources.h" | 8 #include "grit/generated_resources.h" |
| 9 #include "ui/base/events/event.h" | 9 #include "ui/base/events/event.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| 11 #include "ui/views/controls/button/text_button.h" | 11 #include "ui/views/controls/button/text_button.h" |
| 12 #include "ui/views/controls/label.h" | 12 #include "ui/views/controls/label.h" |
| 13 #include "ui/views/controls/textfield/textfield.h" | 13 #include "ui/views/controls/textfield/textfield.h" |
| 14 #include "ui/views/layout/grid_layout.h" | 14 #include "ui/views/layout/grid_layout.h" |
| 15 #include "ui/views/layout/layout_constants.h" | 15 #include "ui/views/layout/layout_constants.h" |
| 16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 17 | 17 |
| 18 namespace browser { | 18 namespace chrome { |
| 19 | 19 |
| 20 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
| 21 // CryptoModulePasswordDialogView, public: | 21 // CryptoModulePasswordDialogView, public: |
| 22 | 22 |
| 23 CryptoModulePasswordDialogView::CryptoModulePasswordDialogView( | 23 CryptoModulePasswordDialogView::CryptoModulePasswordDialogView( |
| 24 const std::string& slot_name, | 24 const std::string& slot_name, |
| 25 CryptoModulePasswordReason reason, | 25 CryptoModulePasswordReason reason, |
| 26 const std::string& server, | 26 const std::string& server, |
| 27 const CryptoModulePasswordCallback& callback) | 27 const CryptoModulePasswordCallback& callback) |
| 28 : callback_(callback) { | 28 : callback_(callback) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 void CryptoModulePasswordDialogView::Init(const std::string& server, | 85 void CryptoModulePasswordDialogView::Init(const std::string& server, |
| 86 const std::string& slot_name, | 86 const std::string& slot_name, |
| 87 CryptoModulePasswordReason reason) { | 87 CryptoModulePasswordReason reason) { |
| 88 // Select an appropriate text for the reason. | 88 // Select an appropriate text for the reason. |
| 89 std::string text; | 89 std::string text; |
| 90 const string16& server16 = UTF8ToUTF16(server); | 90 const string16& server16 = UTF8ToUTF16(server); |
| 91 const string16& slot16 = UTF8ToUTF16(slot_name); | 91 const string16& slot16 = UTF8ToUTF16(slot_name); |
| 92 switch (reason) { | 92 switch (reason) { |
| 93 case browser::kCryptoModulePasswordKeygen: | 93 case chrome::kCryptoModulePasswordKeygen: |
| 94 text = l10n_util::GetStringFUTF8( | 94 text = l10n_util::GetStringFUTF8( |
| 95 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_KEYGEN, slot16, server16); | 95 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_KEYGEN, slot16, server16); |
| 96 break; | 96 break; |
| 97 case browser::kCryptoModulePasswordCertEnrollment: | 97 case chrome::kCryptoModulePasswordCertEnrollment: |
| 98 text = l10n_util::GetStringFUTF8( | 98 text = l10n_util::GetStringFUTF8( |
| 99 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_ENROLLMENT, slot16, server16); | 99 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_ENROLLMENT, slot16, server16); |
| 100 break; | 100 break; |
| 101 case browser::kCryptoModulePasswordClientAuth: | 101 case chrome::kCryptoModulePasswordClientAuth: |
| 102 text = l10n_util::GetStringFUTF8( | 102 text = l10n_util::GetStringFUTF8( |
| 103 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CLIENT_AUTH, slot16, server16); | 103 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CLIENT_AUTH, slot16, server16); |
| 104 break; | 104 break; |
| 105 case browser::kCryptoModulePasswordListCerts: | 105 case chrome::kCryptoModulePasswordListCerts: |
| 106 text = l10n_util::GetStringFUTF8( | 106 text = l10n_util::GetStringFUTF8( |
| 107 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_LIST_CERTS, slot16); | 107 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_LIST_CERTS, slot16); |
| 108 break; | 108 break; |
| 109 case browser::kCryptoModulePasswordCertImport: | 109 case chrome::kCryptoModulePasswordCertImport: |
| 110 text = l10n_util::GetStringFUTF8( | 110 text = l10n_util::GetStringFUTF8( |
| 111 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_IMPORT, slot16); | 111 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_IMPORT, slot16); |
| 112 break; | 112 break; |
| 113 case browser::kCryptoModulePasswordCertExport: | 113 case chrome::kCryptoModulePasswordCertExport: |
| 114 text = l10n_util::GetStringFUTF8( | 114 text = l10n_util::GetStringFUTF8( |
| 115 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_EXPORT, slot16); | 115 IDS_CRYPTO_MODULE_AUTH_DIALOG_TEXT_CERT_EXPORT, slot16); |
| 116 break; | 116 break; |
| 117 default: | 117 default: |
| 118 NOTREACHED(); | 118 NOTREACHED(); |
| 119 } | 119 } |
| 120 reason_label_ = new views::Label(UTF8ToUTF16(text)); | 120 reason_label_ = new views::Label(UTF8ToUTF16(text)); |
| 121 reason_label_->SetMultiLine(true); | 121 reason_label_->SetMultiLine(true); |
| 122 | 122 |
| 123 password_label_ = new views::Label(l10n_util::GetStringUTF16( | 123 password_label_ = new views::Label(l10n_util::GetStringUTF16( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 const std::string& slot_name, | 156 const std::string& slot_name, |
| 157 bool retry, | 157 bool retry, |
| 158 CryptoModulePasswordReason reason, | 158 CryptoModulePasswordReason reason, |
| 159 const std::string& server, | 159 const std::string& server, |
| 160 const CryptoModulePasswordCallback& callback) { | 160 const CryptoModulePasswordCallback& callback) { |
| 161 CryptoModulePasswordDialogView* dialog = | 161 CryptoModulePasswordDialogView* dialog = |
| 162 new CryptoModulePasswordDialogView(slot_name, reason, server, callback); | 162 new CryptoModulePasswordDialogView(slot_name, reason, server, callback); |
| 163 views::Widget::CreateWindow(dialog)->Show(); | 163 views::Widget::CreateWindow(dialog)->Show(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace browser | 166 } // namespace chrome |
| OLD | NEW |