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_profile.h" |
| 19 #include "chromeos/network/network_profile_handler.h" |
| 20 #include "chromeos/network/network_state.h" |
| 21 #include "chromeos/network/network_state_handler.h" |
14 #include "chromeos/network/network_ui_data.h" | 22 #include "chromeos/network/network_ui_data.h" |
15 #include "chromeos/network/onc/onc_constants.h" | 23 #include "chromeos/network/onc/onc_constants.h" |
16 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
18 #include "grit/locale_settings.h" | 26 #include "grit/locale_settings.h" |
19 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 28 #include "third_party/cros_system_api/dbus/service_constants.h" |
20 #include "ui/base/events/event.h" | 29 #include "ui/base/events/event.h" |
21 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
23 #include "ui/views/controls/button/checkbox.h" | 32 #include "ui/views/controls/button/checkbox.h" |
24 #include "ui/views/controls/button/image_button.h" | 33 #include "ui/views/controls/button/image_button.h" |
25 #include "ui/views/controls/combobox/combobox.h" | 34 #include "ui/views/controls/combobox/combobox.h" |
26 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
27 #include "ui/views/controls/textfield/textfield.h" | 36 #include "ui/views/controls/textfield/textfield.h" |
28 #include "ui/views/layout/grid_layout.h" | 37 #include "ui/views/layout/grid_layout.h" |
29 #include "ui/views/layout/layout_constants.h" | 38 #include "ui/views/layout/layout_constants.h" |
30 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
31 #include "ui/views/window/dialog_client_view.h" | 40 #include "ui/views/window/dialog_client_view.h" |
32 | 41 |
33 namespace chromeos { | 42 namespace chromeos { |
34 | 43 |
35 namespace { | 44 namespace { |
36 | 45 |
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 | 46 // Combobox that supports a preferred width. Used by Server CA combobox |
43 // because the strings inside it are too wide. | 47 // because the strings inside it are too wide. |
44 class ComboboxWithWidth : public views::Combobox { | 48 class ComboboxWithWidth : public views::Combobox { |
45 public: | 49 public: |
46 ComboboxWithWidth(ui::ComboboxModel* model, int width) | 50 ComboboxWithWidth(ui::ComboboxModel* model, int width) |
47 : Combobox(model), | 51 : Combobox(model), |
48 width_(width) { | 52 width_(width) { |
49 } | 53 } |
50 virtual ~ComboboxWithWidth() {} | 54 virtual ~ComboboxWithWidth() {} |
51 virtual gfx::Size GetPreferredSize() OVERRIDE { | 55 virtual gfx::Size GetPreferredSize() OVERRIDE { |
(...skipping 26 matching lines...) Expand all Loading... |
78 enum Phase2AuthComboboxIndex { | 82 enum Phase2AuthComboboxIndex { |
79 PHASE_2_AUTH_INDEX_AUTO = 0, // LEAP, EAP-TLS have only this auth. | 83 PHASE_2_AUTH_INDEX_AUTO = 0, // LEAP, EAP-TLS have only this auth. |
80 PHASE_2_AUTH_INDEX_MD5 = 1, | 84 PHASE_2_AUTH_INDEX_MD5 = 1, |
81 PHASE_2_AUTH_INDEX_MSCHAPV2 = 2, // PEAP has up to this auth. | 85 PHASE_2_AUTH_INDEX_MSCHAPV2 = 2, // PEAP has up to this auth. |
82 PHASE_2_AUTH_INDEX_MSCHAP = 3, | 86 PHASE_2_AUTH_INDEX_MSCHAP = 3, |
83 PHASE_2_AUTH_INDEX_PAP = 4, | 87 PHASE_2_AUTH_INDEX_PAP = 4, |
84 PHASE_2_AUTH_INDEX_CHAP = 5, // EAP-TTLS has up to this auth. | 88 PHASE_2_AUTH_INDEX_CHAP = 5, // EAP-TTLS has up to this auth. |
85 PHASE_2_AUTH_INDEX_COUNT = 6 | 89 PHASE_2_AUTH_INDEX_COUNT = 6 |
86 }; | 90 }; |
87 | 91 |
| 92 void ShillError(const std::string& function, |
| 93 const std::string& error_name, |
| 94 scoped_ptr<base::DictionaryValue> error_data) { |
| 95 NET_LOG_ERROR("Shill Error from WifiConfigView: " + error_name, function); |
| 96 } |
| 97 |
88 } // namespace | 98 } // namespace |
89 | 99 |
90 namespace internal { | 100 namespace internal { |
91 | 101 |
92 class SecurityComboboxModel : public ui::ComboboxModel { | 102 class SecurityComboboxModel : public ui::ComboboxModel { |
93 public: | 103 public: |
94 SecurityComboboxModel(); | 104 SecurityComboboxModel(); |
95 virtual ~SecurityComboboxModel(); | 105 virtual ~SecurityComboboxModel(); |
96 | 106 |
97 // Overridden from ui::ComboboxModel: | 107 // 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); | 325 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); |
316 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) | 326 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) |
317 return l10n_util::GetStringUTF16( | 327 return l10n_util::GetStringUTF16( |
318 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); | 328 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); |
319 return CertLibrary::Get()->GetCertDisplayStringAt( | 329 return CertLibrary::Get()->GetCertDisplayStringAt( |
320 CertLibrary::CERT_TYPE_USER, index); | 330 CertLibrary::CERT_TYPE_USER, index); |
321 } | 331 } |
322 | 332 |
323 } // namespace internal | 333 } // namespace internal |
324 | 334 |
325 WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi) | 335 WifiConfigView::WifiConfigView(NetworkConfigView* parent, |
326 : ChildNetworkConfigView(parent, wifi), | 336 const std::string& service_path, |
| 337 bool show_8021x) |
| 338 : ChildNetworkConfigView(parent, service_path), |
327 ssid_textfield_(NULL), | 339 ssid_textfield_(NULL), |
328 eap_method_combobox_(NULL), | 340 eap_method_combobox_(NULL), |
329 phase_2_auth_label_(NULL), | 341 phase_2_auth_label_(NULL), |
330 phase_2_auth_combobox_(NULL), | 342 phase_2_auth_combobox_(NULL), |
331 user_cert_label_(NULL), | 343 user_cert_label_(NULL), |
332 user_cert_combobox_(NULL), | 344 user_cert_combobox_(NULL), |
333 server_ca_cert_label_(NULL), | 345 server_ca_cert_label_(NULL), |
334 server_ca_cert_combobox_(NULL), | 346 server_ca_cert_combobox_(NULL), |
335 identity_label_(NULL), | 347 identity_label_(NULL), |
336 identity_textfield_(NULL), | 348 identity_textfield_(NULL), |
337 identity_anonymous_label_(NULL), | 349 identity_anonymous_label_(NULL), |
338 identity_anonymous_textfield_(NULL), | 350 identity_anonymous_textfield_(NULL), |
339 save_credentials_checkbox_(NULL), | 351 save_credentials_checkbox_(NULL), |
340 share_network_checkbox_(NULL), | 352 share_network_checkbox_(NULL), |
341 shared_network_label_(NULL), | 353 shared_network_label_(NULL), |
342 security_combobox_(NULL), | 354 security_combobox_(NULL), |
343 passphrase_label_(NULL), | 355 passphrase_label_(NULL), |
344 passphrase_textfield_(NULL), | 356 passphrase_textfield_(NULL), |
345 passphrase_visible_button_(NULL), | 357 passphrase_visible_button_(NULL), |
346 error_label_(NULL) { | 358 error_label_(NULL) { |
347 Init(wifi, Is8021x(wifi)); | 359 Init(service_path, show_8021x); |
348 } | |
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 } | 360 } |
374 | 361 |
375 WifiConfigView::~WifiConfigView() { | 362 WifiConfigView::~WifiConfigView() { |
376 CertLibrary::Get()->RemoveObserver(this); | 363 CertLibrary::Get()->RemoveObserver(this); |
377 } | 364 } |
378 | 365 |
379 string16 WifiConfigView::GetTitle() const { | 366 string16 WifiConfigView::GetTitle() const { |
380 return l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_JOIN_WIFI_NETWORKS); | 367 return l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_JOIN_WIFI_NETWORKS); |
381 } | 368 } |
382 | 369 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 // If not logged in, networks must be shared. | 532 // If not logged in, networks must be shared. |
546 share_network_checkbox_->SetEnabled(false); | 533 share_network_checkbox_->SetEnabled(false); |
547 share_network_checkbox_->SetChecked(true); | 534 share_network_checkbox_->SetChecked(true); |
548 } else { | 535 } else { |
549 share_network_checkbox_->SetEnabled(true); | 536 share_network_checkbox_->SetEnabled(true); |
550 share_network_checkbox_->SetChecked(false); // Default to unshared. | 537 share_network_checkbox_->SetChecked(false); // Default to unshared. |
551 } | 538 } |
552 } | 539 } |
553 | 540 |
554 void WifiConfigView::UpdateErrorLabel() { | 541 void WifiConfigView::UpdateErrorLabel() { |
555 std::string error_msg; | 542 base::string16 error_msg; |
556 if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) { | 543 if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) { |
557 if (!HaveUserCerts()) { | 544 if (!HaveUserCerts()) { |
558 if (!LoginState::Get()->IsUserLoggedIn()) { | 545 if (!LoginState::Get()->IsUserLoggedIn()) { |
559 error_msg = l10n_util::GetStringUTF8( | 546 error_msg = l10n_util::GetStringUTF16( |
560 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT); | 547 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT); |
561 } else { | 548 } else { |
562 error_msg = l10n_util::GetStringUTF8( | 549 error_msg = l10n_util::GetStringUTF16( |
563 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); | 550 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); |
564 } | 551 } |
565 } else if (!IsUserCertValid()) { | 552 } else if (!IsUserCertValid()) { |
566 error_msg = l10n_util::GetStringUTF8( | 553 error_msg = l10n_util::GetStringUTF16( |
567 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); | 554 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); |
568 } | 555 } |
569 } | 556 } |
570 if (error_msg.empty() && !service_path_.empty()) { | 557 if (error_msg.empty() && !service_path_.empty()) { |
571 NetworkLibrary* cros = NetworkLibrary::Get(); | 558 const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()-> |
572 const WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); | 559 GetNetworkState(service_path_); |
573 if (wifi && wifi->failed()) { | 560 if (wifi && wifi->connection_state() == flimflam::kStateFailure) |
574 bool passphrase_empty = wifi->GetPassphrase().empty(); | 561 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 } | 562 } |
594 if (!error_msg.empty()) { | 563 if (!error_msg.empty()) { |
595 error_label_->SetText(UTF8ToUTF16(error_msg)); | 564 error_label_->SetText(error_msg); |
596 error_label_->SetVisible(true); | 565 error_label_->SetVisible(true); |
597 } else { | 566 } else { |
598 error_label_->SetVisible(false); | 567 error_label_->SetVisible(false); |
599 } | 568 } |
600 } | 569 } |
601 | 570 |
602 void WifiConfigView::ContentsChanged(views::Textfield* sender, | 571 void WifiConfigView::ContentsChanged(views::Textfield* sender, |
603 const string16& new_contents) { | 572 const string16& new_contents) { |
604 UpdateDialogButtons(); | 573 UpdateDialogButtons(); |
605 } | 574 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 UpdateErrorLabel(); | 613 UpdateErrorLabel(); |
645 } | 614 } |
646 | 615 |
647 void WifiConfigView::OnCertificatesLoaded(bool initial_load) { | 616 void WifiConfigView::OnCertificatesLoaded(bool initial_load) { |
648 RefreshEapFields(); | 617 RefreshEapFields(); |
649 UpdateDialogButtons(); | 618 UpdateDialogButtons(); |
650 UpdateErrorLabel(); | 619 UpdateErrorLabel(); |
651 } | 620 } |
652 | 621 |
653 bool WifiConfigView::Login() { | 622 bool WifiConfigView::Login() { |
654 NetworkLibrary* cros = NetworkLibrary::Get(); | |
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(true /* share networks by 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 wifi_shared = !wifi->IsPrivate(); |
724 wifi->SetEnrollmentDelegate( | 688 bool share_network = GetShareNetwork(wifi_shared); |
725 CreateEnrollmentDelegate(GetWidget()->GetNativeWindow(), | 689 if (share_network != wifi_shared) { |
726 wifi->name(), | 690 std::string profile_path; |
727 ProfileManager::GetLastUsedProfile())); | 691 if (share_network) { |
728 cros->ConnectToWifiNetwork(wifi, GetShareNetwork(share_default)); | 692 profile_path = NetworkProfileHandler::kSharedProfilePath; |
729 // Connection failures are responsible for updating the UI, including | 693 } else { |
730 // reopening dialogs. | 694 const NetworkProfile* profile = |
| 695 NetworkHandler::Get()->network_profile_handler()-> |
| 696 GetDefaultUserProfile(); |
| 697 if (profile) |
| 698 profile_path = profile->path; |
| 699 else |
| 700 NET_LOG_ERROR("Unable to set user profile", service_path_); |
| 701 } |
| 702 if (!profile_path.empty()) { |
| 703 properties.SetStringWithoutPathExpansion( |
| 704 flimflam::kProfileProperty, profile_path); |
| 705 } |
| 706 } |
| 707 ash::network_connect::ConfigureNetworkAndConnect(service_path_, properties); |
731 } | 708 } |
732 return true; // dialog will be closed | 709 return true; // dialog will be closed |
733 } | 710 } |
734 | 711 |
735 std::string WifiConfigView::GetSsid() const { | 712 std::string WifiConfigView::GetSsid() const { |
736 std::string result; | 713 std::string result; |
737 if (ssid_textfield_ != NULL) { | 714 if (ssid_textfield_ != NULL) { |
738 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); | 715 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); |
739 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); | 716 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); |
740 } | 717 } |
(...skipping 12 matching lines...) Expand all Loading... |
753 return true; // share networks by default (e.g. non 8021x). | 730 return true; // share networks by default (e.g. non 8021x). |
754 return save_credentials_checkbox_->checked(); | 731 return save_credentials_checkbox_->checked(); |
755 } | 732 } |
756 | 733 |
757 bool WifiConfigView::GetShareNetwork(bool share_default) const { | 734 bool WifiConfigView::GetShareNetwork(bool share_default) const { |
758 if (!share_network_checkbox_) | 735 if (!share_network_checkbox_) |
759 return share_default; | 736 return share_default; |
760 return share_network_checkbox_->checked(); | 737 return share_network_checkbox_->checked(); |
761 } | 738 } |
762 | 739 |
763 EAPMethod WifiConfigView::GetEapMethod() const { | 740 std::string WifiConfigView::GetEapMethod() const { |
764 DCHECK(eap_method_combobox_); | 741 DCHECK(eap_method_combobox_); |
765 switch (eap_method_combobox_->selected_index()) { | 742 switch (eap_method_combobox_->selected_index()) { |
| 743 case EAP_METHOD_INDEX_PEAP: |
| 744 return flimflam::kEapMethodPEAP; |
| 745 case EAP_METHOD_INDEX_TLS: |
| 746 return flimflam::kEapMethodTLS; |
| 747 case EAP_METHOD_INDEX_TTLS: |
| 748 return flimflam::kEapMethodTTLS; |
| 749 case EAP_METHOD_INDEX_LEAP: |
| 750 return flimflam::kEapMethodLEAP; |
766 case EAP_METHOD_INDEX_NONE: | 751 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: | 752 default: |
777 return EAP_METHOD_UNKNOWN; | 753 return ""; |
778 } | 754 } |
779 } | 755 } |
780 | 756 |
781 EAPPhase2Auth WifiConfigView::GetEapPhase2Auth() const { | 757 std::string WifiConfigView::GetEapPhase2Auth() const { |
782 DCHECK(phase_2_auth_combobox_); | 758 DCHECK(phase_2_auth_combobox_); |
| 759 bool is_peap = (GetEapMethod() == flimflam::kEapMethodPEAP); |
783 switch (phase_2_auth_combobox_->selected_index()) { | 760 switch (phase_2_auth_combobox_->selected_index()) { |
| 761 case PHASE_2_AUTH_INDEX_MD5: |
| 762 return is_peap ? flimflam::kEapPhase2AuthPEAPMD5 |
| 763 : flimflam::kEapPhase2AuthTTLSMD5; |
| 764 case PHASE_2_AUTH_INDEX_MSCHAPV2: |
| 765 return is_peap ? flimflam::kEapPhase2AuthPEAPMSCHAPV2 |
| 766 : flimflam::kEapPhase2AuthTTLSMSCHAPV2; |
| 767 case PHASE_2_AUTH_INDEX_MSCHAP: |
| 768 return flimflam::kEapPhase2AuthTTLSMSCHAP; |
| 769 case PHASE_2_AUTH_INDEX_PAP: |
| 770 return flimflam::kEapPhase2AuthTTLSPAP; |
| 771 case PHASE_2_AUTH_INDEX_CHAP: |
| 772 return flimflam::kEapPhase2AuthTTLSCHAP; |
784 case PHASE_2_AUTH_INDEX_AUTO: | 773 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: | 774 default: |
797 return EAP_PHASE_2_AUTH_AUTO; | 775 return ""; |
798 } | 776 } |
799 } | 777 } |
800 | 778 |
801 std::string WifiConfigView::GetEapServerCaCertPEM() const { | 779 std::string WifiConfigView::GetEapServerCaCertPEM() const { |
802 DCHECK(server_ca_cert_combobox_); | 780 DCHECK(server_ca_cert_combobox_); |
803 int index = server_ca_cert_combobox_->selected_index(); | 781 int index = server_ca_cert_combobox_->selected_index(); |
804 if (index == 0) { | 782 if (index == 0) { |
805 // First item is "Default". | 783 // First item is "Default". |
806 return std::string(); | 784 return std::string(); |
807 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { | 785 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { |
(...skipping 27 matching lines...) Expand all Loading... |
835 std::string WifiConfigView::GetEapIdentity() const { | 813 std::string WifiConfigView::GetEapIdentity() const { |
836 DCHECK(identity_textfield_); | 814 DCHECK(identity_textfield_); |
837 return UTF16ToUTF8(identity_textfield_->text()); | 815 return UTF16ToUTF8(identity_textfield_->text()); |
838 } | 816 } |
839 | 817 |
840 std::string WifiConfigView::GetEapAnonymousIdentity() const { | 818 std::string WifiConfigView::GetEapAnonymousIdentity() const { |
841 DCHECK(identity_anonymous_textfield_); | 819 DCHECK(identity_anonymous_textfield_); |
842 return UTF16ToUTF8(identity_anonymous_textfield_->text()); | 820 return UTF16ToUTF8(identity_anonymous_textfield_->text()); |
843 } | 821 } |
844 | 822 |
| 823 void WifiConfigView::SetEapProperties(base::DictionaryValue* properties) { |
| 824 properties->SetStringWithoutPathExpansion( |
| 825 flimflam::kEapIdentityProperty, GetEapIdentity()); |
| 826 properties->SetStringWithoutPathExpansion( |
| 827 flimflam::kEapMethodProperty, GetEapMethod()); |
| 828 properties->SetStringWithoutPathExpansion( |
| 829 flimflam::kEapPhase2AuthProperty, GetEapPhase2Auth()); |
| 830 properties->SetStringWithoutPathExpansion( |
| 831 flimflam::kEapAnonymousIdentityProperty, GetEapAnonymousIdentity()); |
| 832 |
| 833 // shill requires both CertID and KeyID for TLS connections, despite |
| 834 // the fact that by convention they are the same ID. |
| 835 properties->SetStringWithoutPathExpansion( |
| 836 flimflam::kEapCertIdProperty, GetEapClientCertPkcs11Id()); |
| 837 properties->SetStringWithoutPathExpansion( |
| 838 flimflam::kEapKeyIdProperty, GetEapClientCertPkcs11Id()); |
| 839 |
| 840 properties->SetBooleanWithoutPathExpansion( |
| 841 flimflam::kEapUseSystemCasProperty, GetEapUseSystemCas()); |
| 842 properties->SetStringWithoutPathExpansion( |
| 843 flimflam::kEapPasswordProperty, GetPassphrase()); |
| 844 |
| 845 base::ListValue* pem_list = new base::ListValue; |
| 846 pem_list->AppendString(GetEapServerCaCertPEM()); |
| 847 properties->SetWithoutPathExpansion( |
| 848 shill::kEapCaCertPemProperty, pem_list); |
| 849 } |
| 850 |
845 void WifiConfigView::Cancel() { | 851 void WifiConfigView::Cancel() { |
846 } | 852 } |
847 | 853 |
848 // This will initialize the view depending on if we have a wifi network or not. | 854 // 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 | 855 // And if we are doing simple password encryption or the more complicated |
850 // 802.1x encryption. | 856 // 802.1x encryption. |
851 // If we are creating the "Join other network..." dialog, we will allow user | 857 // 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 | 858 // to enter the data. And if they select the 802.1x encryption, we will show |
853 // the 802.1x fields. | 859 // the 802.1x fields. |
854 void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) { | 860 void WifiConfigView::Init(const std::string& service_path, bool show_8021x) { |
| 861 const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()-> |
| 862 GetNetworkState(service_path); |
855 if (wifi) { | 863 if (wifi) { |
| 864 if (wifi->security() == flimflam::kSecurity8021x) |
| 865 show_8021x = true; |
856 ParseWiFiEAPUIProperty(&eap_method_ui_data_, wifi, onc::eap::kOuter); | 866 ParseWiFiEAPUIProperty(&eap_method_ui_data_, wifi, onc::eap::kOuter); |
857 ParseWiFiEAPUIProperty(&phase_2_auth_ui_data_, wifi, onc::eap::kInner); | 867 ParseWiFiEAPUIProperty(&phase_2_auth_ui_data_, wifi, onc::eap::kInner); |
858 ParseWiFiEAPUIProperty(&user_cert_ui_data_, wifi, onc::eap::kClientCertRef); | 868 ParseWiFiEAPUIProperty(&user_cert_ui_data_, wifi, onc::eap::kClientCertRef); |
859 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, | 869 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, |
860 onc::eap::kServerCARef); | 870 onc::eap::kServerCARef); |
861 if (server_ca_cert_ui_data_.IsManaged()) { | 871 if (server_ca_cert_ui_data_.IsManaged()) { |
862 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, | 872 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, |
863 onc::eap::kUseSystemCAs); | 873 onc::eap::kUseSystemCAs); |
864 } | 874 } |
865 ParseWiFiEAPUIProperty(&identity_ui_data_, wifi, onc::eap::kIdentity); | 875 ParseWiFiEAPUIProperty(&identity_ui_data_, wifi, onc::eap::kIdentity); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 // Identity | 1010 // Identity |
1001 layout->StartRow(0, column_view_set_id); | 1011 layout->StartRow(0, column_view_set_id); |
1002 string16 identity_label_text = l10n_util::GetStringUTF16( | 1012 string16 identity_label_text = l10n_util::GetStringUTF16( |
1003 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); | 1013 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); |
1004 identity_label_ = new views::Label(identity_label_text); | 1014 identity_label_ = new views::Label(identity_label_text); |
1005 layout->AddView(identity_label_); | 1015 layout->AddView(identity_label_); |
1006 identity_textfield_ = new views::Textfield( | 1016 identity_textfield_ = new views::Textfield( |
1007 views::Textfield::STYLE_DEFAULT); | 1017 views::Textfield::STYLE_DEFAULT); |
1008 identity_textfield_->SetAccessibleName(identity_label_text); | 1018 identity_textfield_->SetAccessibleName(identity_label_text); |
1009 identity_textfield_->SetController(this); | 1019 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()); | 1020 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); |
1013 layout->AddView(identity_textfield_); | 1021 layout->AddView(identity_textfield_); |
1014 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); | 1022 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); |
1015 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1023 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1016 } | 1024 } |
1017 | 1025 |
1018 // Passphrase input | 1026 // Passphrase input |
1019 layout->StartRow(0, column_view_set_id); | 1027 layout->StartRow(0, column_view_set_id); |
1020 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; | 1028 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; |
1021 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); | 1029 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); |
1022 passphrase_label_ = new views::Label(passphrase_label_text); | 1030 passphrase_label_ = new views::Label(passphrase_label_text); |
1023 layout->AddView(passphrase_label_); | 1031 layout->AddView(passphrase_label_); |
1024 passphrase_textfield_ = new views::Textfield( | 1032 passphrase_textfield_ = new views::Textfield( |
1025 views::Textfield::STYLE_OBSCURED); | 1033 views::Textfield::STYLE_OBSCURED); |
1026 passphrase_textfield_->SetController(this); | 1034 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. | 1035 // Disable passphrase input initially for other network. |
1030 passphrase_label_->SetEnabled(wifi != NULL); | 1036 passphrase_label_->SetEnabled(wifi != NULL); |
1031 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); | 1037 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); |
1032 passphrase_textfield_->SetAccessibleName(passphrase_label_text); | 1038 passphrase_textfield_->SetAccessibleName(passphrase_label_text); |
1033 layout->AddView(passphrase_textfield_); | 1039 layout->AddView(passphrase_textfield_); |
1034 | 1040 |
1035 if (passphrase_ui_data_.IsManaged()) { | 1041 if (passphrase_ui_data_.IsManaged()) { |
1036 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_)); | 1042 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_)); |
1037 } else { | 1043 } else { |
1038 // Password visible button. | 1044 // Password visible button. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); | 1101 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); |
1096 save_credentials_checkbox_->SetEnabled( | 1102 save_credentials_checkbox_->SetEnabled( |
1097 save_credentials_ui_data_.IsEditable()); | 1103 save_credentials_ui_data_.IsEditable()); |
1098 layout->SkipColumns(1); | 1104 layout->SkipColumns(1); |
1099 layout->AddView(save_credentials_checkbox_); | 1105 layout->AddView(save_credentials_checkbox_); |
1100 layout->AddView( | 1106 layout->AddView( |
1101 new ControlledSettingIndicatorView(save_credentials_ui_data_)); | 1107 new ControlledSettingIndicatorView(save_credentials_ui_data_)); |
1102 } | 1108 } |
1103 | 1109 |
1104 // Share network | 1110 // Share network |
1105 if (!wifi || | 1111 if (!wifi || !wifi->IsPrivate()) { |
1106 (wifi->profile_type() == PROFILE_NONE && | |
1107 wifi->IsPassphraseRequired() && | |
1108 !wifi->RequiresUserProfile())) { | |
1109 layout->StartRow(0, column_view_set_id); | 1112 layout->StartRow(0, column_view_set_id); |
1110 share_network_checkbox_ = new views::Checkbox( | 1113 share_network_checkbox_ = new views::Checkbox( |
1111 l10n_util::GetStringUTF16( | 1114 l10n_util::GetStringUTF16( |
1112 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK)); | 1115 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK)); |
1113 layout->SkipColumns(1); | 1116 layout->SkipColumns(1); |
1114 layout->AddView(share_network_checkbox_); | 1117 layout->AddView(share_network_checkbox_); |
| 1118 if (wifi) |
| 1119 share_network_checkbox_->SetChecked(true); |
1115 } | 1120 } |
1116 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1121 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1117 | 1122 |
1118 // Create an error label. | 1123 // Create an error label. |
1119 layout->StartRow(0, column_view_set_id); | 1124 layout->StartRow(0, column_view_set_id); |
1120 layout->SkipColumns(1); | 1125 layout->SkipColumns(1); |
1121 error_label_ = new views::Label(); | 1126 error_label_ = new views::Label(); |
1122 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1127 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1123 error_label_->SetEnabledColor(SK_ColorRED); | 1128 error_label_->SetEnabledColor(SK_ColorRED); |
1124 layout->AddView(error_label_); | 1129 layout->AddView(error_label_); |
1125 | 1130 |
1126 // Initialize the field and checkbox values. | 1131 // Initialize the field and checkbox values. |
1127 | 1132 |
1128 // After creating the fields, we set the values. Fields need to be created | 1133 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(); | 1134 RefreshEapFields(); |
1149 | 1135 |
1150 // Phase 2 authentication and anonymous identity. | 1136 RefreshShareCheckbox(); |
1151 if (Phase2AuthActive()) { | 1137 UpdateErrorLabel(); |
1152 EAPPhase2Auth eap_phase_2_auth = | 1138 |
1153 (wifi ? wifi->eap_phase_2_auth() : EAP_PHASE_2_AUTH_AUTO); | 1139 if (wifi) { |
1154 switch (eap_phase_2_auth) { | 1140 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
1155 case EAP_PHASE_2_AUTH_MD5: | 1141 service_path, |
1156 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5); | 1142 base::Bind(&WifiConfigView::InitFromProperties, |
1157 break; | 1143 AsWeakPtr(), show_8021x), |
1158 case EAP_PHASE_2_AUTH_MSCHAPV2: | 1144 base::Bind(&ShillError, "GetProperties")); |
1159 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2); | 1145 } |
1160 break; | 1146 } |
1161 case EAP_PHASE_2_AUTH_MSCHAP: | 1147 |
1162 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP); | 1148 void WifiConfigView::InitFromProperties( |
1163 break; | 1149 bool show_8021x, |
1164 case EAP_PHASE_2_AUTH_PAP: | 1150 const std::string& service_path, |
1165 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP); | 1151 const base::DictionaryValue& properties) { |
1166 break; | 1152 std::string passphrase; |
1167 case EAP_PHASE_2_AUTH_CHAP: | 1153 properties.GetStringWithoutPathExpansion( |
1168 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP); | 1154 flimflam::kPassphraseProperty, &passphrase); |
1169 break; | 1155 passphrase_textfield_->SetText(UTF8ToUTF16(passphrase)); |
1170 default: | 1156 |
1171 break; | 1157 if (!show_8021x) |
| 1158 return; |
| 1159 |
| 1160 std::string identity; |
| 1161 properties.GetStringWithoutPathExpansion( |
| 1162 flimflam::kIdentityProperty, &identity); |
| 1163 identity_textfield_->SetText(UTF8ToUTF16(identity)); |
| 1164 |
| 1165 // EAP Method |
| 1166 std::string eap_method; |
| 1167 properties.GetStringWithoutPathExpansion( |
| 1168 flimflam::kEapMethodProperty, &eap_method); |
| 1169 if (eap_method == flimflam::kEapMethodPEAP) |
| 1170 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP); |
| 1171 else if (eap_method == flimflam::kEapMethodTTLS) |
| 1172 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS); |
| 1173 else if (eap_method == flimflam::kEapMethodTLS) |
| 1174 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TLS); |
| 1175 else if (eap_method == flimflam::kEapMethodLEAP) |
| 1176 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_LEAP); |
| 1177 RefreshEapFields(); |
| 1178 |
| 1179 // Phase 2 authentication and anonymous identity. |
| 1180 if (Phase2AuthActive()) { |
| 1181 std::string eap_phase_2_auth; |
| 1182 properties.GetStringWithoutPathExpansion( |
| 1183 flimflam::kEapPhase2AuthProperty, &eap_phase_2_auth); |
| 1184 if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMD5) |
| 1185 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5); |
| 1186 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAPV2) |
| 1187 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2); |
| 1188 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAP) |
| 1189 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP); |
| 1190 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSPAP) |
| 1191 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP); |
| 1192 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSCHAP) |
| 1193 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP); |
| 1194 |
| 1195 std::string eap_anonymous_identity; |
| 1196 properties.GetStringWithoutPathExpansion( |
| 1197 flimflam::kEapAnonymousIdentityProperty, &eap_anonymous_identity); |
| 1198 identity_anonymous_textfield_->SetText(UTF8ToUTF16(eap_anonymous_identity)); |
| 1199 } |
| 1200 |
| 1201 // Server CA certificate. |
| 1202 if (CaCertActive()) { |
| 1203 std::string eap_ca_cert_pem; |
| 1204 properties.GetStringWithoutPathExpansion( |
| 1205 shill::kEapCaCertPemProperty, &eap_ca_cert_pem); |
| 1206 if (eap_ca_cert_pem.empty()) { |
| 1207 bool eap_use_system_cas = false; |
| 1208 properties.GetBooleanWithoutPathExpansion( |
| 1209 flimflam::kEapUseSystemCasProperty, &eap_use_system_cas); |
| 1210 if (eap_use_system_cas) { |
| 1211 // "Default" |
| 1212 server_ca_cert_combobox_->SetSelectedIndex(0); |
| 1213 } else { |
| 1214 // "Do not check". |
| 1215 server_ca_cert_combobox_->SetSelectedIndex( |
| 1216 server_ca_cert_combobox_->model()->GetItemCount() - 1); |
1172 } | 1217 } |
1173 | 1218 } else { |
1174 const std::string& eap_anonymous_identity = | 1219 // Select the certificate if available. |
1175 (wifi ? wifi->eap_anonymous_identity() : std::string()); | 1220 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( |
1176 identity_anonymous_textfield_->SetText( | 1221 CertLibrary::CERT_TYPE_SERVER_CA, eap_ca_cert_pem); |
1177 UTF8ToUTF16(eap_anonymous_identity)); | 1222 if (cert_index >= 0) { |
1178 } | 1223 // Skip item for "Default". |
1179 | 1224 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 } | 1225 } |
1202 } | 1226 } |
| 1227 } |
1203 | 1228 |
1204 // User certificate. | 1229 // User certificate. |
1205 if (UserCertActive()) { | 1230 if (UserCertActive()) { |
1206 const std::string& pkcs11_id = | 1231 std::string eap_cert_id; |
1207 (wifi ? wifi->eap_client_cert_pkcs11_id() : std::string()); | 1232 properties.GetStringWithoutPathExpansion( |
1208 if (!pkcs11_id.empty()) { | 1233 flimflam::kEapCertIdProperty, &eap_cert_id); |
1209 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( | 1234 if (!eap_cert_id.empty()) { |
1210 CertLibrary::CERT_TYPE_USER, pkcs11_id); | 1235 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( |
1211 if (cert_index >= 0) { | 1236 CertLibrary::CERT_TYPE_USER, eap_cert_id); |
1212 user_cert_combobox_->SetSelectedIndex(cert_index); | 1237 if (cert_index >= 0) |
1213 } | 1238 user_cert_combobox_->SetSelectedIndex(cert_index); |
1214 } | |
1215 } | 1239 } |
| 1240 } |
1216 | 1241 |
1217 // Identity is always active. | 1242 // Identity is always active. |
1218 const std::string& eap_identity = | 1243 std::string eap_identity; |
1219 (wifi ? wifi->eap_identity() : std::string()); | 1244 properties.GetStringWithoutPathExpansion( |
1220 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); | 1245 flimflam::kEapIdentityProperty, &eap_identity); |
| 1246 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); |
1221 | 1247 |
1222 // Passphrase | 1248 // Passphrase |
1223 if (PassphraseActive()) { | 1249 if (PassphraseActive()) { |
1224 const std::string& eap_passphrase = | 1250 std::string eap_password; |
1225 (wifi ? wifi->eap_passphrase() : std::string()); | 1251 properties.GetStringWithoutPathExpansion( |
1226 passphrase_textfield_->SetText(UTF8ToUTF16(eap_passphrase)); | 1252 flimflam::kEapPasswordProperty, &eap_password); |
1227 } | 1253 passphrase_textfield_->SetText(UTF8ToUTF16(eap_password)); |
| 1254 } |
1228 | 1255 |
1229 // Save credentials | 1256 // Save credentials |
1230 bool save_credentials = (wifi ? wifi->save_credentials() : false); | 1257 bool save_credentials = false; |
1231 save_credentials_checkbox_->SetChecked(save_credentials); | 1258 properties.GetBooleanWithoutPathExpansion( |
1232 } | 1259 flimflam::kSaveCredentialsProperty, &save_credentials); |
| 1260 save_credentials_checkbox_->SetChecked(save_credentials); |
1233 | 1261 |
1234 RefreshShareCheckbox(); | 1262 RefreshShareCheckbox(); |
1235 UpdateErrorLabel(); | 1263 UpdateErrorLabel(); |
1236 } | 1264 } |
1237 | 1265 |
1238 void WifiConfigView::InitFocus() { | 1266 void WifiConfigView::InitFocus() { |
1239 views::View* view_to_focus = GetInitiallyFocusedView(); | 1267 views::View* view_to_focus = GetInitiallyFocusedView(); |
1240 if (view_to_focus) | 1268 if (view_to_focus) |
1241 view_to_focus->RequestFocus(); | 1269 view_to_focus->RequestFocus(); |
1242 } | 1270 } |
1243 | 1271 |
1244 // static | 1272 // static |
1245 void WifiConfigView::ParseWiFiUIProperty( | 1273 void WifiConfigView::ParseWiFiUIProperty( |
1246 NetworkPropertyUIData* property_ui_data, | 1274 NetworkPropertyUIData* property_ui_data, |
1247 Network* network, | 1275 const NetworkState* network, |
1248 const std::string& key) { | 1276 const std::string& key) { |
1249 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | 1277 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
1250 const base::DictionaryValue* onc = | 1278 const base::DictionaryValue* onc = |
1251 NetworkConfigView::FindPolicyForActiveUser(network, &onc_source); | 1279 network_connect::FindPolicyForActiveUser(network, &onc_source); |
1252 | 1280 |
1253 property_ui_data->ParseOncProperty( | 1281 property_ui_data->ParseOncProperty( |
1254 onc_source, | 1282 onc_source, |
1255 onc, | 1283 onc, |
1256 base::StringPrintf("%s.%s", onc::network_config::kWiFi, key.c_str())); | 1284 base::StringPrintf("%s.%s", onc::network_config::kWiFi, key.c_str())); |
1257 } | 1285 } |
1258 | 1286 |
1259 // static | 1287 // static |
1260 void WifiConfigView::ParseWiFiEAPUIProperty( | 1288 void WifiConfigView::ParseWiFiEAPUIProperty( |
1261 NetworkPropertyUIData* property_ui_data, | 1289 NetworkPropertyUIData* property_ui_data, |
1262 Network* network, | 1290 const NetworkState* network, |
1263 const std::string& key) { | 1291 const std::string& key) { |
1264 ParseWiFiUIProperty( | 1292 ParseWiFiUIProperty( |
1265 property_ui_data, network, | 1293 property_ui_data, network, |
1266 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); | 1294 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); |
1267 } | 1295 } |
1268 | 1296 |
1269 } // namespace chromeos | 1297 } // namespace chromeos |
OLD | NEW |