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 "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
8 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chromeos/cros/network_library.h" | |
11 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 11 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
| 12 #include "chrome/browser/chromeos/options/network_connect.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chromeos/login/login_state.h" | 14 #include "chromeos/login/login_state.h" |
| 15 #include "chromeos/network/network_configuration_handler.h" |
| 16 #include "chromeos/network/network_event_log.h" |
| 17 #include "chromeos/network/network_handler.h" |
| 18 #include "chromeos/network/network_state.h" |
| 19 #include "chromeos/network/network_state_handler.h" |
14 #include "chromeos/network/network_ui_data.h" | 20 #include "chromeos/network/network_ui_data.h" |
15 #include "chromeos/network/onc/onc_constants.h" | 21 #include "chromeos/network/onc/onc_constants.h" |
16 #include "grit/chromium_strings.h" | 22 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
18 #include "grit/locale_settings.h" | 24 #include "grit/locale_settings.h" |
19 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
| 26 #include "third_party/cros_system_api/dbus/service_constants.h" |
20 #include "ui/base/events/event.h" | 27 #include "ui/base/events/event.h" |
21 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
23 #include "ui/views/controls/button/checkbox.h" | 30 #include "ui/views/controls/button/checkbox.h" |
24 #include "ui/views/controls/button/image_button.h" | 31 #include "ui/views/controls/button/image_button.h" |
25 #include "ui/views/controls/combobox/combobox.h" | 32 #include "ui/views/controls/combobox/combobox.h" |
26 #include "ui/views/controls/label.h" | 33 #include "ui/views/controls/label.h" |
27 #include "ui/views/controls/textfield/textfield.h" | 34 #include "ui/views/controls/textfield/textfield.h" |
28 #include "ui/views/layout/grid_layout.h" | 35 #include "ui/views/layout/grid_layout.h" |
29 #include "ui/views/layout/layout_constants.h" | 36 #include "ui/views/layout/layout_constants.h" |
30 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
31 #include "ui/views/window/dialog_client_view.h" | 38 #include "ui/views/window/dialog_client_view.h" |
32 | 39 |
33 namespace chromeos { | 40 namespace chromeos { |
34 | 41 |
35 namespace { | 42 namespace { |
36 | 43 |
37 // Returns true if network is known to require 802.1x. | |
38 bool Is8021x(const WifiNetwork* wifi) { | |
39 return wifi && wifi->encrypted() && wifi->encryption() == SECURITY_8021X; | |
40 } | |
41 | |
42 // Combobox that supports a preferred width. Used by Server CA combobox | 44 // Combobox that supports a preferred width. Used by Server CA combobox |
43 // because the strings inside it are too wide. | 45 // because the strings inside it are too wide. |
44 class ComboboxWithWidth : public views::Combobox { | 46 class ComboboxWithWidth : public views::Combobox { |
45 public: | 47 public: |
46 ComboboxWithWidth(ui::ComboboxModel* model, int width) | 48 ComboboxWithWidth(ui::ComboboxModel* model, int width) |
47 : Combobox(model), | 49 : Combobox(model), |
48 width_(width) { | 50 width_(width) { |
49 } | 51 } |
50 virtual ~ComboboxWithWidth() {} | 52 virtual ~ComboboxWithWidth() {} |
51 virtual gfx::Size GetPreferredSize() OVERRIDE { | 53 virtual gfx::Size GetPreferredSize() OVERRIDE { |
(...skipping 26 matching lines...) Expand all Loading... |
78 enum Phase2AuthComboboxIndex { | 80 enum Phase2AuthComboboxIndex { |
79 PHASE_2_AUTH_INDEX_AUTO = 0, // LEAP, EAP-TLS have only this auth. | 81 PHASE_2_AUTH_INDEX_AUTO = 0, // LEAP, EAP-TLS have only this auth. |
80 PHASE_2_AUTH_INDEX_MD5 = 1, | 82 PHASE_2_AUTH_INDEX_MD5 = 1, |
81 PHASE_2_AUTH_INDEX_MSCHAPV2 = 2, // PEAP has up to this auth. | 83 PHASE_2_AUTH_INDEX_MSCHAPV2 = 2, // PEAP has up to this auth. |
82 PHASE_2_AUTH_INDEX_MSCHAP = 3, | 84 PHASE_2_AUTH_INDEX_MSCHAP = 3, |
83 PHASE_2_AUTH_INDEX_PAP = 4, | 85 PHASE_2_AUTH_INDEX_PAP = 4, |
84 PHASE_2_AUTH_INDEX_CHAP = 5, // EAP-TTLS has up to this auth. | 86 PHASE_2_AUTH_INDEX_CHAP = 5, // EAP-TTLS has up to this auth. |
85 PHASE_2_AUTH_INDEX_COUNT = 6 | 87 PHASE_2_AUTH_INDEX_COUNT = 6 |
86 }; | 88 }; |
87 | 89 |
| 90 void ShillError(const std::string& function, |
| 91 const std::string& error_name, |
| 92 scoped_ptr<base::DictionaryValue> error_data) { |
| 93 NET_LOG_ERROR("Shill Error from WifiConfigView: " + error_name, function); |
| 94 } |
| 95 |
88 } // namespace | 96 } // namespace |
89 | 97 |
90 namespace internal { | 98 namespace internal { |
91 | 99 |
92 class SecurityComboboxModel : public ui::ComboboxModel { | 100 class SecurityComboboxModel : public ui::ComboboxModel { |
93 public: | 101 public: |
94 SecurityComboboxModel(); | 102 SecurityComboboxModel(); |
95 virtual ~SecurityComboboxModel(); | 103 virtual ~SecurityComboboxModel(); |
96 | 104 |
97 // Overridden from ui::ComboboxModel: | 105 // Overridden from ui::ComboboxModel: |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); | 323 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); |
316 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) | 324 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) |
317 return l10n_util::GetStringUTF16( | 325 return l10n_util::GetStringUTF16( |
318 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); | 326 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); |
319 return CertLibrary::Get()->GetCertDisplayStringAt( | 327 return CertLibrary::Get()->GetCertDisplayStringAt( |
320 CertLibrary::CERT_TYPE_USER, index); | 328 CertLibrary::CERT_TYPE_USER, index); |
321 } | 329 } |
322 | 330 |
323 } // namespace internal | 331 } // namespace internal |
324 | 332 |
325 WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi) | 333 WifiConfigView::WifiConfigView(NetworkConfigView* parent, |
326 : ChildNetworkConfigView(parent, wifi), | 334 const std::string& service_path, |
| 335 bool show_8021x) |
| 336 : ChildNetworkConfigView(parent, service_path), |
327 ssid_textfield_(NULL), | 337 ssid_textfield_(NULL), |
328 eap_method_combobox_(NULL), | 338 eap_method_combobox_(NULL), |
329 phase_2_auth_label_(NULL), | 339 phase_2_auth_label_(NULL), |
330 phase_2_auth_combobox_(NULL), | 340 phase_2_auth_combobox_(NULL), |
331 user_cert_label_(NULL), | 341 user_cert_label_(NULL), |
332 user_cert_combobox_(NULL), | 342 user_cert_combobox_(NULL), |
333 server_ca_cert_label_(NULL), | 343 server_ca_cert_label_(NULL), |
334 server_ca_cert_combobox_(NULL), | 344 server_ca_cert_combobox_(NULL), |
335 identity_label_(NULL), | 345 identity_label_(NULL), |
336 identity_textfield_(NULL), | 346 identity_textfield_(NULL), |
337 identity_anonymous_label_(NULL), | 347 identity_anonymous_label_(NULL), |
338 identity_anonymous_textfield_(NULL), | 348 identity_anonymous_textfield_(NULL), |
339 save_credentials_checkbox_(NULL), | 349 save_credentials_checkbox_(NULL), |
340 share_network_checkbox_(NULL), | 350 share_network_checkbox_(NULL), |
341 shared_network_label_(NULL), | 351 shared_network_label_(NULL), |
342 security_combobox_(NULL), | 352 security_combobox_(NULL), |
343 passphrase_label_(NULL), | 353 passphrase_label_(NULL), |
344 passphrase_textfield_(NULL), | 354 passphrase_textfield_(NULL), |
345 passphrase_visible_button_(NULL), | 355 passphrase_visible_button_(NULL), |
346 error_label_(NULL) { | 356 error_label_(NULL), |
347 Init(wifi, Is8021x(wifi)); | 357 weak_ptr_factory_(this) { |
348 } | 358 Init(show_8021x); |
349 | |
350 WifiConfigView::WifiConfigView(NetworkConfigView* parent, bool show_8021x) | |
351 : ChildNetworkConfigView(parent), | |
352 ssid_textfield_(NULL), | |
353 eap_method_combobox_(NULL), | |
354 phase_2_auth_label_(NULL), | |
355 phase_2_auth_combobox_(NULL), | |
356 user_cert_label_(NULL), | |
357 user_cert_combobox_(NULL), | |
358 server_ca_cert_label_(NULL), | |
359 server_ca_cert_combobox_(NULL), | |
360 identity_label_(NULL), | |
361 identity_textfield_(NULL), | |
362 identity_anonymous_label_(NULL), | |
363 identity_anonymous_textfield_(NULL), | |
364 save_credentials_checkbox_(NULL), | |
365 share_network_checkbox_(NULL), | |
366 shared_network_label_(NULL), | |
367 security_combobox_(NULL), | |
368 passphrase_label_(NULL), | |
369 passphrase_textfield_(NULL), | |
370 passphrase_visible_button_(NULL), | |
371 error_label_(NULL) { | |
372 Init(NULL, show_8021x); | |
373 } | 359 } |
374 | 360 |
375 WifiConfigView::~WifiConfigView() { | 361 WifiConfigView::~WifiConfigView() { |
376 CertLibrary::Get()->RemoveObserver(this); | 362 CertLibrary::Get()->RemoveObserver(this); |
377 } | 363 } |
378 | 364 |
379 string16 WifiConfigView::GetTitle() const { | 365 string16 WifiConfigView::GetTitle() const { |
380 return l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_JOIN_WIFI_NETWORKS); | 366 return l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_JOIN_WIFI_NETWORKS); |
381 } | 367 } |
382 | 368 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 security_combobox_->selected_index() == SECURITY_INDEX_NONE) { | 520 security_combobox_->selected_index() == SECURITY_INDEX_NONE) { |
535 share_network_checkbox_->SetEnabled(false); | 521 share_network_checkbox_->SetEnabled(false); |
536 share_network_checkbox_->SetChecked(true); | 522 share_network_checkbox_->SetChecked(true); |
537 } else if (eap_method_combobox_ && | 523 } else if (eap_method_combobox_ && |
538 (eap_method_combobox_->selected_index() == EAP_METHOD_INDEX_TLS || | 524 (eap_method_combobox_->selected_index() == EAP_METHOD_INDEX_TLS || |
539 user_cert_combobox_->selected_index() != 0)) { | 525 user_cert_combobox_->selected_index() != 0)) { |
540 // Can not share TLS network (requires certificate), or any network where | 526 // Can not share TLS network (requires certificate), or any network where |
541 // user certificates are enabled. | 527 // user certificates are enabled. |
542 share_network_checkbox_->SetEnabled(false); | 528 share_network_checkbox_->SetEnabled(false); |
543 share_network_checkbox_->SetChecked(false); | 529 share_network_checkbox_->SetChecked(false); |
544 } else if (!LoginState::Get()->IsUserLoggedIn()) { | 530 } else if (!LoginState::Get()->IsUserAuthenticated()) { |
545 // If not logged in, networks must be shared. | 531 // If not logged in as an authenticated user, networks must be shared. |
546 share_network_checkbox_->SetEnabled(false); | 532 share_network_checkbox_->SetEnabled(false); |
547 share_network_checkbox_->SetChecked(true); | 533 share_network_checkbox_->SetChecked(true); |
548 } else { | 534 } else { |
549 share_network_checkbox_->SetEnabled(true); | 535 share_network_checkbox_->SetEnabled(true); |
550 share_network_checkbox_->SetChecked(false); // Default to unshared. | 536 share_network_checkbox_->SetChecked(false); // Default to unshared. |
551 } | 537 } |
552 } | 538 } |
553 | 539 |
554 void WifiConfigView::UpdateErrorLabel() { | 540 void WifiConfigView::UpdateErrorLabel() { |
555 std::string error_msg; | 541 base::string16 error_msg; |
556 if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) { | 542 if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) { |
557 if (!HaveUserCerts()) { | 543 if (!HaveUserCerts()) { |
558 if (!LoginState::Get()->IsUserLoggedIn()) { | 544 if (!LoginState::Get()->IsUserAuthenticated()) { |
559 error_msg = l10n_util::GetStringUTF8( | 545 error_msg = l10n_util::GetStringUTF16( |
560 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT); | 546 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT); |
561 } else { | 547 } else { |
562 error_msg = l10n_util::GetStringUTF8( | 548 error_msg = l10n_util::GetStringUTF16( |
563 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); | 549 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); |
564 } | 550 } |
565 } else if (!IsUserCertValid()) { | 551 } else if (!IsUserCertValid()) { |
566 error_msg = l10n_util::GetStringUTF8( | 552 error_msg = l10n_util::GetStringUTF16( |
567 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); | 553 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); |
568 } | 554 } |
569 } | 555 } |
570 if (error_msg.empty() && !service_path_.empty()) { | 556 if (error_msg.empty() && !service_path_.empty()) { |
571 NetworkLibrary* cros = NetworkLibrary::Get(); | 557 const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()-> |
572 const WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); | 558 GetNetworkState(service_path_); |
573 if (wifi && wifi->failed()) { | 559 if (wifi && wifi->connection_state() == flimflam::kStateFailure) |
574 bool passphrase_empty = wifi->GetPassphrase().empty(); | 560 error_msg = ash::network_connect::ErrorString(wifi->error()); |
575 switch (wifi->error()) { | |
576 case ERROR_BAD_PASSPHRASE: | |
577 if (!passphrase_empty) { | |
578 error_msg = l10n_util::GetStringUTF8( | |
579 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE); | |
580 } | |
581 break; | |
582 case ERROR_BAD_WEPKEY: | |
583 if (!passphrase_empty) { | |
584 error_msg = l10n_util::GetStringUTF8( | |
585 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_WEPKEY); | |
586 } | |
587 break; | |
588 default: | |
589 error_msg = wifi->GetErrorString(); | |
590 break; | |
591 } | |
592 } | |
593 } | 561 } |
594 if (!error_msg.empty()) { | 562 if (!error_msg.empty()) { |
595 error_label_->SetText(UTF8ToUTF16(error_msg)); | 563 error_label_->SetText(error_msg); |
596 error_label_->SetVisible(true); | 564 error_label_->SetVisible(true); |
597 } else { | 565 } else { |
598 error_label_->SetVisible(false); | 566 error_label_->SetVisible(false); |
599 } | 567 } |
600 } | 568 } |
601 | 569 |
602 void WifiConfigView::ContentsChanged(views::Textfield* sender, | 570 void WifiConfigView::ContentsChanged(views::Textfield* sender, |
603 const string16& new_contents) { | 571 const string16& new_contents) { |
604 UpdateDialogButtons(); | 572 UpdateDialogButtons(); |
605 } | 573 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 UpdateErrorLabel(); | 612 UpdateErrorLabel(); |
645 } | 613 } |
646 | 614 |
647 void WifiConfigView::OnCertificatesLoaded(bool initial_load) { | 615 void WifiConfigView::OnCertificatesLoaded(bool initial_load) { |
648 RefreshEapFields(); | 616 RefreshEapFields(); |
649 UpdateDialogButtons(); | 617 UpdateDialogButtons(); |
650 UpdateErrorLabel(); | 618 UpdateErrorLabel(); |
651 } | 619 } |
652 | 620 |
653 bool WifiConfigView::Login() { | 621 bool WifiConfigView::Login() { |
654 NetworkLibrary* cros = NetworkLibrary::Get(); | 622 const bool share_default = true; |
655 if (service_path_.empty()) { | 623 if (service_path_.empty()) { |
656 const bool share_default = true; // share networks by default | 624 // Set configuration properties. |
| 625 base::DictionaryValue properties; |
| 626 properties.SetStringWithoutPathExpansion( |
| 627 flimflam::kTypeProperty, flimflam::kTypeWifi); |
| 628 properties.SetStringWithoutPathExpansion( |
| 629 flimflam::kSSIDProperty, GetSsid()); |
| 630 properties.SetStringWithoutPathExpansion( |
| 631 flimflam::kModeProperty, flimflam::kModeManaged); |
| 632 properties.SetBooleanWithoutPathExpansion( |
| 633 flimflam::kSaveCredentialsProperty, GetSaveCredentials()); |
| 634 std::string security = flimflam::kSecurityNone; |
657 if (!eap_method_combobox_) { | 635 if (!eap_method_combobox_) { |
658 // Hidden ordinary Wi-Fi connection. | 636 // Hidden ordinary Wi-Fi connection. |
659 ConnectionSecurity security = SECURITY_UNKNOWN; | |
660 switch (security_combobox_->selected_index()) { | 637 switch (security_combobox_->selected_index()) { |
661 case SECURITY_INDEX_NONE: | 638 case SECURITY_INDEX_NONE: |
662 security = SECURITY_NONE; | 639 security = flimflam::kSecurityNone; |
663 break; | 640 break; |
664 case SECURITY_INDEX_WEP: | 641 case SECURITY_INDEX_WEP: |
665 security = SECURITY_WEP; | 642 security = flimflam::kSecurityWep; |
666 break; | 643 break; |
667 case SECURITY_INDEX_PSK: | 644 case SECURITY_INDEX_PSK: |
668 security = SECURITY_PSK; | 645 security = flimflam::kSecurityPsk; |
669 break; | 646 break; |
670 } | 647 } |
671 cros->ConnectToUnconfiguredWifiNetwork( | 648 std::string passphrase = GetPassphrase(); |
672 GetSsid(), | 649 if (!passphrase.empty()) { |
673 security, | 650 properties.SetStringWithoutPathExpansion( |
674 GetPassphrase(), | 651 flimflam::kPassphraseProperty, GetPassphrase()); |
675 NULL, | 652 } |
676 GetSaveCredentials(), | |
677 GetShareNetwork(share_default)); | |
678 } else { | 653 } else { |
679 // Hidden 802.1X EAP Wi-Fi connection. | 654 // Hidden 802.1X EAP Wi-Fi connection. |
680 chromeos::NetworkLibrary::EAPConfigData config_data; | 655 security = flimflam::kSecurity8021x; |
681 config_data.method = GetEapMethod(); | 656 SetEapProperties(&properties); |
682 config_data.auth = GetEapPhase2Auth(); | |
683 config_data.server_ca_cert_pem = GetEapServerCaCertPEM(); | |
684 config_data.use_system_cas = GetEapUseSystemCas(); | |
685 config_data.client_cert_pkcs11_id = GetEapClientCertPkcs11Id(); | |
686 config_data.identity = GetEapIdentity(); | |
687 config_data.anonymous_identity = GetEapAnonymousIdentity(); | |
688 cros->ConnectToUnconfiguredWifiNetwork( | |
689 GetSsid(), | |
690 SECURITY_8021X, | |
691 GetPassphrase(), | |
692 &config_data, | |
693 GetSaveCredentials(), | |
694 GetShareNetwork(share_default)); | |
695 } | 657 } |
| 658 properties.SetStringWithoutPathExpansion( |
| 659 flimflam::kSecurityProperty, security); |
| 660 |
| 661 // Configure and connect to network. |
| 662 bool shared = GetShareNetwork(share_default); |
| 663 ash::network_connect::CreateConfigurationAndConnect(&properties, shared); |
696 } else { | 664 } else { |
697 WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); | 665 const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()-> |
| 666 GetNetworkState(service_path_); |
698 if (!wifi) { | 667 if (!wifi) { |
699 // Shill no longer knows about this wifi network (edge case). | 668 // Shill no longer knows about this wifi network (edge case). |
700 // TODO(stevenjb): Add a notification (chromium-os13225). | 669 // TODO(stevenjb): Add notification for this. |
701 LOG(WARNING) << "Wifi network: " << service_path_ << " no longer exists."; | 670 NET_LOG_ERROR("Network not found", service_path_); |
702 return true; | 671 return true; // Close dialog |
703 } | 672 } |
| 673 base::DictionaryValue properties; |
704 if (eap_method_combobox_) { | 674 if (eap_method_combobox_) { |
705 // Visible 802.1X EAP Wi-Fi connection. | 675 // Visible 802.1X EAP Wi-Fi connection. |
706 EAPMethod method = GetEapMethod(); | 676 SetEapProperties(&properties); |
707 DCHECK(method != EAP_METHOD_UNKNOWN); | 677 properties.SetBooleanWithoutPathExpansion( |
708 wifi->SetEAPMethod(method); | 678 flimflam::kSaveCredentialsProperty, GetSaveCredentials()); |
709 wifi->SetEAPPhase2Auth(GetEapPhase2Auth()); | |
710 wifi->SetEAPServerCaCertPEM(GetEapServerCaCertPEM()); | |
711 wifi->SetEAPUseSystemCAs(GetEapUseSystemCas()); | |
712 wifi->SetEAPClientCertPkcs11Id(GetEapClientCertPkcs11Id()); | |
713 wifi->SetEAPIdentity(GetEapIdentity()); | |
714 wifi->SetEAPAnonymousIdentity(GetEapAnonymousIdentity()); | |
715 wifi->SetEAPPassphrase(GetPassphrase()); | |
716 wifi->SetSaveCredentials(GetSaveCredentials()); | |
717 } else { | 679 } else { |
718 // Visible ordinary Wi-Fi connection. | 680 // Visible ordinary Wi-Fi connection. |
719 const std::string passphrase = GetPassphrase(); | 681 const std::string passphrase = GetPassphrase(); |
720 if (passphrase != wifi->passphrase()) | 682 if (!passphrase.empty()) { |
721 wifi->SetPassphrase(passphrase); | 683 properties.SetStringWithoutPathExpansion( |
| 684 flimflam::kPassphraseProperty, passphrase); |
| 685 } |
722 } | 686 } |
723 bool share_default = (wifi->profile_type() != PROFILE_USER); | 687 bool share_network = GetShareNetwork(share_default); |
724 wifi->SetEnrollmentDelegate( | 688 ash::network_connect::ConfigureNetworkAndConnect( |
725 CreateEnrollmentDelegate(GetWidget()->GetNativeWindow(), | 689 service_path_, properties, share_network); |
726 wifi->name(), | |
727 ProfileManager::GetLastUsedProfile())); | |
728 cros->ConnectToWifiNetwork(wifi, GetShareNetwork(share_default)); | |
729 // Connection failures are responsible for updating the UI, including | |
730 // reopening dialogs. | |
731 } | 690 } |
732 return true; // dialog will be closed | 691 return true; // dialog will be closed |
733 } | 692 } |
734 | 693 |
735 std::string WifiConfigView::GetSsid() const { | 694 std::string WifiConfigView::GetSsid() const { |
736 std::string result; | 695 std::string result; |
737 if (ssid_textfield_ != NULL) { | 696 if (ssid_textfield_ != NULL) { |
738 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); | 697 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); |
739 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); | 698 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); |
740 } | 699 } |
(...skipping 12 matching lines...) Expand all Loading... |
753 return true; // share networks by default (e.g. non 8021x). | 712 return true; // share networks by default (e.g. non 8021x). |
754 return save_credentials_checkbox_->checked(); | 713 return save_credentials_checkbox_->checked(); |
755 } | 714 } |
756 | 715 |
757 bool WifiConfigView::GetShareNetwork(bool share_default) const { | 716 bool WifiConfigView::GetShareNetwork(bool share_default) const { |
758 if (!share_network_checkbox_) | 717 if (!share_network_checkbox_) |
759 return share_default; | 718 return share_default; |
760 return share_network_checkbox_->checked(); | 719 return share_network_checkbox_->checked(); |
761 } | 720 } |
762 | 721 |
763 EAPMethod WifiConfigView::GetEapMethod() const { | 722 std::string WifiConfigView::GetEapMethod() const { |
764 DCHECK(eap_method_combobox_); | 723 DCHECK(eap_method_combobox_); |
765 switch (eap_method_combobox_->selected_index()) { | 724 switch (eap_method_combobox_->selected_index()) { |
| 725 case EAP_METHOD_INDEX_PEAP: |
| 726 return flimflam::kEapMethodPEAP; |
| 727 case EAP_METHOD_INDEX_TLS: |
| 728 return flimflam::kEapMethodTLS; |
| 729 case EAP_METHOD_INDEX_TTLS: |
| 730 return flimflam::kEapMethodTTLS; |
| 731 case EAP_METHOD_INDEX_LEAP: |
| 732 return flimflam::kEapMethodLEAP; |
766 case EAP_METHOD_INDEX_NONE: | 733 case EAP_METHOD_INDEX_NONE: |
767 return EAP_METHOD_UNKNOWN; | |
768 case EAP_METHOD_INDEX_PEAP: | |
769 return EAP_METHOD_PEAP; | |
770 case EAP_METHOD_INDEX_TLS: | |
771 return EAP_METHOD_TLS; | |
772 case EAP_METHOD_INDEX_TTLS: | |
773 return EAP_METHOD_TTLS; | |
774 case EAP_METHOD_INDEX_LEAP: | |
775 return EAP_METHOD_LEAP; | |
776 default: | 734 default: |
777 return EAP_METHOD_UNKNOWN; | 735 return ""; |
778 } | 736 } |
779 } | 737 } |
780 | 738 |
781 EAPPhase2Auth WifiConfigView::GetEapPhase2Auth() const { | 739 std::string WifiConfigView::GetEapPhase2Auth() const { |
782 DCHECK(phase_2_auth_combobox_); | 740 DCHECK(phase_2_auth_combobox_); |
| 741 bool is_peap = (GetEapMethod() == flimflam::kEapMethodPEAP); |
783 switch (phase_2_auth_combobox_->selected_index()) { | 742 switch (phase_2_auth_combobox_->selected_index()) { |
| 743 case PHASE_2_AUTH_INDEX_MD5: |
| 744 return is_peap ? flimflam::kEapPhase2AuthPEAPMD5 |
| 745 : flimflam::kEapPhase2AuthTTLSMD5; |
| 746 case PHASE_2_AUTH_INDEX_MSCHAPV2: |
| 747 return is_peap ? flimflam::kEapPhase2AuthPEAPMSCHAPV2 |
| 748 : flimflam::kEapPhase2AuthTTLSMSCHAPV2; |
| 749 case PHASE_2_AUTH_INDEX_MSCHAP: |
| 750 return flimflam::kEapPhase2AuthTTLSMSCHAP; |
| 751 case PHASE_2_AUTH_INDEX_PAP: |
| 752 return flimflam::kEapPhase2AuthTTLSPAP; |
| 753 case PHASE_2_AUTH_INDEX_CHAP: |
| 754 return flimflam::kEapPhase2AuthTTLSCHAP; |
784 case PHASE_2_AUTH_INDEX_AUTO: | 755 case PHASE_2_AUTH_INDEX_AUTO: |
785 return EAP_PHASE_2_AUTH_AUTO; | |
786 case PHASE_2_AUTH_INDEX_MD5: | |
787 return EAP_PHASE_2_AUTH_MD5; | |
788 case PHASE_2_AUTH_INDEX_MSCHAPV2: | |
789 return EAP_PHASE_2_AUTH_MSCHAPV2; | |
790 case PHASE_2_AUTH_INDEX_MSCHAP: | |
791 return EAP_PHASE_2_AUTH_MSCHAP; | |
792 case PHASE_2_AUTH_INDEX_PAP: | |
793 return EAP_PHASE_2_AUTH_PAP; | |
794 case PHASE_2_AUTH_INDEX_CHAP: | |
795 return EAP_PHASE_2_AUTH_CHAP; | |
796 default: | 756 default: |
797 return EAP_PHASE_2_AUTH_AUTO; | 757 return ""; |
798 } | 758 } |
799 } | 759 } |
800 | 760 |
801 std::string WifiConfigView::GetEapServerCaCertPEM() const { | 761 std::string WifiConfigView::GetEapServerCaCertPEM() const { |
802 DCHECK(server_ca_cert_combobox_); | 762 DCHECK(server_ca_cert_combobox_); |
803 int index = server_ca_cert_combobox_->selected_index(); | 763 int index = server_ca_cert_combobox_->selected_index(); |
804 if (index == 0) { | 764 if (index == 0) { |
805 // First item is "Default". | 765 // First item is "Default". |
806 return std::string(); | 766 return std::string(); |
807 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { | 767 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { |
(...skipping 27 matching lines...) Expand all Loading... |
835 std::string WifiConfigView::GetEapIdentity() const { | 795 std::string WifiConfigView::GetEapIdentity() const { |
836 DCHECK(identity_textfield_); | 796 DCHECK(identity_textfield_); |
837 return UTF16ToUTF8(identity_textfield_->text()); | 797 return UTF16ToUTF8(identity_textfield_->text()); |
838 } | 798 } |
839 | 799 |
840 std::string WifiConfigView::GetEapAnonymousIdentity() const { | 800 std::string WifiConfigView::GetEapAnonymousIdentity() const { |
841 DCHECK(identity_anonymous_textfield_); | 801 DCHECK(identity_anonymous_textfield_); |
842 return UTF16ToUTF8(identity_anonymous_textfield_->text()); | 802 return UTF16ToUTF8(identity_anonymous_textfield_->text()); |
843 } | 803 } |
844 | 804 |
| 805 void WifiConfigView::SetEapProperties(base::DictionaryValue* properties) { |
| 806 properties->SetStringWithoutPathExpansion( |
| 807 flimflam::kEapIdentityProperty, GetEapIdentity()); |
| 808 properties->SetStringWithoutPathExpansion( |
| 809 flimflam::kEapMethodProperty, GetEapMethod()); |
| 810 properties->SetStringWithoutPathExpansion( |
| 811 flimflam::kEapPhase2AuthProperty, GetEapPhase2Auth()); |
| 812 properties->SetStringWithoutPathExpansion( |
| 813 flimflam::kEapAnonymousIdentityProperty, GetEapAnonymousIdentity()); |
| 814 |
| 815 // shill requires both CertID and KeyID for TLS connections, despite |
| 816 // the fact that by convention they are the same ID. |
| 817 properties->SetStringWithoutPathExpansion( |
| 818 flimflam::kEapCertIdProperty, GetEapClientCertPkcs11Id()); |
| 819 properties->SetStringWithoutPathExpansion( |
| 820 flimflam::kEapKeyIdProperty, GetEapClientCertPkcs11Id()); |
| 821 |
| 822 properties->SetBooleanWithoutPathExpansion( |
| 823 flimflam::kEapUseSystemCasProperty, GetEapUseSystemCas()); |
| 824 properties->SetStringWithoutPathExpansion( |
| 825 flimflam::kEapPasswordProperty, GetPassphrase()); |
| 826 |
| 827 base::ListValue* pem_list = new base::ListValue; |
| 828 pem_list->AppendString(GetEapServerCaCertPEM()); |
| 829 properties->SetWithoutPathExpansion( |
| 830 shill::kEapCaCertPemProperty, pem_list); |
| 831 } |
| 832 |
845 void WifiConfigView::Cancel() { | 833 void WifiConfigView::Cancel() { |
846 } | 834 } |
847 | 835 |
848 // This will initialize the view depending on if we have a wifi network or not. | 836 // This will initialize the view depending on if we have a wifi network or not. |
849 // And if we are doing simple password encryption or the more complicated | 837 // And if we are doing simple password encryption or the more complicated |
850 // 802.1x encryption. | 838 // 802.1x encryption. |
851 // If we are creating the "Join other network..." dialog, we will allow user | 839 // If we are creating the "Join other network..." dialog, we will allow user |
852 // to enter the data. And if they select the 802.1x encryption, we will show | 840 // to enter the data. And if they select the 802.1x encryption, we will show |
853 // the 802.1x fields. | 841 // the 802.1x fields. |
854 void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) { | 842 void WifiConfigView::Init(bool show_8021x) { |
| 843 const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()-> |
| 844 GetNetworkState(service_path_); |
855 if (wifi) { | 845 if (wifi) { |
| 846 DCHECK(wifi->type() == flimflam::kTypeWifi); |
| 847 if (wifi->security() == flimflam::kSecurity8021x) |
| 848 show_8021x = true; |
856 ParseWiFiEAPUIProperty(&eap_method_ui_data_, wifi, onc::eap::kOuter); | 849 ParseWiFiEAPUIProperty(&eap_method_ui_data_, wifi, onc::eap::kOuter); |
857 ParseWiFiEAPUIProperty(&phase_2_auth_ui_data_, wifi, onc::eap::kInner); | 850 ParseWiFiEAPUIProperty(&phase_2_auth_ui_data_, wifi, onc::eap::kInner); |
858 ParseWiFiEAPUIProperty(&user_cert_ui_data_, wifi, onc::eap::kClientCertRef); | 851 ParseWiFiEAPUIProperty(&user_cert_ui_data_, wifi, onc::eap::kClientCertRef); |
859 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, | 852 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, |
860 onc::eap::kServerCARef); | 853 onc::eap::kServerCARef); |
861 if (server_ca_cert_ui_data_.IsManaged()) { | 854 if (server_ca_cert_ui_data_.IsManaged()) { |
862 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, | 855 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, |
863 onc::eap::kUseSystemCAs); | 856 onc::eap::kUseSystemCAs); |
864 } | 857 } |
865 ParseWiFiEAPUIProperty(&identity_ui_data_, wifi, onc::eap::kIdentity); | 858 ParseWiFiEAPUIProperty(&identity_ui_data_, wifi, onc::eap::kIdentity); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 // Identity | 993 // Identity |
1001 layout->StartRow(0, column_view_set_id); | 994 layout->StartRow(0, column_view_set_id); |
1002 string16 identity_label_text = l10n_util::GetStringUTF16( | 995 string16 identity_label_text = l10n_util::GetStringUTF16( |
1003 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); | 996 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); |
1004 identity_label_ = new views::Label(identity_label_text); | 997 identity_label_ = new views::Label(identity_label_text); |
1005 layout->AddView(identity_label_); | 998 layout->AddView(identity_label_); |
1006 identity_textfield_ = new views::Textfield( | 999 identity_textfield_ = new views::Textfield( |
1007 views::Textfield::STYLE_DEFAULT); | 1000 views::Textfield::STYLE_DEFAULT); |
1008 identity_textfield_->SetAccessibleName(identity_label_text); | 1001 identity_textfield_->SetAccessibleName(identity_label_text); |
1009 identity_textfield_->SetController(this); | 1002 identity_textfield_->SetController(this); |
1010 if (wifi && !wifi->identity().empty()) | |
1011 identity_textfield_->SetText(UTF8ToUTF16(wifi->identity())); | |
1012 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); | 1003 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); |
1013 layout->AddView(identity_textfield_); | 1004 layout->AddView(identity_textfield_); |
1014 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); | 1005 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); |
1015 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1006 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1016 } | 1007 } |
1017 | 1008 |
1018 // Passphrase input | 1009 // Passphrase input |
1019 layout->StartRow(0, column_view_set_id); | 1010 layout->StartRow(0, column_view_set_id); |
1020 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; | 1011 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; |
1021 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); | 1012 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); |
1022 passphrase_label_ = new views::Label(passphrase_label_text); | 1013 passphrase_label_ = new views::Label(passphrase_label_text); |
1023 layout->AddView(passphrase_label_); | 1014 layout->AddView(passphrase_label_); |
1024 passphrase_textfield_ = new views::Textfield( | 1015 passphrase_textfield_ = new views::Textfield( |
1025 views::Textfield::STYLE_OBSCURED); | 1016 views::Textfield::STYLE_OBSCURED); |
1026 passphrase_textfield_->SetController(this); | 1017 passphrase_textfield_->SetController(this); |
1027 if (wifi && !wifi->GetPassphrase().empty()) | |
1028 passphrase_textfield_->SetText(UTF8ToUTF16(wifi->GetPassphrase())); | |
1029 // Disable passphrase input initially for other network. | 1018 // Disable passphrase input initially for other network. |
1030 passphrase_label_->SetEnabled(wifi != NULL); | 1019 passphrase_label_->SetEnabled(wifi != NULL); |
1031 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); | 1020 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); |
1032 passphrase_textfield_->SetAccessibleName(passphrase_label_text); | 1021 passphrase_textfield_->SetAccessibleName(passphrase_label_text); |
1033 layout->AddView(passphrase_textfield_); | 1022 layout->AddView(passphrase_textfield_); |
1034 | 1023 |
1035 if (passphrase_ui_data_.IsManaged()) { | 1024 if (passphrase_ui_data_.IsManaged()) { |
1036 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_)); | 1025 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_)); |
1037 } else { | 1026 } else { |
1038 // Password visible button. | 1027 // Password visible button. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); | 1084 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); |
1096 save_credentials_checkbox_->SetEnabled( | 1085 save_credentials_checkbox_->SetEnabled( |
1097 save_credentials_ui_data_.IsEditable()); | 1086 save_credentials_ui_data_.IsEditable()); |
1098 layout->SkipColumns(1); | 1087 layout->SkipColumns(1); |
1099 layout->AddView(save_credentials_checkbox_); | 1088 layout->AddView(save_credentials_checkbox_); |
1100 layout->AddView( | 1089 layout->AddView( |
1101 new ControlledSettingIndicatorView(save_credentials_ui_data_)); | 1090 new ControlledSettingIndicatorView(save_credentials_ui_data_)); |
1102 } | 1091 } |
1103 | 1092 |
1104 // Share network | 1093 // Share network |
1105 if (!wifi || | 1094 if (!wifi || wifi->profile_path().empty()) { |
1106 (wifi->profile_type() == PROFILE_NONE && | |
1107 wifi->IsPassphraseRequired() && | |
1108 !wifi->RequiresUserProfile())) { | |
1109 layout->StartRow(0, column_view_set_id); | 1095 layout->StartRow(0, column_view_set_id); |
1110 share_network_checkbox_ = new views::Checkbox( | 1096 share_network_checkbox_ = new views::Checkbox( |
1111 l10n_util::GetStringUTF16( | 1097 l10n_util::GetStringUTF16( |
1112 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK)); | 1098 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK)); |
1113 layout->SkipColumns(1); | 1099 layout->SkipColumns(1); |
1114 layout->AddView(share_network_checkbox_); | 1100 layout->AddView(share_network_checkbox_); |
1115 } | 1101 } |
1116 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1102 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1117 | 1103 |
1118 // Create an error label. | 1104 // Create an error label. |
1119 layout->StartRow(0, column_view_set_id); | 1105 layout->StartRow(0, column_view_set_id); |
1120 layout->SkipColumns(1); | 1106 layout->SkipColumns(1); |
1121 error_label_ = new views::Label(); | 1107 error_label_ = new views::Label(); |
1122 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1108 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1123 error_label_->SetEnabledColor(SK_ColorRED); | 1109 error_label_->SetEnabledColor(SK_ColorRED); |
1124 layout->AddView(error_label_); | 1110 layout->AddView(error_label_); |
1125 | 1111 |
1126 // Initialize the field and checkbox values. | 1112 // Initialize the field and checkbox values. |
1127 | 1113 |
1128 // After creating the fields, we set the values. Fields need to be created | 1114 if (!wifi && show_8021x) |
1129 // first because RefreshEapFields() will enable/disable them as appropriate. | |
1130 if (show_8021x) { | |
1131 EAPMethod eap_method = (wifi ? wifi->eap_method() : EAP_METHOD_UNKNOWN); | |
1132 switch (eap_method) { | |
1133 case EAP_METHOD_PEAP: | |
1134 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP); | |
1135 break; | |
1136 case EAP_METHOD_TTLS: | |
1137 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS); | |
1138 break; | |
1139 case EAP_METHOD_TLS: | |
1140 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TLS); | |
1141 break; | |
1142 case EAP_METHOD_LEAP: | |
1143 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_LEAP); | |
1144 break; | |
1145 default: | |
1146 break; | |
1147 } | |
1148 RefreshEapFields(); | 1115 RefreshEapFields(); |
1149 | 1116 |
1150 // Phase 2 authentication and anonymous identity. | 1117 RefreshShareCheckbox(); |
1151 if (Phase2AuthActive()) { | 1118 UpdateErrorLabel(); |
1152 EAPPhase2Auth eap_phase_2_auth = | 1119 |
1153 (wifi ? wifi->eap_phase_2_auth() : EAP_PHASE_2_AUTH_AUTO); | 1120 if (wifi) { |
1154 switch (eap_phase_2_auth) { | 1121 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
1155 case EAP_PHASE_2_AUTH_MD5: | 1122 service_path_, |
1156 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5); | 1123 base::Bind(&WifiConfigView::InitFromProperties, |
1157 break; | 1124 weak_ptr_factory_.GetWeakPtr(), show_8021x), |
1158 case EAP_PHASE_2_AUTH_MSCHAPV2: | 1125 base::Bind(&ShillError, "GetProperties")); |
1159 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2); | 1126 } |
1160 break; | 1127 } |
1161 case EAP_PHASE_2_AUTH_MSCHAP: | 1128 |
1162 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP); | 1129 void WifiConfigView::InitFromProperties( |
1163 break; | 1130 bool show_8021x, |
1164 case EAP_PHASE_2_AUTH_PAP: | 1131 const std::string& service_path, |
1165 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP); | 1132 const base::DictionaryValue& properties) { |
1166 break; | 1133 std::string passphrase; |
1167 case EAP_PHASE_2_AUTH_CHAP: | 1134 properties.GetStringWithoutPathExpansion( |
1168 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP); | 1135 flimflam::kPassphraseProperty, &passphrase); |
1169 break; | 1136 passphrase_textfield_->SetText(UTF8ToUTF16(passphrase)); |
1170 default: | 1137 |
1171 break; | 1138 if (!show_8021x) |
| 1139 return; |
| 1140 |
| 1141 // EAP Method |
| 1142 std::string eap_method; |
| 1143 properties.GetStringWithoutPathExpansion( |
| 1144 flimflam::kEapMethodProperty, &eap_method); |
| 1145 if (eap_method == flimflam::kEapMethodPEAP) |
| 1146 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP); |
| 1147 else if (eap_method == flimflam::kEapMethodTTLS) |
| 1148 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS); |
| 1149 else if (eap_method == flimflam::kEapMethodTLS) |
| 1150 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TLS); |
| 1151 else if (eap_method == flimflam::kEapMethodLEAP) |
| 1152 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_LEAP); |
| 1153 RefreshEapFields(); |
| 1154 |
| 1155 // Phase 2 authentication and anonymous identity. |
| 1156 if (Phase2AuthActive()) { |
| 1157 std::string eap_phase_2_auth; |
| 1158 properties.GetStringWithoutPathExpansion( |
| 1159 flimflam::kEapPhase2AuthProperty, &eap_phase_2_auth); |
| 1160 if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMD5) |
| 1161 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5); |
| 1162 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAPV2) |
| 1163 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2); |
| 1164 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAP) |
| 1165 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP); |
| 1166 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSPAP) |
| 1167 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP); |
| 1168 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSCHAP) |
| 1169 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP); |
| 1170 |
| 1171 std::string eap_anonymous_identity; |
| 1172 properties.GetStringWithoutPathExpansion( |
| 1173 flimflam::kEapAnonymousIdentityProperty, &eap_anonymous_identity); |
| 1174 identity_anonymous_textfield_->SetText(UTF8ToUTF16(eap_anonymous_identity)); |
| 1175 } |
| 1176 |
| 1177 // Server CA certificate. |
| 1178 if (CaCertActive()) { |
| 1179 std::string eap_ca_cert_pem; |
| 1180 const base::ListValue* pems = NULL; |
| 1181 if (properties.GetListWithoutPathExpansion( |
| 1182 shill::kEapCaCertPemProperty, &pems)) |
| 1183 pems->GetString(0, &eap_ca_cert_pem); |
| 1184 if (eap_ca_cert_pem.empty()) { |
| 1185 bool eap_use_system_cas = false; |
| 1186 properties.GetBooleanWithoutPathExpansion( |
| 1187 flimflam::kEapUseSystemCasProperty, &eap_use_system_cas); |
| 1188 if (eap_use_system_cas) { |
| 1189 // "Default" |
| 1190 server_ca_cert_combobox_->SetSelectedIndex(0); |
| 1191 } else { |
| 1192 // "Do not check". |
| 1193 server_ca_cert_combobox_->SetSelectedIndex( |
| 1194 server_ca_cert_combobox_->model()->GetItemCount() - 1); |
1172 } | 1195 } |
1173 | 1196 } else { |
1174 const std::string& eap_anonymous_identity = | 1197 // Select the certificate if available. |
1175 (wifi ? wifi->eap_anonymous_identity() : std::string()); | 1198 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( |
1176 identity_anonymous_textfield_->SetText( | 1199 CertLibrary::CERT_TYPE_SERVER_CA, eap_ca_cert_pem); |
1177 UTF8ToUTF16(eap_anonymous_identity)); | 1200 if (cert_index >= 0) { |
1178 } | 1201 // Skip item for "Default". |
1179 | 1202 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); |
1180 // Server CA certificate. | |
1181 if (CaCertActive()) { | |
1182 const std::string& ca_cert_pem = | |
1183 (wifi ? wifi->eap_server_ca_cert_pem() : std::string()); | |
1184 if (ca_cert_pem.empty()) { | |
1185 if (wifi->eap_use_system_cas()) { | |
1186 // "Default". | |
1187 server_ca_cert_combobox_->SetSelectedIndex(0); | |
1188 } else { | |
1189 // "Do not check". | |
1190 server_ca_cert_combobox_->SetSelectedIndex( | |
1191 server_ca_cert_combobox_->model()->GetItemCount() - 1); | |
1192 } | |
1193 } else { | |
1194 // Select the certificate if available. | |
1195 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( | |
1196 CertLibrary::CERT_TYPE_SERVER_CA, ca_cert_pem); | |
1197 if (cert_index >= 0) { | |
1198 // Skip item for "Default". | |
1199 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); | |
1200 } | |
1201 } | 1203 } |
1202 } | 1204 } |
| 1205 } |
1203 | 1206 |
1204 // User certificate. | 1207 // User certificate. |
1205 if (UserCertActive()) { | 1208 if (UserCertActive()) { |
1206 const std::string& pkcs11_id = | 1209 std::string eap_cert_id; |
1207 (wifi ? wifi->eap_client_cert_pkcs11_id() : std::string()); | 1210 properties.GetStringWithoutPathExpansion( |
1208 if (!pkcs11_id.empty()) { | 1211 flimflam::kEapCertIdProperty, &eap_cert_id); |
1209 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( | 1212 if (!eap_cert_id.empty()) { |
1210 CertLibrary::CERT_TYPE_USER, pkcs11_id); | 1213 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( |
1211 if (cert_index >= 0) { | 1214 CertLibrary::CERT_TYPE_USER, eap_cert_id); |
1212 user_cert_combobox_->SetSelectedIndex(cert_index); | 1215 if (cert_index >= 0) |
1213 } | 1216 user_cert_combobox_->SetSelectedIndex(cert_index); |
1214 } | |
1215 } | 1217 } |
| 1218 } |
1216 | 1219 |
1217 // Identity is always active. | 1220 // Identity is always active. |
1218 const std::string& eap_identity = | 1221 std::string eap_identity; |
1219 (wifi ? wifi->eap_identity() : std::string()); | 1222 properties.GetStringWithoutPathExpansion( |
1220 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); | 1223 flimflam::kEapIdentityProperty, &eap_identity); |
| 1224 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); |
1221 | 1225 |
1222 // Passphrase | 1226 // Passphrase |
1223 if (PassphraseActive()) { | 1227 if (PassphraseActive()) { |
1224 const std::string& eap_passphrase = | 1228 std::string eap_password; |
1225 (wifi ? wifi->eap_passphrase() : std::string()); | 1229 properties.GetStringWithoutPathExpansion( |
1226 passphrase_textfield_->SetText(UTF8ToUTF16(eap_passphrase)); | 1230 flimflam::kEapPasswordProperty, &eap_password); |
1227 } | 1231 passphrase_textfield_->SetText(UTF8ToUTF16(eap_password)); |
| 1232 } |
1228 | 1233 |
1229 // Save credentials | 1234 // Save credentials |
1230 bool save_credentials = (wifi ? wifi->save_credentials() : false); | 1235 bool save_credentials = false; |
1231 save_credentials_checkbox_->SetChecked(save_credentials); | 1236 properties.GetBooleanWithoutPathExpansion( |
1232 } | 1237 flimflam::kSaveCredentialsProperty, &save_credentials); |
| 1238 save_credentials_checkbox_->SetChecked(save_credentials); |
1233 | 1239 |
1234 RefreshShareCheckbox(); | 1240 RefreshShareCheckbox(); |
1235 UpdateErrorLabel(); | 1241 UpdateErrorLabel(); |
1236 } | 1242 } |
1237 | 1243 |
1238 void WifiConfigView::InitFocus() { | 1244 void WifiConfigView::InitFocus() { |
1239 views::View* view_to_focus = GetInitiallyFocusedView(); | 1245 views::View* view_to_focus = GetInitiallyFocusedView(); |
1240 if (view_to_focus) | 1246 if (view_to_focus) |
1241 view_to_focus->RequestFocus(); | 1247 view_to_focus->RequestFocus(); |
1242 } | 1248 } |
1243 | 1249 |
1244 // static | 1250 // static |
1245 void WifiConfigView::ParseWiFiUIProperty( | 1251 void WifiConfigView::ParseWiFiUIProperty( |
1246 NetworkPropertyUIData* property_ui_data, | 1252 NetworkPropertyUIData* property_ui_data, |
1247 Network* network, | 1253 const NetworkState* network, |
1248 const std::string& key) { | 1254 const std::string& key) { |
1249 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | 1255 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
1250 const base::DictionaryValue* onc = | 1256 const base::DictionaryValue* onc = |
1251 NetworkConfigView::FindPolicyForActiveUser(network, &onc_source); | 1257 network_connect::FindPolicyForActiveUser(network, &onc_source); |
1252 | 1258 |
1253 property_ui_data->ParseOncProperty( | 1259 property_ui_data->ParseOncProperty( |
1254 onc_source, | 1260 onc_source, |
1255 onc, | 1261 onc, |
1256 base::StringPrintf("%s.%s", onc::network_config::kWiFi, key.c_str())); | 1262 base::StringPrintf("%s.%s", onc::network_config::kWiFi, key.c_str())); |
1257 } | 1263 } |
1258 | 1264 |
1259 // static | 1265 // static |
1260 void WifiConfigView::ParseWiFiEAPUIProperty( | 1266 void WifiConfigView::ParseWiFiEAPUIProperty( |
1261 NetworkPropertyUIData* property_ui_data, | 1267 NetworkPropertyUIData* property_ui_data, |
1262 Network* network, | 1268 const NetworkState* network, |
1263 const std::string& key) { | 1269 const std::string& key) { |
1264 ParseWiFiUIProperty( | 1270 ParseWiFiUIProperty( |
1265 property_ui_data, network, | 1271 property_ui_data, network, |
1266 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); | 1272 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); |
1267 } | 1273 } |
1268 | 1274 |
1269 } // namespace chromeos | 1275 } // namespace chromeos |
OLD | NEW |