| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 int UserCertComboboxModel::GetItemCount() const { | 322 int UserCertComboboxModel::GetItemCount() const { |
| 323 if (!owner_->UserCertActive()) | 323 if (!owner_->UserCertActive()) |
| 324 return 1; // "None installed" (combobox must have at least 1 entry) | 324 return 1; // "None installed" (combobox must have at least 1 entry) |
| 325 if (CertLibrary::Get()->CertificatesLoading()) | 325 if (CertLibrary::Get()->CertificatesLoading()) |
| 326 return 1; // "Loading" | 326 return 1; // "Loading" |
| 327 int num_certs = | 327 int num_certs = |
| 328 CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER); | 328 CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER); |
| 329 if (num_certs == 0) | 329 if (num_certs == 0) |
| 330 return 1; // "None installed" | 330 return 1; // "None installed" |
| 331 if (owner_->ManagedUserCertNotFound()) |
| 332 return 1; // Empty: no user cert found, but managed (not editable). |
| 331 return num_certs; | 333 return num_certs; |
| 332 } | 334 } |
| 333 | 335 |
| 334 base::string16 UserCertComboboxModel::GetItemAt(int index) { | 336 base::string16 UserCertComboboxModel::GetItemAt(int index) { |
| 335 if (!owner_->UserCertActive()) | 337 if (!owner_->UserCertActive()) |
| 336 return l10n_util::GetStringUTF16( | 338 return l10n_util::GetStringUTF16( |
| 337 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); | 339 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); |
| 338 if (CertLibrary::Get()->CertificatesLoading()) | 340 if (CertLibrary::Get()->CertificatesLoading()) |
| 339 return l10n_util::GetStringUTF16( | 341 return l10n_util::GetStringUTF16( |
| 340 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); | 342 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); |
| 341 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) | 343 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) |
| 342 return l10n_util::GetStringUTF16( | 344 return l10n_util::GetStringUTF16( |
| 343 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); | 345 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); |
| 346 if (owner_->ManagedUserCertNotFound()) |
| 347 return base::string16(); // Empty: no user cert found, but managed (not |
| 348 // editable). |
| 344 return CertLibrary::Get()->GetCertDisplayStringAt( | 349 return CertLibrary::Get()->GetCertDisplayStringAt( |
| 345 CertLibrary::CERT_TYPE_USER, index); | 350 CertLibrary::CERT_TYPE_USER, index); |
| 346 } | 351 } |
| 347 | 352 |
| 348 } // namespace internal | 353 } // namespace internal |
| 349 | 354 |
| 350 WifiConfigView::WifiConfigView(NetworkConfigView* parent, | 355 WifiConfigView::WifiConfigView(NetworkConfigView* parent, |
| 351 const std::string& service_path, | 356 const std::string& service_path, |
| 352 bool show_8021x) | 357 bool show_8021x) |
| 353 : ChildNetworkConfigView(parent, service_path), | 358 : ChildNetworkConfigView(parent, service_path), |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 layout->AddView(subject_match_textfield_, 1, 1, views::GridLayout::FILL, | 1115 layout->AddView(subject_match_textfield_, 1, 1, views::GridLayout::FILL, |
| 1111 views::GridLayout::FILL, 0, | 1116 views::GridLayout::FILL, 0, |
| 1112 ChildNetworkConfigView::kInputFieldHeight); | 1117 ChildNetworkConfigView::kInputFieldHeight); |
| 1113 } else { | 1118 } else { |
| 1114 layout->AddView(subject_match_textfield_); | 1119 layout->AddView(subject_match_textfield_); |
| 1115 } | 1120 } |
| 1116 layout->AddPaddingRow(0, provider->GetDistanceMetric( | 1121 layout->AddPaddingRow(0, provider->GetDistanceMetric( |
| 1117 views::DISTANCE_RELATED_CONTROL_VERTICAL)); | 1122 views::DISTANCE_RELATED_CONTROL_VERTICAL)); |
| 1118 | 1123 |
| 1119 // User certificate | 1124 // User certificate |
| 1125 managed_user_cert_not_found_ = false; |
| 1120 layout->StartRow(0, column_view_set_id); | 1126 layout->StartRow(0, column_view_set_id); |
| 1121 base::string16 user_cert_label_text = l10n_util::GetStringUTF16( | 1127 base::string16 user_cert_label_text = l10n_util::GetStringUTF16( |
| 1122 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT); | 1128 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT); |
| 1123 user_cert_label_ = new views::Label(user_cert_label_text); | 1129 user_cert_label_ = new views::Label(user_cert_label_text); |
| 1124 layout->AddView(user_cert_label_); | 1130 layout->AddView(user_cert_label_); |
| 1125 user_cert_combobox_model_.reset(new internal::UserCertComboboxModel(this)); | 1131 user_cert_combobox_model_.reset(new internal::UserCertComboboxModel(this)); |
| 1126 user_cert_combobox_ = new views::Combobox(user_cert_combobox_model_.get()); | 1132 user_cert_combobox_ = new views::Combobox(user_cert_combobox_model_.get()); |
| 1127 user_cert_combobox_->SetAccessibleName(user_cert_label_text); | 1133 user_cert_combobox_->SetAccessibleName(user_cert_label_text); |
| 1128 user_cert_label_->SetEnabled(false); | 1134 user_cert_label_->SetEnabled(false); |
| 1129 user_cert_combobox_->SetEnabled(false); | 1135 user_cert_combobox_->SetEnabled(false); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 properties.GetStringWithoutPathExpansion( | 1402 properties.GetStringWithoutPathExpansion( |
| 1397 shill::kEapCertIdProperty, &eap_cert_id); | 1403 shill::kEapCertIdProperty, &eap_cert_id); |
| 1398 int unused_slot_id = 0; | 1404 int unused_slot_id = 0; |
| 1399 std::string pkcs11_id = client_cert::GetPkcs11AndSlotIdFromEapCertId( | 1405 std::string pkcs11_id = client_cert::GetPkcs11AndSlotIdFromEapCertId( |
| 1400 eap_cert_id, &unused_slot_id); | 1406 eap_cert_id, &unused_slot_id); |
| 1401 if (!pkcs11_id.empty()) { | 1407 if (!pkcs11_id.empty()) { |
| 1402 int cert_index = | 1408 int cert_index = |
| 1403 CertLibrary::Get()->GetUserCertIndexByPkcs11Id(pkcs11_id); | 1409 CertLibrary::Get()->GetUserCertIndexByPkcs11Id(pkcs11_id); |
| 1404 if (cert_index >= 0) | 1410 if (cert_index >= 0) |
| 1405 user_cert_combobox_->SetSelectedIndex(cert_index); | 1411 user_cert_combobox_->SetSelectedIndex(cert_index); |
| 1412 } else if (!user_cert_ui_data_.IsEditable() && |
| 1413 CertLibrary::Get()->NumCertificates( |
| 1414 CertLibrary::CERT_TYPE_USER) > 0) { |
| 1415 // The cert is not configured (e.g. policy-provided client cert pattern |
| 1416 // did not match anything), and the cert selection is not editable |
| 1417 // (probably because the network is configured by policy). In this case, |
| 1418 // we don't want to display the first certificate in the list, as that |
| 1419 // would be misleading. |
| 1420 managed_user_cert_not_found_ = true; |
| 1421 user_cert_combobox_->ModelChanged(); |
| 1422 user_cert_combobox_->SetSelectedIndex(0); |
| 1406 } | 1423 } |
| 1407 } | 1424 } |
| 1408 | 1425 |
| 1409 // Identity is always active. | 1426 // Identity is always active. |
| 1410 std::string eap_identity; | 1427 std::string eap_identity; |
| 1411 properties.GetStringWithoutPathExpansion( | 1428 properties.GetStringWithoutPathExpansion( |
| 1412 shill::kEapIdentityProperty, &eap_identity); | 1429 shill::kEapIdentityProperty, &eap_identity); |
| 1413 identity_textfield_->SetText(base::UTF8ToUTF16(eap_identity)); | 1430 identity_textfield_->SetText(base::UTF8ToUTF16(eap_identity)); |
| 1414 | 1431 |
| 1415 // Passphrase | 1432 // Passphrase |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 void WifiConfigView::ParseEAPUIProperty(NetworkPropertyUIData* property_ui_data, | 1495 void WifiConfigView::ParseEAPUIProperty(NetworkPropertyUIData* property_ui_data, |
| 1479 const NetworkState* network, | 1496 const NetworkState* network, |
| 1480 const std::string& key) { | 1497 const std::string& key) { |
| 1481 std::string onc_tag = network->type() == shill::kTypeEthernet | 1498 std::string onc_tag = network->type() == shill::kTypeEthernet |
| 1482 ? ::onc::ethernet::kEAP | 1499 ? ::onc::ethernet::kEAP |
| 1483 : ::onc::wifi::kEAP; | 1500 : ::onc::wifi::kEAP; |
| 1484 ParseUIProperty(property_ui_data, network, onc_tag + '.' + key); | 1501 ParseUIProperty(property_ui_data, network, onc_tag + '.' + key); |
| 1485 } | 1502 } |
| 1486 | 1503 |
| 1487 } // namespace chromeos | 1504 } // namespace chromeos |
| OLD | NEW |