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 // If the 'Share' checkbox has been changed we need to set the Profile |
724 wifi->SetEnrollmentDelegate( | 688 // property of the network which will request that Shill move the network. |
725 CreateEnrollmentDelegate(GetWidget()->GetNativeWindow(), | 689 bool wifi_shared = !wifi->IsPrivate(); |
726 wifi->name(), | 690 bool share_network = GetShareNetwork(wifi_shared); |
pneubeck (no reviews)
2013/08/06 15:45:19
The 'shared' setting cannot and shouldn't be chang
stevenjb
2013/08/06 20:23:55
The logic for this has gotten twisted over time. A
| |
727 ProfileManager::GetLastUsedProfile())); | 691 if (share_network != wifi_shared) { |
pneubeck (no reviews)
2013/08/06 15:45:19
Very strong "No!".
stevenjb
2013/08/06 20:23:55
oO
pneubeck (no reviews)
2013/08/07 16:20:59
This was related to changing the shared state of p
| |
728 cros->ConnectToWifiNetwork(wifi, GetShareNetwork(share_default)); | 692 std::string profile_path; |
729 // Connection failures are responsible for updating the UI, including | 693 if (share_network) { |
730 // reopening dialogs. | 694 profile_path = NetworkProfileHandler::kSharedProfilePath; |
695 } else { | |
696 const NetworkProfile* profile = | |
697 NetworkHandler::Get()->network_profile_handler()-> | |
698 GetDefaultUserProfile(); | |
699 if (profile) | |
700 profile_path = profile->path; | |
701 else | |
702 NET_LOG_ERROR("Unable to set user profile", service_path_); | |
703 } | |
704 if (!profile_path.empty()) { | |
705 properties.SetStringWithoutPathExpansion( | |
706 flimflam::kProfileProperty, profile_path); | |
707 } | |
708 } | |
709 ash::network_connect::ConfigureNetworkAndConnect(service_path_, properties); | |
731 } | 710 } |
732 return true; // dialog will be closed | 711 return true; // dialog will be closed |
733 } | 712 } |
734 | 713 |
735 std::string WifiConfigView::GetSsid() const { | 714 std::string WifiConfigView::GetSsid() const { |
736 std::string result; | 715 std::string result; |
737 if (ssid_textfield_ != NULL) { | 716 if (ssid_textfield_ != NULL) { |
738 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); | 717 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); |
739 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); | 718 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); |
740 } | 719 } |
(...skipping 12 matching lines...) Expand all Loading... | |
753 return true; // share networks by default (e.g. non 8021x). | 732 return true; // share networks by default (e.g. non 8021x). |
754 return save_credentials_checkbox_->checked(); | 733 return save_credentials_checkbox_->checked(); |
755 } | 734 } |
756 | 735 |
757 bool WifiConfigView::GetShareNetwork(bool share_default) const { | 736 bool WifiConfigView::GetShareNetwork(bool share_default) const { |
758 if (!share_network_checkbox_) | 737 if (!share_network_checkbox_) |
759 return share_default; | 738 return share_default; |
760 return share_network_checkbox_->checked(); | 739 return share_network_checkbox_->checked(); |
761 } | 740 } |
762 | 741 |
763 EAPMethod WifiConfigView::GetEapMethod() const { | 742 std::string WifiConfigView::GetEapMethod() const { |
764 DCHECK(eap_method_combobox_); | 743 DCHECK(eap_method_combobox_); |
765 switch (eap_method_combobox_->selected_index()) { | 744 switch (eap_method_combobox_->selected_index()) { |
745 case EAP_METHOD_INDEX_PEAP: | |
746 return flimflam::kEapMethodPEAP; | |
747 case EAP_METHOD_INDEX_TLS: | |
748 return flimflam::kEapMethodTLS; | |
749 case EAP_METHOD_INDEX_TTLS: | |
750 return flimflam::kEapMethodTTLS; | |
751 case EAP_METHOD_INDEX_LEAP: | |
752 return flimflam::kEapMethodLEAP; | |
766 case EAP_METHOD_INDEX_NONE: | 753 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: | 754 default: |
777 return EAP_METHOD_UNKNOWN; | 755 return ""; |
778 } | 756 } |
779 } | 757 } |
780 | 758 |
781 EAPPhase2Auth WifiConfigView::GetEapPhase2Auth() const { | 759 std::string WifiConfigView::GetEapPhase2Auth() const { |
782 DCHECK(phase_2_auth_combobox_); | 760 DCHECK(phase_2_auth_combobox_); |
761 bool is_peap = (GetEapMethod() == flimflam::kEapMethodPEAP); | |
783 switch (phase_2_auth_combobox_->selected_index()) { | 762 switch (phase_2_auth_combobox_->selected_index()) { |
763 case PHASE_2_AUTH_INDEX_MD5: | |
764 return is_peap ? flimflam::kEapPhase2AuthPEAPMD5 | |
765 : flimflam::kEapPhase2AuthTTLSMD5; | |
766 case PHASE_2_AUTH_INDEX_MSCHAPV2: | |
767 return is_peap ? flimflam::kEapPhase2AuthPEAPMSCHAPV2 | |
768 : flimflam::kEapPhase2AuthTTLSMSCHAPV2; | |
769 case PHASE_2_AUTH_INDEX_MSCHAP: | |
770 return flimflam::kEapPhase2AuthTTLSMSCHAP; | |
771 case PHASE_2_AUTH_INDEX_PAP: | |
772 return flimflam::kEapPhase2AuthTTLSPAP; | |
773 case PHASE_2_AUTH_INDEX_CHAP: | |
774 return flimflam::kEapPhase2AuthTTLSCHAP; | |
784 case PHASE_2_AUTH_INDEX_AUTO: | 775 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: | 776 default: |
797 return EAP_PHASE_2_AUTH_AUTO; | 777 return ""; |
798 } | 778 } |
799 } | 779 } |
800 | 780 |
801 std::string WifiConfigView::GetEapServerCaCertPEM() const { | 781 std::string WifiConfigView::GetEapServerCaCertPEM() const { |
802 DCHECK(server_ca_cert_combobox_); | 782 DCHECK(server_ca_cert_combobox_); |
803 int index = server_ca_cert_combobox_->selected_index(); | 783 int index = server_ca_cert_combobox_->selected_index(); |
804 if (index == 0) { | 784 if (index == 0) { |
805 // First item is "Default". | 785 // First item is "Default". |
806 return std::string(); | 786 return std::string(); |
807 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { | 787 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { |
(...skipping 27 matching lines...) Expand all Loading... | |
835 std::string WifiConfigView::GetEapIdentity() const { | 815 std::string WifiConfigView::GetEapIdentity() const { |
836 DCHECK(identity_textfield_); | 816 DCHECK(identity_textfield_); |
837 return UTF16ToUTF8(identity_textfield_->text()); | 817 return UTF16ToUTF8(identity_textfield_->text()); |
838 } | 818 } |
839 | 819 |
840 std::string WifiConfigView::GetEapAnonymousIdentity() const { | 820 std::string WifiConfigView::GetEapAnonymousIdentity() const { |
841 DCHECK(identity_anonymous_textfield_); | 821 DCHECK(identity_anonymous_textfield_); |
842 return UTF16ToUTF8(identity_anonymous_textfield_->text()); | 822 return UTF16ToUTF8(identity_anonymous_textfield_->text()); |
843 } | 823 } |
844 | 824 |
825 void WifiConfigView::SetEapProperties(base::DictionaryValue* properties) { | |
826 properties->SetStringWithoutPathExpansion( | |
827 flimflam::kEapIdentityProperty, GetEapIdentity()); | |
828 properties->SetStringWithoutPathExpansion( | |
829 flimflam::kEapMethodProperty, GetEapMethod()); | |
830 properties->SetStringWithoutPathExpansion( | |
831 flimflam::kEapPhase2AuthProperty, GetEapPhase2Auth()); | |
832 properties->SetStringWithoutPathExpansion( | |
833 flimflam::kEapAnonymousIdentityProperty, GetEapAnonymousIdentity()); | |
834 | |
835 // shill requires both CertID and KeyID for TLS connections, despite | |
836 // the fact that by convention they are the same ID. | |
837 properties->SetStringWithoutPathExpansion( | |
838 flimflam::kEapCertIdProperty, GetEapClientCertPkcs11Id()); | |
839 properties->SetStringWithoutPathExpansion( | |
840 flimflam::kEapKeyIdProperty, GetEapClientCertPkcs11Id()); | |
841 | |
842 properties->SetBooleanWithoutPathExpansion( | |
843 flimflam::kEapUseSystemCasProperty, GetEapUseSystemCas()); | |
844 properties->SetStringWithoutPathExpansion( | |
845 flimflam::kEapPasswordProperty, GetPassphrase()); | |
846 | |
847 base::ListValue* pem_list = new base::ListValue; | |
848 pem_list->AppendString(GetEapServerCaCertPEM()); | |
849 properties->SetWithoutPathExpansion( | |
850 shill::kEapCaCertPemProperty, pem_list); | |
851 } | |
852 | |
845 void WifiConfigView::Cancel() { | 853 void WifiConfigView::Cancel() { |
846 } | 854 } |
847 | 855 |
848 // This will initialize the view depending on if we have a wifi network or not. | 856 // 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 | 857 // And if we are doing simple password encryption or the more complicated |
850 // 802.1x encryption. | 858 // 802.1x encryption. |
851 // If we are creating the "Join other network..." dialog, we will allow user | 859 // 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 | 860 // to enter the data. And if they select the 802.1x encryption, we will show |
853 // the 802.1x fields. | 861 // the 802.1x fields. |
854 void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) { | 862 void WifiConfigView::Init(const std::string& service_path, bool show_8021x) { |
863 const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()-> | |
864 GetNetworkState(service_path); | |
855 if (wifi) { | 865 if (wifi) { |
866 DCHECK(wifi->type() == flimflam::kTypeWifi); | |
867 if (wifi->security() == flimflam::kSecurity8021x) | |
868 show_8021x = true; | |
856 ParseWiFiEAPUIProperty(&eap_method_ui_data_, wifi, onc::eap::kOuter); | 869 ParseWiFiEAPUIProperty(&eap_method_ui_data_, wifi, onc::eap::kOuter); |
857 ParseWiFiEAPUIProperty(&phase_2_auth_ui_data_, wifi, onc::eap::kInner); | 870 ParseWiFiEAPUIProperty(&phase_2_auth_ui_data_, wifi, onc::eap::kInner); |
858 ParseWiFiEAPUIProperty(&user_cert_ui_data_, wifi, onc::eap::kClientCertRef); | 871 ParseWiFiEAPUIProperty(&user_cert_ui_data_, wifi, onc::eap::kClientCertRef); |
859 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, | 872 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, |
860 onc::eap::kServerCARef); | 873 onc::eap::kServerCARef); |
861 if (server_ca_cert_ui_data_.IsManaged()) { | 874 if (server_ca_cert_ui_data_.IsManaged()) { |
862 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, | 875 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, |
863 onc::eap::kUseSystemCAs); | 876 onc::eap::kUseSystemCAs); |
864 } | 877 } |
865 ParseWiFiEAPUIProperty(&identity_ui_data_, wifi, onc::eap::kIdentity); | 878 ParseWiFiEAPUIProperty(&identity_ui_data_, wifi, onc::eap::kIdentity); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1000 // Identity | 1013 // Identity |
1001 layout->StartRow(0, column_view_set_id); | 1014 layout->StartRow(0, column_view_set_id); |
1002 string16 identity_label_text = l10n_util::GetStringUTF16( | 1015 string16 identity_label_text = l10n_util::GetStringUTF16( |
1003 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); | 1016 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); |
1004 identity_label_ = new views::Label(identity_label_text); | 1017 identity_label_ = new views::Label(identity_label_text); |
1005 layout->AddView(identity_label_); | 1018 layout->AddView(identity_label_); |
1006 identity_textfield_ = new views::Textfield( | 1019 identity_textfield_ = new views::Textfield( |
1007 views::Textfield::STYLE_DEFAULT); | 1020 views::Textfield::STYLE_DEFAULT); |
1008 identity_textfield_->SetAccessibleName(identity_label_text); | 1021 identity_textfield_->SetAccessibleName(identity_label_text); |
1009 identity_textfield_->SetController(this); | 1022 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()); | 1023 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); |
1013 layout->AddView(identity_textfield_); | 1024 layout->AddView(identity_textfield_); |
1014 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); | 1025 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); |
1015 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1026 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1016 } | 1027 } |
1017 | 1028 |
1018 // Passphrase input | 1029 // Passphrase input |
1019 layout->StartRow(0, column_view_set_id); | 1030 layout->StartRow(0, column_view_set_id); |
1020 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; | 1031 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; |
1021 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); | 1032 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); |
1022 passphrase_label_ = new views::Label(passphrase_label_text); | 1033 passphrase_label_ = new views::Label(passphrase_label_text); |
1023 layout->AddView(passphrase_label_); | 1034 layout->AddView(passphrase_label_); |
1024 passphrase_textfield_ = new views::Textfield( | 1035 passphrase_textfield_ = new views::Textfield( |
1025 views::Textfield::STYLE_OBSCURED); | 1036 views::Textfield::STYLE_OBSCURED); |
1026 passphrase_textfield_->SetController(this); | 1037 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. | 1038 // Disable passphrase input initially for other network. |
1030 passphrase_label_->SetEnabled(wifi != NULL); | 1039 passphrase_label_->SetEnabled(wifi != NULL); |
1031 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); | 1040 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); |
1032 passphrase_textfield_->SetAccessibleName(passphrase_label_text); | 1041 passphrase_textfield_->SetAccessibleName(passphrase_label_text); |
1033 layout->AddView(passphrase_textfield_); | 1042 layout->AddView(passphrase_textfield_); |
1034 | 1043 |
1035 if (passphrase_ui_data_.IsManaged()) { | 1044 if (passphrase_ui_data_.IsManaged()) { |
1036 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_)); | 1045 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_)); |
1037 } else { | 1046 } else { |
1038 // Password visible button. | 1047 // Password visible button. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1095 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); | 1104 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); |
1096 save_credentials_checkbox_->SetEnabled( | 1105 save_credentials_checkbox_->SetEnabled( |
1097 save_credentials_ui_data_.IsEditable()); | 1106 save_credentials_ui_data_.IsEditable()); |
1098 layout->SkipColumns(1); | 1107 layout->SkipColumns(1); |
1099 layout->AddView(save_credentials_checkbox_); | 1108 layout->AddView(save_credentials_checkbox_); |
1100 layout->AddView( | 1109 layout->AddView( |
1101 new ControlledSettingIndicatorView(save_credentials_ui_data_)); | 1110 new ControlledSettingIndicatorView(save_credentials_ui_data_)); |
1102 } | 1111 } |
1103 | 1112 |
1104 // Share network | 1113 // Share network |
1105 if (!wifi || | 1114 if (!wifi || !wifi->IsPrivate()) { |
pneubeck (no reviews)
2013/08/06 15:45:19
this is not the same as before.
!IsPrivate can al
stevenjb
2013/08/06 20:23:55
Done.
| |
1106 (wifi->profile_type() == PROFILE_NONE && | |
1107 wifi->IsPassphraseRequired() && | |
1108 !wifi->RequiresUserProfile())) { | |
1109 layout->StartRow(0, column_view_set_id); | 1115 layout->StartRow(0, column_view_set_id); |
1110 share_network_checkbox_ = new views::Checkbox( | 1116 share_network_checkbox_ = new views::Checkbox( |
1111 l10n_util::GetStringUTF16( | 1117 l10n_util::GetStringUTF16( |
1112 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK)); | 1118 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK)); |
1113 layout->SkipColumns(1); | 1119 layout->SkipColumns(1); |
1114 layout->AddView(share_network_checkbox_); | 1120 layout->AddView(share_network_checkbox_); |
1121 if (wifi) | |
pneubeck (no reviews)
2013/08/06 15:45:19
why this condition?
stevenjb
2013/08/06 20:23:55
Removed. This gets set appropriately in RefreshSha
| |
1122 share_network_checkbox_->SetChecked(true); | |
1115 } | 1123 } |
1116 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1124 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1117 | 1125 |
1118 // Create an error label. | 1126 // Create an error label. |
1119 layout->StartRow(0, column_view_set_id); | 1127 layout->StartRow(0, column_view_set_id); |
1120 layout->SkipColumns(1); | 1128 layout->SkipColumns(1); |
1121 error_label_ = new views::Label(); | 1129 error_label_ = new views::Label(); |
1122 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1130 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1123 error_label_->SetEnabledColor(SK_ColorRED); | 1131 error_label_->SetEnabledColor(SK_ColorRED); |
1124 layout->AddView(error_label_); | 1132 layout->AddView(error_label_); |
1125 | 1133 |
1126 // Initialize the field and checkbox values. | 1134 // Initialize the field and checkbox values. |
1127 | 1135 |
1128 // After creating the fields, we set the values. Fields need to be created | 1136 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(); | 1137 RefreshEapFields(); |
1149 | 1138 |
1150 // Phase 2 authentication and anonymous identity. | 1139 RefreshShareCheckbox(); |
1151 if (Phase2AuthActive()) { | 1140 UpdateErrorLabel(); |
1152 EAPPhase2Auth eap_phase_2_auth = | 1141 |
1153 (wifi ? wifi->eap_phase_2_auth() : EAP_PHASE_2_AUTH_AUTO); | 1142 if (wifi) { |
1154 switch (eap_phase_2_auth) { | 1143 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
1155 case EAP_PHASE_2_AUTH_MD5: | 1144 service_path, |
1156 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5); | 1145 base::Bind(&WifiConfigView::InitFromProperties, |
1157 break; | 1146 AsWeakPtr(), show_8021x), |
1158 case EAP_PHASE_2_AUTH_MSCHAPV2: | 1147 base::Bind(&ShillError, "GetProperties")); |
1159 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2); | 1148 } |
1160 break; | 1149 } |
1161 case EAP_PHASE_2_AUTH_MSCHAP: | 1150 |
1162 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP); | 1151 void WifiConfigView::InitFromProperties( |
1163 break; | 1152 bool show_8021x, |
1164 case EAP_PHASE_2_AUTH_PAP: | 1153 const std::string& service_path, |
1165 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP); | 1154 const base::DictionaryValue& properties) { |
1166 break; | 1155 std::string passphrase; |
1167 case EAP_PHASE_2_AUTH_CHAP: | 1156 properties.GetStringWithoutPathExpansion( |
1168 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP); | 1157 flimflam::kPassphraseProperty, &passphrase); |
1169 break; | 1158 passphrase_textfield_->SetText(UTF8ToUTF16(passphrase)); |
1170 default: | 1159 |
1171 break; | 1160 if (!show_8021x) |
1161 return; | |
1162 | |
1163 std::string identity; | |
1164 properties.GetStringWithoutPathExpansion( | |
1165 flimflam::kIdentityProperty, &identity); | |
1166 identity_textfield_->SetText(UTF8ToUTF16(identity)); | |
1167 | |
1168 // EAP Method | |
1169 std::string eap_method; | |
1170 properties.GetStringWithoutPathExpansion( | |
1171 flimflam::kEapMethodProperty, &eap_method); | |
1172 if (eap_method == flimflam::kEapMethodPEAP) | |
1173 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP); | |
1174 else if (eap_method == flimflam::kEapMethodTTLS) | |
1175 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS); | |
1176 else if (eap_method == flimflam::kEapMethodTLS) | |
1177 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TLS); | |
1178 else if (eap_method == flimflam::kEapMethodLEAP) | |
1179 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_LEAP); | |
1180 RefreshEapFields(); | |
1181 | |
1182 // Phase 2 authentication and anonymous identity. | |
1183 if (Phase2AuthActive()) { | |
1184 std::string eap_phase_2_auth; | |
1185 properties.GetStringWithoutPathExpansion( | |
1186 flimflam::kEapPhase2AuthProperty, &eap_phase_2_auth); | |
1187 if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMD5) | |
1188 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5); | |
1189 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAPV2) | |
1190 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2); | |
1191 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAP) | |
1192 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP); | |
1193 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSPAP) | |
1194 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP); | |
1195 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSCHAP) | |
1196 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP); | |
1197 | |
1198 std::string eap_anonymous_identity; | |
1199 properties.GetStringWithoutPathExpansion( | |
1200 flimflam::kEapAnonymousIdentityProperty, &eap_anonymous_identity); | |
1201 identity_anonymous_textfield_->SetText(UTF8ToUTF16(eap_anonymous_identity)); | |
1202 } | |
1203 | |
1204 // Server CA certificate. | |
1205 if (CaCertActive()) { | |
1206 std::string eap_ca_cert_pem; | |
1207 properties.GetStringWithoutPathExpansion( | |
1208 shill::kEapCaCertPemProperty, &eap_ca_cert_pem); | |
pneubeck (no reviews)
2013/08/06 15:45:19
CaCertPem is a list not a string.
you have to read
stevenjb
2013/08/06 20:23:55
Done.
| |
1209 if (eap_ca_cert_pem.empty()) { | |
1210 bool eap_use_system_cas = false; | |
1211 properties.GetBooleanWithoutPathExpansion( | |
1212 flimflam::kEapUseSystemCasProperty, &eap_use_system_cas); | |
1213 if (eap_use_system_cas) { | |
1214 // "Default" | |
1215 server_ca_cert_combobox_->SetSelectedIndex(0); | |
1216 } else { | |
1217 // "Do not check". | |
1218 server_ca_cert_combobox_->SetSelectedIndex( | |
1219 server_ca_cert_combobox_->model()->GetItemCount() - 1); | |
1172 } | 1220 } |
1173 | 1221 } else { |
1174 const std::string& eap_anonymous_identity = | 1222 // Select the certificate if available. |
1175 (wifi ? wifi->eap_anonymous_identity() : std::string()); | 1223 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( |
1176 identity_anonymous_textfield_->SetText( | 1224 CertLibrary::CERT_TYPE_SERVER_CA, eap_ca_cert_pem); |
1177 UTF8ToUTF16(eap_anonymous_identity)); | 1225 if (cert_index >= 0) { |
1178 } | 1226 // Skip item for "Default". |
1179 | 1227 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 } | 1228 } |
1202 } | 1229 } |
1230 } | |
1203 | 1231 |
1204 // User certificate. | 1232 // User certificate. |
1205 if (UserCertActive()) { | 1233 if (UserCertActive()) { |
1206 const std::string& pkcs11_id = | 1234 std::string eap_cert_id; |
1207 (wifi ? wifi->eap_client_cert_pkcs11_id() : std::string()); | 1235 properties.GetStringWithoutPathExpansion( |
1208 if (!pkcs11_id.empty()) { | 1236 flimflam::kEapCertIdProperty, &eap_cert_id); |
1209 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( | 1237 if (!eap_cert_id.empty()) { |
1210 CertLibrary::CERT_TYPE_USER, pkcs11_id); | 1238 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( |
1211 if (cert_index >= 0) { | 1239 CertLibrary::CERT_TYPE_USER, eap_cert_id); |
1212 user_cert_combobox_->SetSelectedIndex(cert_index); | 1240 if (cert_index >= 0) |
1213 } | 1241 user_cert_combobox_->SetSelectedIndex(cert_index); |
1214 } | |
1215 } | 1242 } |
1243 } | |
1216 | 1244 |
1217 // Identity is always active. | 1245 // Identity is always active. |
1218 const std::string& eap_identity = | 1246 std::string eap_identity; |
1219 (wifi ? wifi->eap_identity() : std::string()); | 1247 properties.GetStringWithoutPathExpansion( |
1220 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); | 1248 flimflam::kEapIdentityProperty, &eap_identity); |
1249 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); | |
1221 | 1250 |
1222 // Passphrase | 1251 // Passphrase |
1223 if (PassphraseActive()) { | 1252 if (PassphraseActive()) { |
1224 const std::string& eap_passphrase = | 1253 std::string eap_password; |
1225 (wifi ? wifi->eap_passphrase() : std::string()); | 1254 properties.GetStringWithoutPathExpansion( |
1226 passphrase_textfield_->SetText(UTF8ToUTF16(eap_passphrase)); | 1255 flimflam::kEapPasswordProperty, &eap_password); |
1227 } | 1256 passphrase_textfield_->SetText(UTF8ToUTF16(eap_password)); |
1257 } | |
1228 | 1258 |
1229 // Save credentials | 1259 // Save credentials |
1230 bool save_credentials = (wifi ? wifi->save_credentials() : false); | 1260 bool save_credentials = false; |
1231 save_credentials_checkbox_->SetChecked(save_credentials); | 1261 properties.GetBooleanWithoutPathExpansion( |
1232 } | 1262 flimflam::kSaveCredentialsProperty, &save_credentials); |
1263 save_credentials_checkbox_->SetChecked(save_credentials); | |
1233 | 1264 |
1234 RefreshShareCheckbox(); | 1265 RefreshShareCheckbox(); |
1235 UpdateErrorLabel(); | 1266 UpdateErrorLabel(); |
1236 } | 1267 } |
1237 | 1268 |
1238 void WifiConfigView::InitFocus() { | 1269 void WifiConfigView::InitFocus() { |
1239 views::View* view_to_focus = GetInitiallyFocusedView(); | 1270 views::View* view_to_focus = GetInitiallyFocusedView(); |
1240 if (view_to_focus) | 1271 if (view_to_focus) |
1241 view_to_focus->RequestFocus(); | 1272 view_to_focus->RequestFocus(); |
1242 } | 1273 } |
1243 | 1274 |
1244 // static | 1275 // static |
1245 void WifiConfigView::ParseWiFiUIProperty( | 1276 void WifiConfigView::ParseWiFiUIProperty( |
1246 NetworkPropertyUIData* property_ui_data, | 1277 NetworkPropertyUIData* property_ui_data, |
1247 Network* network, | 1278 const NetworkState* network, |
1248 const std::string& key) { | 1279 const std::string& key) { |
1249 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | 1280 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
1250 const base::DictionaryValue* onc = | 1281 const base::DictionaryValue* onc = |
1251 NetworkConfigView::FindPolicyForActiveUser(network, &onc_source); | 1282 network_connect::FindPolicyForActiveUser(network, &onc_source); |
1252 | 1283 |
1253 property_ui_data->ParseOncProperty( | 1284 property_ui_data->ParseOncProperty( |
1254 onc_source, | 1285 onc_source, |
1255 onc, | 1286 onc, |
1256 base::StringPrintf("%s.%s", onc::network_config::kWiFi, key.c_str())); | 1287 base::StringPrintf("%s.%s", onc::network_config::kWiFi, key.c_str())); |
1257 } | 1288 } |
1258 | 1289 |
1259 // static | 1290 // static |
1260 void WifiConfigView::ParseWiFiEAPUIProperty( | 1291 void WifiConfigView::ParseWiFiEAPUIProperty( |
1261 NetworkPropertyUIData* property_ui_data, | 1292 NetworkPropertyUIData* property_ui_data, |
1262 Network* network, | 1293 const NetworkState* network, |
1263 const std::string& key) { | 1294 const std::string& key) { |
1264 ParseWiFiUIProperty( | 1295 ParseWiFiUIProperty( |
1265 property_ui_data, network, | 1296 property_ui_data, network, |
1266 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); | 1297 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); |
1267 } | 1298 } |
1268 | 1299 |
1269 } // namespace chromeos | 1300 } // namespace chromeos |
OLD | NEW |