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/chromeos/options/wifi_config_view.h" | 5 #include "chrome/browser/chromeos/options/wifi_config_view.h" |
6 | 6 |
7 #include "ash/system/chromeos/network/network_connect.h" | 7 #include "ash/system/chromeos/network/network_connect.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 DCHECK(server_ca_cert_combobox_); | 804 DCHECK(server_ca_cert_combobox_); |
805 int index = server_ca_cert_combobox_->selected_index(); | 805 int index = server_ca_cert_combobox_->selected_index(); |
806 if (index == 0) { | 806 if (index == 0) { |
807 // First item is "Default". | 807 // First item is "Default". |
808 return std::string(); | 808 return std::string(); |
809 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { | 809 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { |
810 // Last item is "Do not check". | 810 // Last item is "Do not check". |
811 return std::string(); | 811 return std::string(); |
812 } else { | 812 } else { |
813 int cert_index = index - 1; | 813 int cert_index = index - 1; |
814 return CertLibrary::Get()->GetCertPEMAt( | 814 return CertLibrary::Get()->GetServerCACertPEMAt(cert_index); |
815 CertLibrary::CERT_TYPE_SERVER_CA, cert_index); | |
816 } | 815 } |
817 } | 816 } |
818 | 817 |
819 bool WifiConfigView::GetEapUseSystemCas() const { | 818 bool WifiConfigView::GetEapUseSystemCas() const { |
820 DCHECK(server_ca_cert_combobox_); | 819 DCHECK(server_ca_cert_combobox_); |
821 // Only use system CAs if the first item ("Default") is selected. | 820 // Only use system CAs if the first item ("Default") is selected. |
822 return server_ca_cert_combobox_->selected_index() == 0; | 821 return server_ca_cert_combobox_->selected_index() == 0; |
823 } | 822 } |
824 | 823 |
825 std::string WifiConfigView::GetEapSubjectMatch() const { | 824 std::string WifiConfigView::GetEapSubjectMatch() const { |
826 DCHECK(subject_match_textfield_); | 825 DCHECK(subject_match_textfield_); |
827 return base::UTF16ToUTF8(subject_match_textfield_->text()); | 826 return base::UTF16ToUTF8(subject_match_textfield_->text()); |
828 } | 827 } |
829 | 828 |
830 std::string WifiConfigView::GetEapClientCertPkcs11Id() const { | 829 std::string WifiConfigView::GetEapClientCertPkcs11Id() const { |
831 DCHECK(user_cert_combobox_); | 830 DCHECK(user_cert_combobox_); |
832 if (!HaveUserCerts() || !UserCertActive()) { | 831 if (!HaveUserCerts() || !UserCertActive()) { |
833 return std::string(); // No certificate selected or not required. | 832 return std::string(); // No certificate selected or not required. |
834 } else { | 833 } else { |
835 // Certificates are listed in the order they appear in the model. | 834 // Certificates are listed in the order they appear in the model. |
836 int index = user_cert_combobox_->selected_index(); | 835 int index = user_cert_combobox_->selected_index(); |
837 return CertLibrary::Get()->GetCertPkcs11IdAt( | 836 return CertLibrary::Get()->GetUserCertPkcs11IdAt(index); |
838 CertLibrary::CERT_TYPE_USER, index); | |
839 } | 837 } |
840 } | 838 } |
841 | 839 |
842 std::string WifiConfigView::GetEapIdentity() const { | 840 std::string WifiConfigView::GetEapIdentity() const { |
843 DCHECK(identity_textfield_); | 841 DCHECK(identity_textfield_); |
844 return base::UTF16ToUTF8(identity_textfield_->text()); | 842 return base::UTF16ToUTF8(identity_textfield_->text()); |
845 } | 843 } |
846 | 844 |
847 std::string WifiConfigView::GetEapAnonymousIdentity() const { | 845 std::string WifiConfigView::GetEapAnonymousIdentity() const { |
848 DCHECK(identity_anonymous_textfield_); | 846 DCHECK(identity_anonymous_textfield_); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 if (eap_use_system_cas) { | 1253 if (eap_use_system_cas) { |
1256 // "Default" | 1254 // "Default" |
1257 server_ca_cert_combobox_->SetSelectedIndex(0); | 1255 server_ca_cert_combobox_->SetSelectedIndex(0); |
1258 } else { | 1256 } else { |
1259 // "Do not check". | 1257 // "Do not check". |
1260 server_ca_cert_combobox_->SetSelectedIndex( | 1258 server_ca_cert_combobox_->SetSelectedIndex( |
1261 server_ca_cert_combobox_->model()->GetItemCount() - 1); | 1259 server_ca_cert_combobox_->model()->GetItemCount() - 1); |
1262 } | 1260 } |
1263 } else { | 1261 } else { |
1264 // Select the certificate if available. | 1262 // Select the certificate if available. |
1265 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( | 1263 int cert_index = |
1266 CertLibrary::CERT_TYPE_SERVER_CA, eap_ca_cert_pem); | 1264 CertLibrary::Get()->GetServerCACertIndexByPEM(eap_ca_cert_pem); |
1267 if (cert_index >= 0) { | 1265 if (cert_index >= 0) { |
1268 // Skip item for "Default". | 1266 // Skip item for "Default". |
1269 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); | 1267 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); |
1270 } else { | 1268 } else { |
1271 // "Default" | 1269 // "Default" |
1272 server_ca_cert_combobox_->SetSelectedIndex(0); | 1270 server_ca_cert_combobox_->SetSelectedIndex(0); |
1273 } | 1271 } |
1274 } | 1272 } |
1275 } | 1273 } |
1276 | 1274 |
1277 // User certificate. | 1275 // User certificate. |
1278 if (UserCertActive()) { | 1276 if (UserCertActive()) { |
1279 std::string eap_cert_id; | 1277 std::string eap_cert_id; |
1280 properties.GetStringWithoutPathExpansion( | 1278 properties.GetStringWithoutPathExpansion( |
1281 shill::kEapCertIdProperty, &eap_cert_id); | 1279 shill::kEapCertIdProperty, &eap_cert_id); |
1282 if (!eap_cert_id.empty()) { | 1280 if (!eap_cert_id.empty()) { |
1283 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( | 1281 int cert_index = |
1284 CertLibrary::CERT_TYPE_USER, eap_cert_id); | 1282 CertLibrary::Get()->GetUserCertIndexByPkcs11Id(eap_cert_id); |
1285 if (cert_index >= 0) | 1283 if (cert_index >= 0) |
1286 user_cert_combobox_->SetSelectedIndex(cert_index); | 1284 user_cert_combobox_->SetSelectedIndex(cert_index); |
1287 } | 1285 } |
1288 } | 1286 } |
1289 | 1287 |
1290 // Identity is always active. | 1288 // Identity is always active. |
1291 std::string eap_identity; | 1289 std::string eap_identity; |
1292 properties.GetStringWithoutPathExpansion( | 1290 properties.GetStringWithoutPathExpansion( |
1293 shill::kEapIdentityProperty, &eap_identity); | 1291 shill::kEapIdentityProperty, &eap_identity); |
1294 identity_textfield_->SetText(base::UTF8ToUTF16(eap_identity)); | 1292 identity_textfield_->SetText(base::UTF8ToUTF16(eap_identity)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 void WifiConfigView::ParseWiFiEAPUIProperty( | 1347 void WifiConfigView::ParseWiFiEAPUIProperty( |
1350 NetworkPropertyUIData* property_ui_data, | 1348 NetworkPropertyUIData* property_ui_data, |
1351 const NetworkState* network, | 1349 const NetworkState* network, |
1352 const std::string& key) { | 1350 const std::string& key) { |
1353 ParseWiFiUIProperty( | 1351 ParseWiFiUIProperty( |
1354 property_ui_data, network, | 1352 property_ui_data, network, |
1355 base::StringPrintf("%s.%s", ::onc::wifi::kEAP, key.c_str())); | 1353 base::StringPrintf("%s.%s", ::onc::wifi::kEAP, key.c_str())); |
1356 } | 1354 } |
1357 | 1355 |
1358 } // namespace chromeos | 1356 } // namespace chromeos |
OLD | NEW |