| 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 "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 class Phase2AuthComboboxModel : public ui::ComboboxModel { | 124 class Phase2AuthComboboxModel : public ui::ComboboxModel { |
| 125 public: | 125 public: |
| 126 explicit Phase2AuthComboboxModel(views::Combobox* eap_method_combobox) | 126 explicit Phase2AuthComboboxModel(views::Combobox* eap_method_combobox) |
| 127 : eap_method_combobox_(eap_method_combobox) {} | 127 : eap_method_combobox_(eap_method_combobox) {} |
| 128 virtual ~Phase2AuthComboboxModel() {} | 128 virtual ~Phase2AuthComboboxModel() {} |
| 129 | 129 |
| 130 // Overridden from ui::ComboboxModel: | 130 // Overridden from ui::ComboboxModel: |
| 131 virtual int GetItemCount() const OVERRIDE { | 131 virtual int GetItemCount() const OVERRIDE { |
| 132 switch (eap_method_combobox_->selected_item()) { | 132 switch (eap_method_combobox_->selected_index()) { |
| 133 case EAP_METHOD_INDEX_NONE: | 133 case EAP_METHOD_INDEX_NONE: |
| 134 case EAP_METHOD_INDEX_TLS: | 134 case EAP_METHOD_INDEX_TLS: |
| 135 case EAP_METHOD_INDEX_LEAP: | 135 case EAP_METHOD_INDEX_LEAP: |
| 136 return PHASE_2_AUTH_INDEX_AUTO + 1; | 136 return PHASE_2_AUTH_INDEX_AUTO + 1; |
| 137 case EAP_METHOD_INDEX_PEAP: | 137 case EAP_METHOD_INDEX_PEAP: |
| 138 return PHASE_2_AUTH_INDEX_MSCHAPV2 + 1; | 138 return PHASE_2_AUTH_INDEX_MSCHAPV2 + 1; |
| 139 case EAP_METHOD_INDEX_TTLS: | 139 case EAP_METHOD_INDEX_TTLS: |
| 140 return PHASE_2_AUTH_INDEX_CHAP + 1; | 140 return PHASE_2_AUTH_INDEX_CHAP + 1; |
| 141 } | 141 } |
| 142 NOTREACHED(); | 142 NOTREACHED(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 if (service_path_.empty() && GetSsid().empty()) | 340 if (service_path_.empty() && GetSsid().empty()) |
| 341 return false; | 341 return false; |
| 342 | 342 |
| 343 // If the network requires a passphrase, make sure it is the right length. | 343 // If the network requires a passphrase, make sure it is the right length. |
| 344 if (passphrase_textfield_ != NULL | 344 if (passphrase_textfield_ != NULL |
| 345 && PassphraseActive() | 345 && PassphraseActive() |
| 346 && passphrase_textfield_->text().length() < kMinWirelessPasswordLen) | 346 && passphrase_textfield_->text().length() < kMinWirelessPasswordLen) |
| 347 return false; | 347 return false; |
| 348 | 348 |
| 349 // If we're using EAP, we must have a method. | 349 // If we're using EAP, we must have a method. |
| 350 if (eap_method_combobox_ | 350 if (eap_method_combobox_ && |
| 351 && eap_method_combobox_->selected_item() == EAP_METHOD_INDEX_NONE) | 351 eap_method_combobox_->selected_index() == EAP_METHOD_INDEX_NONE) |
| 352 return false; | 352 return false; |
| 353 | 353 |
| 354 // Block login if certs are required but user has none. | 354 // Block login if certs are required but user has none. |
| 355 if (UserCertRequired() && (!HaveUserCerts() || !IsUserCertValid())) | 355 if (UserCertRequired() && (!HaveUserCerts() || !IsUserCertValid())) |
| 356 return false; | 356 return false; |
| 357 | 357 |
| 358 return true; | 358 return true; |
| 359 } | 359 } |
| 360 | 360 |
| 361 bool WifiConfigView::UserCertRequired() const { | 361 bool WifiConfigView::UserCertRequired() const { |
| 362 if (!cert_library_) | 362 if (!cert_library_) |
| 363 return false; // return false until cert_library_ is initialized. | 363 return false; // return false until cert_library_ is initialized. |
| 364 return UserCertActive(); | 364 return UserCertActive(); |
| 365 } | 365 } |
| 366 | 366 |
| 367 bool WifiConfigView::HaveUserCerts() const { | 367 bool WifiConfigView::HaveUserCerts() const { |
| 368 return cert_library_->GetUserCertificates().Size() > 0; | 368 return cert_library_->GetUserCertificates().Size() > 0; |
| 369 } | 369 } |
| 370 | 370 |
| 371 bool WifiConfigView::IsUserCertValid() const { | 371 bool WifiConfigView::IsUserCertValid() const { |
| 372 if (!UserCertActive()) | 372 if (!UserCertActive()) |
| 373 return false; | 373 return false; |
| 374 int selected = user_cert_combobox_->selected_item(); | 374 int index = user_cert_combobox_->selected_index(); |
| 375 if (selected < 0) | 375 if (index < 0) |
| 376 return false; | 376 return false; |
| 377 // Currently only hardware-backed user certificates are valid. | 377 // Currently only hardware-backed user certificates are valid. |
| 378 if (cert_library_->IsHardwareBacked() && | 378 if (cert_library_->IsHardwareBacked() && |
| 379 !cert_library_->GetUserCertificates().IsHardwareBackedAt(selected)) | 379 !cert_library_->GetUserCertificates().IsHardwareBackedAt(index)) |
| 380 return false; | 380 return false; |
| 381 return true; | 381 return true; |
| 382 } | 382 } |
| 383 | 383 |
| 384 bool WifiConfigView::Phase2AuthActive() const { | 384 bool WifiConfigView::Phase2AuthActive() const { |
| 385 if (phase_2_auth_combobox_) | 385 if (phase_2_auth_combobox_) |
| 386 return phase_2_auth_combobox_->model()->GetItemCount() > 1; | 386 return phase_2_auth_combobox_->model()->GetItemCount() > 1; |
| 387 | |
| 388 return false; | 387 return false; |
| 389 } | 388 } |
| 390 | 389 |
| 391 bool WifiConfigView::PassphraseActive() const { | 390 bool WifiConfigView::PassphraseActive() const { |
| 392 if (eap_method_combobox_) { | 391 if (eap_method_combobox_) { |
| 393 // No password for EAP-TLS. | 392 // No password for EAP-TLS. |
| 394 int selected = eap_method_combobox_->selected_item(); | 393 int index = eap_method_combobox_->selected_index(); |
| 395 return (selected != EAP_METHOD_INDEX_NONE && | 394 return index != EAP_METHOD_INDEX_NONE && index != EAP_METHOD_INDEX_TLS; |
| 396 selected != EAP_METHOD_INDEX_TLS); | |
| 397 } else if (security_combobox_) { | 395 } else if (security_combobox_) { |
| 398 return security_combobox_->selected_item() != SECURITY_INDEX_NONE; | 396 return security_combobox_->selected_index() != SECURITY_INDEX_NONE; |
| 399 } | 397 } |
| 400 | |
| 401 return false; | 398 return false; |
| 402 } | 399 } |
| 403 | 400 |
| 404 bool WifiConfigView::UserCertActive() const { | 401 bool WifiConfigView::UserCertActive() const { |
| 405 // User certs only for EAP-TLS. | 402 // User certs only for EAP-TLS. |
| 406 if (eap_method_combobox_) | 403 if (eap_method_combobox_) |
| 407 return eap_method_combobox_->selected_item() == EAP_METHOD_INDEX_TLS; | 404 return eap_method_combobox_->selected_index() == EAP_METHOD_INDEX_TLS; |
| 408 | 405 |
| 409 return false; | 406 return false; |
| 410 } | 407 } |
| 411 | 408 |
| 412 bool WifiConfigView::CaCertActive() const { | 409 bool WifiConfigView::CaCertActive() const { |
| 413 // No server CA certs for LEAP. | 410 // No server CA certs for LEAP. |
| 414 if (eap_method_combobox_) { | 411 if (eap_method_combobox_) { |
| 415 int selected = eap_method_combobox_->selected_item(); | 412 int index = eap_method_combobox_->selected_index(); |
| 416 return (selected != EAP_METHOD_INDEX_NONE && | 413 return index != EAP_METHOD_INDEX_NONE && index != EAP_METHOD_INDEX_LEAP; |
| 417 selected != EAP_METHOD_INDEX_LEAP); | |
| 418 } | 414 } |
| 419 | |
| 420 return false; | 415 return false; |
| 421 } | 416 } |
| 422 | 417 |
| 423 void WifiConfigView::UpdateDialogButtons() { | 418 void WifiConfigView::UpdateDialogButtons() { |
| 424 parent_->GetDialogClientView()->UpdateDialogButtons(); | 419 parent_->GetDialogClientView()->UpdateDialogButtons(); |
| 425 } | 420 } |
| 426 | 421 |
| 427 void WifiConfigView::RefreshEapFields() { | 422 void WifiConfigView::RefreshEapFields() { |
| 428 DCHECK(cert_library_); | 423 DCHECK(cert_library_); |
| 429 | 424 |
| 430 // If EAP method changes, the phase 2 auth choices may have changed also. | 425 // If EAP method changes, the phase 2 auth choices may have changed also. |
| 431 phase_2_auth_combobox_->ModelChanged(); | 426 phase_2_auth_combobox_->ModelChanged(); |
| 432 phase_2_auth_combobox_->SetSelectedItem(0); | 427 phase_2_auth_combobox_->SetSelectedIndex(0); |
| 433 bool phase_2_auth_enabled = Phase2AuthActive(); | 428 bool phase_2_auth_enabled = Phase2AuthActive(); |
| 434 phase_2_auth_combobox_->SetEnabled(phase_2_auth_enabled && | 429 phase_2_auth_combobox_->SetEnabled(phase_2_auth_enabled && |
| 435 phase_2_auth_ui_data_.editable()); | 430 phase_2_auth_ui_data_.editable()); |
| 436 phase_2_auth_label_->SetEnabled(phase_2_auth_enabled); | 431 phase_2_auth_label_->SetEnabled(phase_2_auth_enabled); |
| 437 | 432 |
| 438 // Passphrase. | 433 // Passphrase. |
| 439 bool passphrase_enabled = PassphraseActive(); | 434 bool passphrase_enabled = PassphraseActive(); |
| 440 passphrase_textfield_->SetEnabled(passphrase_enabled && | 435 passphrase_textfield_->SetEnabled(passphrase_enabled && |
| 441 passphrase_ui_data_.editable()); | 436 passphrase_ui_data_.editable()); |
| 442 passphrase_label_->SetEnabled(passphrase_enabled); | 437 passphrase_label_->SetEnabled(passphrase_enabled); |
| 443 if (!passphrase_enabled) | 438 if (!passphrase_enabled) |
| 444 passphrase_textfield_->SetText(string16()); | 439 passphrase_textfield_->SetText(string16()); |
| 445 | 440 |
| 446 // User cert. | 441 // User cert. |
| 447 bool certs_loading = cert_library_->CertificatesLoading(); | 442 bool certs_loading = cert_library_->CertificatesLoading(); |
| 448 bool user_cert_enabled = UserCertActive(); | 443 bool user_cert_enabled = UserCertActive(); |
| 449 user_cert_label_->SetEnabled(user_cert_enabled); | 444 user_cert_label_->SetEnabled(user_cert_enabled); |
| 450 bool have_user_certs = !certs_loading && HaveUserCerts(); | 445 bool have_user_certs = !certs_loading && HaveUserCerts(); |
| 451 user_cert_combobox_->SetEnabled(user_cert_enabled && | 446 user_cert_combobox_->SetEnabled(user_cert_enabled && |
| 452 have_user_certs && | 447 have_user_certs && |
| 453 user_cert_ui_data_.editable()); | 448 user_cert_ui_data_.editable()); |
| 454 user_cert_combobox_->ModelChanged(); | 449 user_cert_combobox_->ModelChanged(); |
| 455 user_cert_combobox_->SetSelectedItem(0); | 450 user_cert_combobox_->SetSelectedIndex(0); |
| 456 | 451 |
| 457 // Server CA. | 452 // Server CA. |
| 458 bool ca_cert_enabled = CaCertActive(); | 453 bool ca_cert_enabled = CaCertActive(); |
| 459 server_ca_cert_label_->SetEnabled(ca_cert_enabled); | 454 server_ca_cert_label_->SetEnabled(ca_cert_enabled); |
| 460 server_ca_cert_combobox_->SetEnabled(ca_cert_enabled && | 455 server_ca_cert_combobox_->SetEnabled(ca_cert_enabled && |
| 461 !certs_loading && | 456 !certs_loading && |
| 462 server_ca_cert_ui_data_.editable()); | 457 server_ca_cert_ui_data_.editable()); |
| 463 server_ca_cert_combobox_->ModelChanged(); | 458 server_ca_cert_combobox_->ModelChanged(); |
| 464 server_ca_cert_combobox_->SetSelectedItem(0); | 459 server_ca_cert_combobox_->SetSelectedIndex(0); |
| 465 | 460 |
| 466 // No anonymous identity if no phase 2 auth. | 461 // No anonymous identity if no phase 2 auth. |
| 467 bool identity_anonymous_enabled = phase_2_auth_enabled; | 462 bool identity_anonymous_enabled = phase_2_auth_enabled; |
| 468 identity_anonymous_textfield_->SetEnabled( | 463 identity_anonymous_textfield_->SetEnabled( |
| 469 identity_anonymous_enabled && identity_anonymous_ui_data_.editable()); | 464 identity_anonymous_enabled && identity_anonymous_ui_data_.editable()); |
| 470 identity_anonymous_label_->SetEnabled(identity_anonymous_enabled); | 465 identity_anonymous_label_->SetEnabled(identity_anonymous_enabled); |
| 471 if (!identity_anonymous_enabled) | 466 if (!identity_anonymous_enabled) |
| 472 identity_anonymous_textfield_->SetText(string16()); | 467 identity_anonymous_textfield_->SetText(string16()); |
| 473 | 468 |
| 474 RefreshShareCheckbox(); | 469 RefreshShareCheckbox(); |
| 475 } | 470 } |
| 476 | 471 |
| 477 void WifiConfigView::RefreshShareCheckbox() { | 472 void WifiConfigView::RefreshShareCheckbox() { |
| 478 if (!share_network_checkbox_) | 473 if (!share_network_checkbox_) |
| 479 return; | 474 return; |
| 480 | 475 |
| 481 if (security_combobox_ && | 476 if (security_combobox_ && |
| 482 security_combobox_->selected_item() == SECURITY_INDEX_NONE) { | 477 security_combobox_->selected_index() == SECURITY_INDEX_NONE) { |
| 483 share_network_checkbox_->SetEnabled(false); | 478 share_network_checkbox_->SetEnabled(false); |
| 484 share_network_checkbox_->SetChecked(true); | 479 share_network_checkbox_->SetChecked(true); |
| 485 } else if (eap_method_combobox_ && | 480 } else if (eap_method_combobox_ && |
| 486 (eap_method_combobox_->selected_item() == EAP_METHOD_INDEX_TLS || | 481 (eap_method_combobox_->selected_index() == EAP_METHOD_INDEX_TLS || |
| 487 user_cert_combobox_->selected_item() != 0)) { | 482 user_cert_combobox_->selected_index() != 0)) { |
| 488 // Can not share TLS network (requires certificate), or any network where | 483 // Can not share TLS network (requires certificate), or any network where |
| 489 // user certificates are enabled. | 484 // user certificates are enabled. |
| 490 share_network_checkbox_->SetEnabled(false); | 485 share_network_checkbox_->SetEnabled(false); |
| 491 share_network_checkbox_->SetChecked(false); | 486 share_network_checkbox_->SetChecked(false); |
| 492 } else if (!UserManager::Get()->IsUserLoggedIn()) { | 487 } else if (!UserManager::Get()->IsUserLoggedIn()) { |
| 493 // If not logged in, networks must be shared. | 488 // If not logged in, networks must be shared. |
| 494 share_network_checkbox_->SetEnabled(false); | 489 share_network_checkbox_->SetEnabled(false); |
| 495 share_network_checkbox_->SetChecked(true); | 490 share_network_checkbox_->SetChecked(true); |
| 496 } else { | 491 } else { |
| 497 share_network_checkbox_->SetEnabled(true); | 492 share_network_checkbox_->SetEnabled(true); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 UpdateErrorLabel(); | 596 UpdateErrorLabel(); |
| 602 } | 597 } |
| 603 | 598 |
| 604 bool WifiConfigView::Login() { | 599 bool WifiConfigView::Login() { |
| 605 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 600 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 606 if (service_path_.empty()) { | 601 if (service_path_.empty()) { |
| 607 const bool share_default = true; // share networks by default | 602 const bool share_default = true; // share networks by default |
| 608 if (!eap_method_combobox_) { | 603 if (!eap_method_combobox_) { |
| 609 // Hidden ordinary Wi-Fi connection. | 604 // Hidden ordinary Wi-Fi connection. |
| 610 ConnectionSecurity security = SECURITY_UNKNOWN; | 605 ConnectionSecurity security = SECURITY_UNKNOWN; |
| 611 switch (security_combobox_->selected_item()) { | 606 switch (security_combobox_->selected_index()) { |
| 612 case SECURITY_INDEX_NONE: | 607 case SECURITY_INDEX_NONE: |
| 613 security = SECURITY_NONE; | 608 security = SECURITY_NONE; |
| 614 break; | 609 break; |
| 615 case SECURITY_INDEX_WEP: | 610 case SECURITY_INDEX_WEP: |
| 616 security = SECURITY_WEP; | 611 security = SECURITY_WEP; |
| 617 break; | 612 break; |
| 618 case SECURITY_INDEX_PSK: | 613 case SECURITY_INDEX_PSK: |
| 619 security = SECURITY_PSK; | 614 security = SECURITY_PSK; |
| 620 break; | 615 break; |
| 621 } | 616 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 } | 697 } |
| 703 | 698 |
| 704 bool WifiConfigView::GetShareNetwork(bool share_default) const { | 699 bool WifiConfigView::GetShareNetwork(bool share_default) const { |
| 705 if (!share_network_checkbox_) | 700 if (!share_network_checkbox_) |
| 706 return share_default; | 701 return share_default; |
| 707 return share_network_checkbox_->checked(); | 702 return share_network_checkbox_->checked(); |
| 708 } | 703 } |
| 709 | 704 |
| 710 EAPMethod WifiConfigView::GetEapMethod() const { | 705 EAPMethod WifiConfigView::GetEapMethod() const { |
| 711 DCHECK(eap_method_combobox_); | 706 DCHECK(eap_method_combobox_); |
| 712 switch (eap_method_combobox_->selected_item()) { | 707 switch (eap_method_combobox_->selected_index()) { |
| 713 case EAP_METHOD_INDEX_NONE: | 708 case EAP_METHOD_INDEX_NONE: |
| 714 return EAP_METHOD_UNKNOWN; | 709 return EAP_METHOD_UNKNOWN; |
| 715 case EAP_METHOD_INDEX_PEAP: | 710 case EAP_METHOD_INDEX_PEAP: |
| 716 return EAP_METHOD_PEAP; | 711 return EAP_METHOD_PEAP; |
| 717 case EAP_METHOD_INDEX_TLS: | 712 case EAP_METHOD_INDEX_TLS: |
| 718 return EAP_METHOD_TLS; | 713 return EAP_METHOD_TLS; |
| 719 case EAP_METHOD_INDEX_TTLS: | 714 case EAP_METHOD_INDEX_TTLS: |
| 720 return EAP_METHOD_TTLS; | 715 return EAP_METHOD_TTLS; |
| 721 case EAP_METHOD_INDEX_LEAP: | 716 case EAP_METHOD_INDEX_LEAP: |
| 722 return EAP_METHOD_LEAP; | 717 return EAP_METHOD_LEAP; |
| 723 default: | 718 default: |
| 724 return EAP_METHOD_UNKNOWN; | 719 return EAP_METHOD_UNKNOWN; |
| 725 } | 720 } |
| 726 } | 721 } |
| 727 | 722 |
| 728 EAPPhase2Auth WifiConfigView::GetEapPhase2Auth() const { | 723 EAPPhase2Auth WifiConfigView::GetEapPhase2Auth() const { |
| 729 DCHECK(phase_2_auth_combobox_); | 724 DCHECK(phase_2_auth_combobox_); |
| 730 switch (phase_2_auth_combobox_->selected_item()) { | 725 switch (phase_2_auth_combobox_->selected_index()) { |
| 731 case PHASE_2_AUTH_INDEX_AUTO: | 726 case PHASE_2_AUTH_INDEX_AUTO: |
| 732 return EAP_PHASE_2_AUTH_AUTO; | 727 return EAP_PHASE_2_AUTH_AUTO; |
| 733 case PHASE_2_AUTH_INDEX_MD5: | 728 case PHASE_2_AUTH_INDEX_MD5: |
| 734 return EAP_PHASE_2_AUTH_MD5; | 729 return EAP_PHASE_2_AUTH_MD5; |
| 735 case PHASE_2_AUTH_INDEX_MSCHAPV2: | 730 case PHASE_2_AUTH_INDEX_MSCHAPV2: |
| 736 return EAP_PHASE_2_AUTH_MSCHAPV2; | 731 return EAP_PHASE_2_AUTH_MSCHAPV2; |
| 737 case PHASE_2_AUTH_INDEX_MSCHAP: | 732 case PHASE_2_AUTH_INDEX_MSCHAP: |
| 738 return EAP_PHASE_2_AUTH_MSCHAP; | 733 return EAP_PHASE_2_AUTH_MSCHAP; |
| 739 case PHASE_2_AUTH_INDEX_PAP: | 734 case PHASE_2_AUTH_INDEX_PAP: |
| 740 return EAP_PHASE_2_AUTH_PAP; | 735 return EAP_PHASE_2_AUTH_PAP; |
| 741 case PHASE_2_AUTH_INDEX_CHAP: | 736 case PHASE_2_AUTH_INDEX_CHAP: |
| 742 return EAP_PHASE_2_AUTH_CHAP; | 737 return EAP_PHASE_2_AUTH_CHAP; |
| 743 default: | 738 default: |
| 744 return EAP_PHASE_2_AUTH_AUTO; | 739 return EAP_PHASE_2_AUTH_AUTO; |
| 745 } | 740 } |
| 746 } | 741 } |
| 747 | 742 |
| 748 std::string WifiConfigView::GetEapServerCaCertNssNickname() const { | 743 std::string WifiConfigView::GetEapServerCaCertNssNickname() const { |
| 749 DCHECK(server_ca_cert_combobox_); | 744 DCHECK(server_ca_cert_combobox_); |
| 750 DCHECK(cert_library_); | 745 DCHECK(cert_library_); |
| 751 int selected = server_ca_cert_combobox_->selected_item(); | 746 int index = server_ca_cert_combobox_->selected_index(); |
| 752 if (selected == 0) { | 747 if (index == 0) { |
| 753 // First item is "Default". | 748 // First item is "Default". |
| 754 return std::string(); | 749 return std::string(); |
| 755 } else if (selected == | 750 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { |
| 756 server_ca_cert_combobox_->model()->GetItemCount() - 1) { | |
| 757 // Last item is "Do not check". | 751 // Last item is "Do not check". |
| 758 return std::string(); | 752 return std::string(); |
| 759 } else { | 753 } else { |
| 760 DCHECK(cert_library_); | 754 DCHECK(cert_library_); |
| 761 int cert_index = selected - 1; | 755 int cert_index = index - 1; |
| 762 return cert_library_->GetCACertificates().GetNicknameAt(cert_index); | 756 return cert_library_->GetCACertificates().GetNicknameAt(cert_index); |
| 763 } | 757 } |
| 764 } | 758 } |
| 765 | 759 |
| 766 bool WifiConfigView::GetEapUseSystemCas() const { | 760 bool WifiConfigView::GetEapUseSystemCas() const { |
| 767 DCHECK(server_ca_cert_combobox_); | 761 DCHECK(server_ca_cert_combobox_); |
| 768 // Only use system CAs if the first item ("Default") is selected. | 762 // Only use system CAs if the first item ("Default") is selected. |
| 769 return server_ca_cert_combobox_->selected_item() == 0; | 763 return server_ca_cert_combobox_->selected_index() == 0; |
| 770 } | 764 } |
| 771 | 765 |
| 772 std::string WifiConfigView::GetEapClientCertPkcs11Id() const { | 766 std::string WifiConfigView::GetEapClientCertPkcs11Id() const { |
| 773 DCHECK(user_cert_combobox_); | 767 DCHECK(user_cert_combobox_); |
| 774 DCHECK(cert_library_); | 768 DCHECK(cert_library_); |
| 775 if (!HaveUserCerts()) { | 769 if (!HaveUserCerts()) { |
| 776 return std::string(); // "None installed" | 770 return std::string(); // "None installed" |
| 777 } else { | 771 } else { |
| 778 // Certificates are listed in the order they appear in the model. | 772 // Certificates are listed in the order they appear in the model. |
| 779 int selected = user_cert_combobox_->selected_item(); | 773 int index = user_cert_combobox_->selected_index(); |
| 780 return cert_library_->GetUserCertificates().GetPkcs11IdAt(selected); | 774 return cert_library_->GetUserCertificates().GetPkcs11IdAt(index); |
| 781 } | 775 } |
| 782 } | 776 } |
| 783 | 777 |
| 784 std::string WifiConfigView::GetEapIdentity() const { | 778 std::string WifiConfigView::GetEapIdentity() const { |
| 785 DCHECK(identity_textfield_); | 779 DCHECK(identity_textfield_); |
| 786 return UTF16ToUTF8(identity_textfield_->text()); | 780 return UTF16ToUTF8(identity_textfield_->text()); |
| 787 } | 781 } |
| 788 | 782 |
| 789 std::string WifiConfigView::GetEapAnonymousIdentity() const { | 783 std::string WifiConfigView::GetEapAnonymousIdentity() const { |
| 790 DCHECK(identity_anonymous_textfield_); | 784 DCHECK(identity_anonymous_textfield_); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 layout->AddView(error_label_); | 1047 layout->AddView(error_label_); |
| 1054 | 1048 |
| 1055 // Initialize the field and checkbox values. | 1049 // Initialize the field and checkbox values. |
| 1056 | 1050 |
| 1057 // After creating the fields, we set the values. Fields need to be created | 1051 // After creating the fields, we set the values. Fields need to be created |
| 1058 // first because RefreshEapFields() will enable/disable them as appropriate. | 1052 // first because RefreshEapFields() will enable/disable them as appropriate. |
| 1059 if (show_8021x) { | 1053 if (show_8021x) { |
| 1060 EAPMethod eap_method = (wifi ? wifi->eap_method() : EAP_METHOD_UNKNOWN); | 1054 EAPMethod eap_method = (wifi ? wifi->eap_method() : EAP_METHOD_UNKNOWN); |
| 1061 switch (eap_method) { | 1055 switch (eap_method) { |
| 1062 case EAP_METHOD_PEAP: | 1056 case EAP_METHOD_PEAP: |
| 1063 eap_method_combobox_->SetSelectedItem(EAP_METHOD_INDEX_PEAP); | 1057 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP); |
| 1064 break; | 1058 break; |
| 1065 case EAP_METHOD_TTLS: | 1059 case EAP_METHOD_TTLS: |
| 1066 eap_method_combobox_->SetSelectedItem(EAP_METHOD_INDEX_TTLS); | 1060 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS); |
| 1067 break; | 1061 break; |
| 1068 case EAP_METHOD_TLS: | 1062 case EAP_METHOD_TLS: |
| 1069 eap_method_combobox_->SetSelectedItem(EAP_METHOD_INDEX_TLS); | 1063 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TLS); |
| 1070 break; | 1064 break; |
| 1071 case EAP_METHOD_LEAP: | 1065 case EAP_METHOD_LEAP: |
| 1072 eap_method_combobox_->SetSelectedItem(EAP_METHOD_INDEX_LEAP); | 1066 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_LEAP); |
| 1073 break; | 1067 break; |
| 1074 default: | 1068 default: |
| 1075 break; | 1069 break; |
| 1076 } | 1070 } |
| 1077 RefreshEapFields(); | 1071 RefreshEapFields(); |
| 1078 | 1072 |
| 1079 // Phase 2 authentication and anonymous identity. | 1073 // Phase 2 authentication and anonymous identity. |
| 1080 if (Phase2AuthActive()) { | 1074 if (Phase2AuthActive()) { |
| 1081 EAPPhase2Auth eap_phase_2_auth = | 1075 EAPPhase2Auth eap_phase_2_auth = |
| 1082 (wifi ? wifi->eap_phase_2_auth() : EAP_PHASE_2_AUTH_AUTO); | 1076 (wifi ? wifi->eap_phase_2_auth() : EAP_PHASE_2_AUTH_AUTO); |
| 1083 switch (eap_phase_2_auth) { | 1077 switch (eap_phase_2_auth) { |
| 1084 case EAP_PHASE_2_AUTH_MD5: | 1078 case EAP_PHASE_2_AUTH_MD5: |
| 1085 phase_2_auth_combobox_->SetSelectedItem(PHASE_2_AUTH_INDEX_MD5); | 1079 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5); |
| 1086 break; | 1080 break; |
| 1087 case EAP_PHASE_2_AUTH_MSCHAPV2: | 1081 case EAP_PHASE_2_AUTH_MSCHAPV2: |
| 1088 phase_2_auth_combobox_->SetSelectedItem(PHASE_2_AUTH_INDEX_MSCHAPV2); | 1082 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2); |
| 1089 break; | 1083 break; |
| 1090 case EAP_PHASE_2_AUTH_MSCHAP: | 1084 case EAP_PHASE_2_AUTH_MSCHAP: |
| 1091 phase_2_auth_combobox_->SetSelectedItem(PHASE_2_AUTH_INDEX_MSCHAP); | 1085 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP); |
| 1092 break; | 1086 break; |
| 1093 case EAP_PHASE_2_AUTH_PAP: | 1087 case EAP_PHASE_2_AUTH_PAP: |
| 1094 phase_2_auth_combobox_->SetSelectedItem(PHASE_2_AUTH_INDEX_PAP); | 1088 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP); |
| 1095 break; | 1089 break; |
| 1096 case EAP_PHASE_2_AUTH_CHAP: | 1090 case EAP_PHASE_2_AUTH_CHAP: |
| 1097 phase_2_auth_combobox_->SetSelectedItem(PHASE_2_AUTH_INDEX_CHAP); | 1091 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP); |
| 1098 break; | 1092 break; |
| 1099 default: | 1093 default: |
| 1100 break; | 1094 break; |
| 1101 } | 1095 } |
| 1102 | 1096 |
| 1103 const std::string& eap_anonymous_identity = | 1097 const std::string& eap_anonymous_identity = |
| 1104 (wifi ? wifi->eap_anonymous_identity() : std::string()); | 1098 (wifi ? wifi->eap_anonymous_identity() : std::string()); |
| 1105 identity_anonymous_textfield_->SetText( | 1099 identity_anonymous_textfield_->SetText( |
| 1106 UTF8ToUTF16(eap_anonymous_identity)); | 1100 UTF8ToUTF16(eap_anonymous_identity)); |
| 1107 } | 1101 } |
| 1108 | 1102 |
| 1109 // Server CA certificate | 1103 // Server CA certificate. |
| 1110 if (CaCertActive()) { | 1104 if (CaCertActive()) { |
| 1111 const std::string& nss_nickname = | 1105 const std::string& nss_nickname = |
| 1112 (wifi ? wifi->eap_server_ca_cert_nss_nickname() : std::string()); | 1106 (wifi ? wifi->eap_server_ca_cert_nss_nickname() : std::string()); |
| 1113 if (nss_nickname.empty()) { | 1107 if (nss_nickname.empty()) { |
| 1114 if (wifi->eap_use_system_cas()) { | 1108 if (wifi->eap_use_system_cas()) { |
| 1115 // "Default" | 1109 // "Default". |
| 1116 server_ca_cert_combobox_->SetSelectedItem(0); | 1110 server_ca_cert_combobox_->SetSelectedIndex(0); |
| 1117 } else { | 1111 } else { |
| 1118 // "Do not check" | 1112 // "Do not check". |
| 1119 server_ca_cert_combobox_->SetSelectedItem( | 1113 server_ca_cert_combobox_->SetSelectedIndex( |
| 1120 server_ca_cert_combobox_->model()->GetItemCount() - 1); | 1114 server_ca_cert_combobox_->model()->GetItemCount() - 1); |
| 1121 } | 1115 } |
| 1122 } else { | 1116 } else { |
| 1123 // select the certificate if available | 1117 // Select the certificate if available. |
| 1124 int cert_index = | 1118 int cert_index = |
| 1125 cert_library_->GetCACertificates().FindCertByNickname(nss_nickname); | 1119 cert_library_->GetCACertificates().FindCertByNickname(nss_nickname); |
| 1126 if (cert_index >= 0) { | 1120 if (cert_index >= 0) { |
| 1127 // Skip item for "Default" | 1121 // Skip item for "Default". |
| 1128 server_ca_cert_combobox_->SetSelectedItem(1 + cert_index); | 1122 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); |
| 1129 } | 1123 } |
| 1130 } | 1124 } |
| 1131 } | 1125 } |
| 1132 | 1126 |
| 1133 // User certificate | 1127 // User certificate. |
| 1134 if (UserCertActive()) { | 1128 if (UserCertActive()) { |
| 1135 const std::string& pkcs11_id = | 1129 const std::string& pkcs11_id = |
| 1136 (wifi ? wifi->eap_client_cert_pkcs11_id() : std::string()); | 1130 (wifi ? wifi->eap_client_cert_pkcs11_id() : std::string()); |
| 1137 if (!pkcs11_id.empty()) { | 1131 if (!pkcs11_id.empty()) { |
| 1138 int cert_index = | 1132 int cert_index = |
| 1139 cert_library_->GetUserCertificates().FindCertByPkcs11Id(pkcs11_id); | 1133 cert_library_->GetUserCertificates().FindCertByPkcs11Id(pkcs11_id); |
| 1140 if (cert_index >= 0) { | 1134 if (cert_index >= 0) { |
| 1141 user_cert_combobox_->SetSelectedItem(cert_index); | 1135 user_cert_combobox_->SetSelectedIndex(cert_index); |
| 1142 } | 1136 } |
| 1143 } | 1137 } |
| 1144 } | 1138 } |
| 1145 | 1139 |
| 1146 // Identity is always active. | 1140 // Identity is always active. |
| 1147 const std::string& eap_identity = | 1141 const std::string& eap_identity = |
| 1148 (wifi ? wifi->eap_identity() : std::string()); | 1142 (wifi ? wifi->eap_identity() : std::string()); |
| 1149 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); | 1143 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); |
| 1150 | 1144 |
| 1151 // Passphrase | 1145 // Passphrase |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 void WifiConfigView::ParseWiFiEAPUIProperty( | 1178 void WifiConfigView::ParseWiFiEAPUIProperty( |
| 1185 NetworkPropertyUIData* property_ui_data, | 1179 NetworkPropertyUIData* property_ui_data, |
| 1186 Network* network, | 1180 Network* network, |
| 1187 const std::string& key) { | 1181 const std::string& key) { |
| 1188 ParseWiFiUIProperty( | 1182 ParseWiFiUIProperty( |
| 1189 property_ui_data, network, | 1183 property_ui_data, network, |
| 1190 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); | 1184 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); |
| 1191 } | 1185 } |
| 1192 | 1186 |
| 1193 } // namespace chromeos | 1187 } // namespace chromeos |
| OLD | NEW |