OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
10 #include "chrome/browser/chromeos/cros/network_library.h" | 10 #include "chrome/browser/chromeos/cros/network_library.h" |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 528 |
529 void WifiConfigView::OnCertificatesLoaded(bool initial_load) { | 529 void WifiConfigView::OnCertificatesLoaded(bool initial_load) { |
530 RefreshEapFields(); | 530 RefreshEapFields(); |
531 UpdateDialogButtons(); | 531 UpdateDialogButtons(); |
532 UpdateErrorLabel(); | 532 UpdateErrorLabel(); |
533 } | 533 } |
534 | 534 |
535 bool WifiConfigView::Login() { | 535 bool WifiConfigView::Login() { |
536 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 536 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
537 if (service_path_.empty()) { | 537 if (service_path_.empty()) { |
| 538 const bool share_default = true; // share networks by default |
538 if (!eap_method_combobox_) { | 539 if (!eap_method_combobox_) { |
539 // Hidden ordinary Wi-Fi connection. | 540 // Hidden ordinary Wi-Fi connection. |
540 ConnectionSecurity security = SECURITY_UNKNOWN; | 541 ConnectionSecurity security = SECURITY_UNKNOWN; |
541 switch (security_combobox_->selected_item()) { | 542 switch (security_combobox_->selected_item()) { |
542 case SECURITY_INDEX_NONE: | 543 case SECURITY_INDEX_NONE: |
543 security = SECURITY_NONE; | 544 security = SECURITY_NONE; |
544 break; | 545 break; |
545 case SECURITY_INDEX_WEP: | 546 case SECURITY_INDEX_WEP: |
546 security = SECURITY_WEP; | 547 security = SECURITY_WEP; |
547 break; | 548 break; |
548 case SECURITY_INDEX_PSK: | 549 case SECURITY_INDEX_PSK: |
549 security = SECURITY_PSK; | 550 security = SECURITY_PSK; |
550 break; | 551 break; |
551 } | 552 } |
552 cros->ConnectToUnconfiguredWifiNetwork( | 553 cros->ConnectToUnconfiguredWifiNetwork( |
553 GetSsid(), | 554 GetSsid(), |
554 security, | 555 security, |
555 GetPassphrase(), | 556 GetPassphrase(), |
556 NULL, | 557 NULL, |
557 GetSaveCredentials(), | 558 GetSaveCredentials(), |
558 GetShareNetwork()); | 559 GetShareNetwork(share_default)); |
559 } else { | 560 } else { |
560 // Hidden 802.1X EAP Wi-Fi connection. | 561 // Hidden 802.1X EAP Wi-Fi connection. |
561 chromeos::NetworkLibrary::EAPConfigData config_data; | 562 chromeos::NetworkLibrary::EAPConfigData config_data; |
562 config_data.method = GetEapMethod(); | 563 config_data.method = GetEapMethod(); |
563 config_data.auth = GetEapPhase2Auth(); | 564 config_data.auth = GetEapPhase2Auth(); |
564 config_data.server_ca_cert_nss_nickname = GetEapServerCaCertNssNickname(); | 565 config_data.server_ca_cert_nss_nickname = GetEapServerCaCertNssNickname(); |
565 config_data.use_system_cas = GetEapUseSystemCas(); | 566 config_data.use_system_cas = GetEapUseSystemCas(); |
566 config_data.client_cert_pkcs11_id = GetEapClientCertPkcs11Id(); | 567 config_data.client_cert_pkcs11_id = GetEapClientCertPkcs11Id(); |
567 config_data.identity = GetEapIdentity(); | 568 config_data.identity = GetEapIdentity(); |
568 config_data.anonymous_identity = GetEapAnonymousIdentity(); | 569 config_data.anonymous_identity = GetEapAnonymousIdentity(); |
569 cros->ConnectToUnconfiguredWifiNetwork( | 570 cros->ConnectToUnconfiguredWifiNetwork( |
570 GetSsid(), | 571 GetSsid(), |
571 SECURITY_8021X, | 572 SECURITY_8021X, |
572 GetPassphrase(), | 573 GetPassphrase(), |
573 &config_data, | 574 &config_data, |
574 GetSaveCredentials(), | 575 GetSaveCredentials(), |
575 GetShareNetwork()); | 576 GetShareNetwork(share_default)); |
576 } | 577 } |
577 } else { | 578 } else { |
578 WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); | 579 WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); |
579 if (!wifi) { | 580 if (!wifi) { |
580 // Flimflam no longer knows about this wifi network (edge case). | 581 // Flimflam no longer knows about this wifi network (edge case). |
581 // TODO(stevenjb): Add a notification (chromium-os13225). | 582 // TODO(stevenjb): Add a notification (chromium-os13225). |
582 LOG(WARNING) << "Wifi network: " << service_path_ << " no longer exists."; | 583 LOG(WARNING) << "Wifi network: " << service_path_ << " no longer exists."; |
583 return true; | 584 return true; |
584 } | 585 } |
585 if (eap_method_combobox_) { | 586 if (eap_method_combobox_) { |
586 // Visible 802.1X EAP Wi-Fi connection. | 587 // Visible 802.1X EAP Wi-Fi connection. |
587 EAPMethod method = GetEapMethod(); | 588 EAPMethod method = GetEapMethod(); |
588 DCHECK(method != EAP_METHOD_UNKNOWN); | 589 DCHECK(method != EAP_METHOD_UNKNOWN); |
589 wifi->SetEAPMethod(method); | 590 wifi->SetEAPMethod(method); |
590 wifi->SetEAPPhase2Auth(GetEapPhase2Auth()); | 591 wifi->SetEAPPhase2Auth(GetEapPhase2Auth()); |
591 wifi->SetEAPServerCaCertNssNickname(GetEapServerCaCertNssNickname()); | 592 wifi->SetEAPServerCaCertNssNickname(GetEapServerCaCertNssNickname()); |
592 wifi->SetEAPUseSystemCAs(GetEapUseSystemCas()); | 593 wifi->SetEAPUseSystemCAs(GetEapUseSystemCas()); |
593 wifi->SetEAPClientCertPkcs11Id(GetEapClientCertPkcs11Id()); | 594 wifi->SetEAPClientCertPkcs11Id(GetEapClientCertPkcs11Id()); |
594 wifi->SetEAPIdentity(GetEapIdentity()); | 595 wifi->SetEAPIdentity(GetEapIdentity()); |
595 wifi->SetEAPAnonymousIdentity(GetEapAnonymousIdentity()); | 596 wifi->SetEAPAnonymousIdentity(GetEapAnonymousIdentity()); |
596 wifi->SetEAPPassphrase(GetPassphrase()); | 597 wifi->SetEAPPassphrase(GetPassphrase()); |
597 wifi->SetSaveCredentials(GetSaveCredentials()); | 598 wifi->SetSaveCredentials(GetSaveCredentials()); |
598 } else { | 599 } else { |
599 // Visible ordinary Wi-Fi connection. | 600 // Visible ordinary Wi-Fi connection. |
600 const std::string passphrase = GetPassphrase(); | 601 const std::string passphrase = GetPassphrase(); |
601 if (passphrase != wifi->passphrase()) | 602 if (passphrase != wifi->passphrase()) |
602 wifi->SetPassphrase(passphrase); | 603 wifi->SetPassphrase(passphrase); |
603 } | 604 } |
604 | 605 bool share_default = (wifi->profile_type() == PROFILE_SHARED); |
605 cros->ConnectToWifiNetwork(wifi, GetShareNetwork()); | 606 cros->ConnectToWifiNetwork(wifi, GetShareNetwork(share_default)); |
606 // Connection failures are responsible for updating the UI, including | 607 // Connection failures are responsible for updating the UI, including |
607 // reopening dialogs. | 608 // reopening dialogs. |
608 } | 609 } |
609 return true; // dialog will be closed | 610 return true; // dialog will be closed |
610 } | 611 } |
611 | 612 |
612 std::string WifiConfigView::GetSsid() const { | 613 std::string WifiConfigView::GetSsid() const { |
613 std::string result; | 614 std::string result; |
614 if (ssid_textfield_ != NULL) { | 615 if (ssid_textfield_ != NULL) { |
615 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); | 616 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); |
616 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); | 617 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); |
617 } | 618 } |
618 return result; | 619 return result; |
619 } | 620 } |
620 | 621 |
621 std::string WifiConfigView::GetPassphrase() const { | 622 std::string WifiConfigView::GetPassphrase() const { |
622 std::string result; | 623 std::string result; |
623 if (passphrase_textfield_ != NULL) | 624 if (passphrase_textfield_ != NULL) |
624 result = UTF16ToUTF8(passphrase_textfield_->text()); | 625 result = UTF16ToUTF8(passphrase_textfield_->text()); |
625 return result; | 626 return result; |
626 } | 627 } |
627 | 628 |
628 bool WifiConfigView::GetSaveCredentials() const { | 629 bool WifiConfigView::GetSaveCredentials() const { |
629 if (!save_credentials_checkbox_) | 630 if (!save_credentials_checkbox_) |
630 return true; // share networks by default (e.g. non 8021x). | 631 return true; // share networks by default (e.g. non 8021x). |
631 return save_credentials_checkbox_->checked(); | 632 return save_credentials_checkbox_->checked(); |
632 } | 633 } |
633 | 634 |
634 bool WifiConfigView::GetShareNetwork() const { | 635 bool WifiConfigView::GetShareNetwork(bool share_default) const { |
635 if (!share_network_checkbox_) | 636 if (!share_network_checkbox_ || !share_network_checkbox_->IsEnabled()) |
636 return true; // share networks by default (e.g. non secure network). | 637 return share_default; |
637 return share_network_checkbox_->checked(); | 638 return share_network_checkbox_->checked(); |
638 } | 639 } |
639 | 640 |
640 EAPMethod WifiConfigView::GetEapMethod() const { | 641 EAPMethod WifiConfigView::GetEapMethod() const { |
641 DCHECK(eap_method_combobox_); | 642 DCHECK(eap_method_combobox_); |
642 switch (eap_method_combobox_->selected_item()) { | 643 switch (eap_method_combobox_->selected_item()) { |
643 case EAP_METHOD_INDEX_NONE: | 644 case EAP_METHOD_INDEX_NONE: |
644 return EAP_METHOD_UNKNOWN; | 645 return EAP_METHOD_UNKNOWN; |
645 case EAP_METHOD_INDEX_PEAP: | 646 case EAP_METHOD_INDEX_PEAP: |
646 return EAP_METHOD_PEAP; | 647 return EAP_METHOD_PEAP; |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 // Set focus to a reasonable widget, depending on what we're showing. | 1053 // Set focus to a reasonable widget, depending on what we're showing. |
1053 if (ssid_textfield_) | 1054 if (ssid_textfield_) |
1054 ssid_textfield_->RequestFocus(); | 1055 ssid_textfield_->RequestFocus(); |
1055 else if (eap_method_combobox_) | 1056 else if (eap_method_combobox_) |
1056 eap_method_combobox_->RequestFocus(); | 1057 eap_method_combobox_->RequestFocus(); |
1057 else if (passphrase_textfield_ && passphrase_textfield_->IsEnabled()) | 1058 else if (passphrase_textfield_ && passphrase_textfield_->IsEnabled()) |
1058 passphrase_textfield_->RequestFocus(); | 1059 passphrase_textfield_->RequestFocus(); |
1059 } | 1060 } |
1060 | 1061 |
1061 } // namespace chromeos | 1062 } // namespace chromeos |
OLD | NEW |