Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/chromeos/options/wifi_config_view.cc

Issue 21046008: Convert all connect code to use NetworkHandler instead of NetworkLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Round 2.1 Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 weak_ptr_factory_(this) {
348 } 360 Init(show_8021x);
349
350 WifiConfigView::WifiConfigView(NetworkConfigView* parent, bool show_8021x)
351 : ChildNetworkConfigView(parent),
352 ssid_textfield_(NULL),
353 eap_method_combobox_(NULL),
354 phase_2_auth_label_(NULL),
355 phase_2_auth_combobox_(NULL),
356 user_cert_label_(NULL),
357 user_cert_combobox_(NULL),
358 server_ca_cert_label_(NULL),
359 server_ca_cert_combobox_(NULL),
360 identity_label_(NULL),
361 identity_textfield_(NULL),
362 identity_anonymous_label_(NULL),
363 identity_anonymous_textfield_(NULL),
364 save_credentials_checkbox_(NULL),
365 share_network_checkbox_(NULL),
366 shared_network_label_(NULL),
367 security_combobox_(NULL),
368 passphrase_label_(NULL),
369 passphrase_textfield_(NULL),
370 passphrase_visible_button_(NULL),
371 error_label_(NULL) {
372 Init(NULL, show_8021x);
373 } 361 }
374 362
375 WifiConfigView::~WifiConfigView() { 363 WifiConfigView::~WifiConfigView() {
376 CertLibrary::Get()->RemoveObserver(this); 364 CertLibrary::Get()->RemoveObserver(this);
377 } 365 }
378 366
379 string16 WifiConfigView::GetTitle() const { 367 string16 WifiConfigView::GetTitle() const {
380 return l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_JOIN_WIFI_NETWORKS); 368 return l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_JOIN_WIFI_NETWORKS);
381 } 369 }
382 370
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 security_combobox_->selected_index() == SECURITY_INDEX_NONE) { 522 security_combobox_->selected_index() == SECURITY_INDEX_NONE) {
535 share_network_checkbox_->SetEnabled(false); 523 share_network_checkbox_->SetEnabled(false);
536 share_network_checkbox_->SetChecked(true); 524 share_network_checkbox_->SetChecked(true);
537 } else if (eap_method_combobox_ && 525 } else if (eap_method_combobox_ &&
538 (eap_method_combobox_->selected_index() == EAP_METHOD_INDEX_TLS || 526 (eap_method_combobox_->selected_index() == EAP_METHOD_INDEX_TLS ||
539 user_cert_combobox_->selected_index() != 0)) { 527 user_cert_combobox_->selected_index() != 0)) {
540 // Can not share TLS network (requires certificate), or any network where 528 // Can not share TLS network (requires certificate), or any network where
541 // user certificates are enabled. 529 // user certificates are enabled.
542 share_network_checkbox_->SetEnabled(false); 530 share_network_checkbox_->SetEnabled(false);
543 share_network_checkbox_->SetChecked(false); 531 share_network_checkbox_->SetChecked(false);
544 } else if (!LoginState::Get()->IsUserLoggedIn()) { 532 } else if (!LoginState::Get()->IsUserAuthenticated()) {
545 // If not logged in, networks must be shared. 533 // If not logged in as an authenticated user, networks must be shared.
546 share_network_checkbox_->SetEnabled(false); 534 share_network_checkbox_->SetEnabled(false);
547 share_network_checkbox_->SetChecked(true); 535 share_network_checkbox_->SetChecked(true);
548 } else { 536 } else {
549 share_network_checkbox_->SetEnabled(true); 537 share_network_checkbox_->SetEnabled(true);
550 share_network_checkbox_->SetChecked(false); // Default to unshared. 538 share_network_checkbox_->SetChecked(false); // Default to unshared.
551 } 539 }
552 } 540 }
553 541
554 void WifiConfigView::UpdateErrorLabel() { 542 void WifiConfigView::UpdateErrorLabel() {
555 std::string error_msg; 543 base::string16 error_msg;
556 if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) { 544 if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) {
557 if (!HaveUserCerts()) { 545 if (!HaveUserCerts()) {
558 if (!LoginState::Get()->IsUserLoggedIn()) { 546 if (!LoginState::Get()->IsUserAuthenticated()) {
559 error_msg = l10n_util::GetStringUTF8( 547 error_msg = l10n_util::GetStringUTF16(
560 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT); 548 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT);
561 } else { 549 } else {
562 error_msg = l10n_util::GetStringUTF8( 550 error_msg = l10n_util::GetStringUTF16(
563 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); 551 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT);
564 } 552 }
565 } else if (!IsUserCertValid()) { 553 } else if (!IsUserCertValid()) {
566 error_msg = l10n_util::GetStringUTF8( 554 error_msg = l10n_util::GetStringUTF16(
567 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); 555 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED);
568 } 556 }
569 } 557 }
570 if (error_msg.empty() && !service_path_.empty()) { 558 if (error_msg.empty() && !service_path_.empty()) {
571 NetworkLibrary* cros = NetworkLibrary::Get(); 559 const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()->
572 const WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); 560 GetNetworkState(service_path_);
573 if (wifi && wifi->failed()) { 561 if (wifi && wifi->connection_state() == flimflam::kStateFailure)
574 bool passphrase_empty = wifi->GetPassphrase().empty(); 562 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 } 563 }
594 if (!error_msg.empty()) { 564 if (!error_msg.empty()) {
595 error_label_->SetText(UTF8ToUTF16(error_msg)); 565 error_label_->SetText(error_msg);
596 error_label_->SetVisible(true); 566 error_label_->SetVisible(true);
597 } else { 567 } else {
598 error_label_->SetVisible(false); 568 error_label_->SetVisible(false);
599 } 569 }
600 } 570 }
601 571
602 void WifiConfigView::ContentsChanged(views::Textfield* sender, 572 void WifiConfigView::ContentsChanged(views::Textfield* sender,
603 const string16& new_contents) { 573 const string16& new_contents) {
604 UpdateDialogButtons(); 574 UpdateDialogButtons();
605 } 575 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 UpdateErrorLabel(); 614 UpdateErrorLabel();
645 } 615 }
646 616
647 void WifiConfigView::OnCertificatesLoaded(bool initial_load) { 617 void WifiConfigView::OnCertificatesLoaded(bool initial_load) {
648 RefreshEapFields(); 618 RefreshEapFields();
649 UpdateDialogButtons(); 619 UpdateDialogButtons();
650 UpdateErrorLabel(); 620 UpdateErrorLabel();
651 } 621 }
652 622
653 bool WifiConfigView::Login() { 623 bool WifiConfigView::Login() {
654 NetworkLibrary* cros = NetworkLibrary::Get(); 624 const bool share_default = true;
655 if (service_path_.empty()) { 625 if (service_path_.empty()) {
656 const bool share_default = true; // share networks by default 626 // Set configuration properties.
627 base::DictionaryValue properties;
628 properties.SetStringWithoutPathExpansion(
629 flimflam::kTypeProperty, flimflam::kTypeWifi);
630 properties.SetStringWithoutPathExpansion(
631 flimflam::kSSIDProperty, GetSsid());
632 properties.SetStringWithoutPathExpansion(
633 flimflam::kModeProperty, flimflam::kModeManaged);
634 properties.SetBooleanWithoutPathExpansion(
635 flimflam::kSaveCredentialsProperty, GetSaveCredentials());
636 std::string security = flimflam::kSecurityNone;
657 if (!eap_method_combobox_) { 637 if (!eap_method_combobox_) {
658 // Hidden ordinary Wi-Fi connection. 638 // Hidden ordinary Wi-Fi connection.
659 ConnectionSecurity security = SECURITY_UNKNOWN;
660 switch (security_combobox_->selected_index()) { 639 switch (security_combobox_->selected_index()) {
661 case SECURITY_INDEX_NONE: 640 case SECURITY_INDEX_NONE:
662 security = SECURITY_NONE; 641 security = flimflam::kSecurityNone;
663 break; 642 break;
664 case SECURITY_INDEX_WEP: 643 case SECURITY_INDEX_WEP:
665 security = SECURITY_WEP; 644 security = flimflam::kSecurityWep;
666 break; 645 break;
667 case SECURITY_INDEX_PSK: 646 case SECURITY_INDEX_PSK:
668 security = SECURITY_PSK; 647 security = flimflam::kSecurityPsk;
669 break; 648 break;
670 } 649 }
671 cros->ConnectToUnconfiguredWifiNetwork( 650 std::string passphrase = GetPassphrase();
672 GetSsid(), 651 if (!passphrase.empty()) {
673 security, 652 properties.SetStringWithoutPathExpansion(
674 GetPassphrase(), 653 flimflam::kPassphraseProperty, GetPassphrase());
675 NULL, 654 }
676 GetSaveCredentials(),
677 GetShareNetwork(share_default));
678 } else { 655 } else {
679 // Hidden 802.1X EAP Wi-Fi connection. 656 // Hidden 802.1X EAP Wi-Fi connection.
680 chromeos::NetworkLibrary::EAPConfigData config_data; 657 security = flimflam::kSecurity8021x;
681 config_data.method = GetEapMethod(); 658 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 } 659 }
660 properties.SetStringWithoutPathExpansion(
661 flimflam::kSecurityProperty, security);
662
663 // Configure and connect to network.
664 bool shared = GetShareNetwork(share_default);
665 ash::network_connect::CreateConfigurationAndConnect(&properties, shared);
696 } else { 666 } else {
697 WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); 667 const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()->
668 GetNetworkState(service_path_);
698 if (!wifi) { 669 if (!wifi) {
699 // Shill no longer knows about this wifi network (edge case). 670 // Shill no longer knows about this wifi network (edge case).
700 // TODO(stevenjb): Add a notification (chromium-os13225). 671 // TODO(stevenjb): Add notification for this.
701 LOG(WARNING) << "Wifi network: " << service_path_ << " no longer exists."; 672 NET_LOG_ERROR("Network not found", service_path_);
702 return true; 673 return true; // Close dialog
703 } 674 }
675 base::DictionaryValue properties;
704 if (eap_method_combobox_) { 676 if (eap_method_combobox_) {
705 // Visible 802.1X EAP Wi-Fi connection. 677 // Visible 802.1X EAP Wi-Fi connection.
706 EAPMethod method = GetEapMethod(); 678 SetEapProperties(&properties);
707 DCHECK(method != EAP_METHOD_UNKNOWN); 679 properties.SetBooleanWithoutPathExpansion(
708 wifi->SetEAPMethod(method); 680 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 { 681 } else {
718 // Visible ordinary Wi-Fi connection. 682 // Visible ordinary Wi-Fi connection.
719 const std::string passphrase = GetPassphrase(); 683 const std::string passphrase = GetPassphrase();
720 if (passphrase != wifi->passphrase()) 684 if (!passphrase.empty()) {
721 wifi->SetPassphrase(passphrase); 685 properties.SetStringWithoutPathExpansion(
686 flimflam::kPassphraseProperty, passphrase);
687 }
722 } 688 }
723 bool share_default = (wifi->profile_type() != PROFILE_USER); 689 // If the network is not in a profile, set the Profile property
724 wifi->SetEnrollmentDelegate( 690 // based on the setting of the 'Share' checkbox.
725 CreateEnrollmentDelegate(GetWidget()->GetNativeWindow(), 691 if (wifi->profile_path().empty()) {
726 wifi->name(), 692 bool share_network = GetShareNetwork(share_default);
727 ProfileManager::GetLastUsedProfile())); 693 std::string profile_path;
728 cros->ConnectToWifiNetwork(wifi, GetShareNetwork(share_default)); 694 if (share_network) {
729 // Connection failures are responsible for updating the UI, including 695 profile_path = NetworkProfileHandler::kSharedProfilePath;
730 // reopening dialogs. 696 } else {
697 const NetworkProfile* profile =
698 NetworkHandler::Get()->network_profile_handler()->
699 GetDefaultUserProfile();
700 if (profile)
701 profile_path = profile->path;
702 else
703 NET_LOG_ERROR("Unable to set user profile", service_path_);
704 }
705 if (!profile_path.empty()) {
706 properties.SetStringWithoutPathExpansion(
707 flimflam::kProfileProperty, profile_path);
708 }
709 }
710 ash::network_connect::ConfigureNetworkAndConnect(service_path_, properties);
pneubeck (no reviews) 2013/08/07 16:20:59 This is calling Service::SetProperties, which igno
stevenjb 2013/08/07 20:22:05 Hmm, interesting question. The existing code is us
731 } 711 }
732 return true; // dialog will be closed 712 return true; // dialog will be closed
733 } 713 }
734 714
735 std::string WifiConfigView::GetSsid() const { 715 std::string WifiConfigView::GetSsid() const {
736 std::string result; 716 std::string result;
737 if (ssid_textfield_ != NULL) { 717 if (ssid_textfield_ != NULL) {
738 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); 718 std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text());
739 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); 719 TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result);
740 } 720 }
(...skipping 12 matching lines...) Expand all
753 return true; // share networks by default (e.g. non 8021x). 733 return true; // share networks by default (e.g. non 8021x).
754 return save_credentials_checkbox_->checked(); 734 return save_credentials_checkbox_->checked();
755 } 735 }
756 736
757 bool WifiConfigView::GetShareNetwork(bool share_default) const { 737 bool WifiConfigView::GetShareNetwork(bool share_default) const {
758 if (!share_network_checkbox_) 738 if (!share_network_checkbox_)
759 return share_default; 739 return share_default;
760 return share_network_checkbox_->checked(); 740 return share_network_checkbox_->checked();
761 } 741 }
762 742
763 EAPMethod WifiConfigView::GetEapMethod() const { 743 std::string WifiConfigView::GetEapMethod() const {
764 DCHECK(eap_method_combobox_); 744 DCHECK(eap_method_combobox_);
765 switch (eap_method_combobox_->selected_index()) { 745 switch (eap_method_combobox_->selected_index()) {
746 case EAP_METHOD_INDEX_PEAP:
747 return flimflam::kEapMethodPEAP;
748 case EAP_METHOD_INDEX_TLS:
749 return flimflam::kEapMethodTLS;
750 case EAP_METHOD_INDEX_TTLS:
751 return flimflam::kEapMethodTTLS;
752 case EAP_METHOD_INDEX_LEAP:
753 return flimflam::kEapMethodLEAP;
766 case EAP_METHOD_INDEX_NONE: 754 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: 755 default:
777 return EAP_METHOD_UNKNOWN; 756 return "";
778 } 757 }
779 } 758 }
780 759
781 EAPPhase2Auth WifiConfigView::GetEapPhase2Auth() const { 760 std::string WifiConfigView::GetEapPhase2Auth() const {
782 DCHECK(phase_2_auth_combobox_); 761 DCHECK(phase_2_auth_combobox_);
762 bool is_peap = (GetEapMethod() == flimflam::kEapMethodPEAP);
783 switch (phase_2_auth_combobox_->selected_index()) { 763 switch (phase_2_auth_combobox_->selected_index()) {
764 case PHASE_2_AUTH_INDEX_MD5:
765 return is_peap ? flimflam::kEapPhase2AuthPEAPMD5
766 : flimflam::kEapPhase2AuthTTLSMD5;
767 case PHASE_2_AUTH_INDEX_MSCHAPV2:
768 return is_peap ? flimflam::kEapPhase2AuthPEAPMSCHAPV2
769 : flimflam::kEapPhase2AuthTTLSMSCHAPV2;
770 case PHASE_2_AUTH_INDEX_MSCHAP:
771 return flimflam::kEapPhase2AuthTTLSMSCHAP;
772 case PHASE_2_AUTH_INDEX_PAP:
773 return flimflam::kEapPhase2AuthTTLSPAP;
774 case PHASE_2_AUTH_INDEX_CHAP:
775 return flimflam::kEapPhase2AuthTTLSCHAP;
784 case PHASE_2_AUTH_INDEX_AUTO: 776 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: 777 default:
797 return EAP_PHASE_2_AUTH_AUTO; 778 return "";
798 } 779 }
799 } 780 }
800 781
801 std::string WifiConfigView::GetEapServerCaCertPEM() const { 782 std::string WifiConfigView::GetEapServerCaCertPEM() const {
802 DCHECK(server_ca_cert_combobox_); 783 DCHECK(server_ca_cert_combobox_);
803 int index = server_ca_cert_combobox_->selected_index(); 784 int index = server_ca_cert_combobox_->selected_index();
804 if (index == 0) { 785 if (index == 0) {
805 // First item is "Default". 786 // First item is "Default".
806 return std::string(); 787 return std::string();
807 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { 788 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) {
(...skipping 27 matching lines...) Expand all
835 std::string WifiConfigView::GetEapIdentity() const { 816 std::string WifiConfigView::GetEapIdentity() const {
836 DCHECK(identity_textfield_); 817 DCHECK(identity_textfield_);
837 return UTF16ToUTF8(identity_textfield_->text()); 818 return UTF16ToUTF8(identity_textfield_->text());
838 } 819 }
839 820
840 std::string WifiConfigView::GetEapAnonymousIdentity() const { 821 std::string WifiConfigView::GetEapAnonymousIdentity() const {
841 DCHECK(identity_anonymous_textfield_); 822 DCHECK(identity_anonymous_textfield_);
842 return UTF16ToUTF8(identity_anonymous_textfield_->text()); 823 return UTF16ToUTF8(identity_anonymous_textfield_->text());
843 } 824 }
844 825
826 void WifiConfigView::SetEapProperties(base::DictionaryValue* properties) {
827 properties->SetStringWithoutPathExpansion(
828 flimflam::kEapIdentityProperty, GetEapIdentity());
829 properties->SetStringWithoutPathExpansion(
830 flimflam::kEapMethodProperty, GetEapMethod());
831 properties->SetStringWithoutPathExpansion(
832 flimflam::kEapPhase2AuthProperty, GetEapPhase2Auth());
833 properties->SetStringWithoutPathExpansion(
834 flimflam::kEapAnonymousIdentityProperty, GetEapAnonymousIdentity());
835
836 // shill requires both CertID and KeyID for TLS connections, despite
837 // the fact that by convention they are the same ID.
838 properties->SetStringWithoutPathExpansion(
839 flimflam::kEapCertIdProperty, GetEapClientCertPkcs11Id());
840 properties->SetStringWithoutPathExpansion(
841 flimflam::kEapKeyIdProperty, GetEapClientCertPkcs11Id());
842
843 properties->SetBooleanWithoutPathExpansion(
844 flimflam::kEapUseSystemCasProperty, GetEapUseSystemCas());
845 properties->SetStringWithoutPathExpansion(
846 flimflam::kEapPasswordProperty, GetPassphrase());
847
848 base::ListValue* pem_list = new base::ListValue;
849 pem_list->AppendString(GetEapServerCaCertPEM());
850 properties->SetWithoutPathExpansion(
851 shill::kEapCaCertPemProperty, pem_list);
852 }
853
845 void WifiConfigView::Cancel() { 854 void WifiConfigView::Cancel() {
846 } 855 }
847 856
848 // This will initialize the view depending on if we have a wifi network or not. 857 // 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 858 // And if we are doing simple password encryption or the more complicated
850 // 802.1x encryption. 859 // 802.1x encryption.
851 // If we are creating the "Join other network..." dialog, we will allow user 860 // 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 861 // to enter the data. And if they select the 802.1x encryption, we will show
853 // the 802.1x fields. 862 // the 802.1x fields.
854 void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) { 863 void WifiConfigView::Init(bool show_8021x) {
864 const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()->
865 GetNetworkState(service_path_);
855 if (wifi) { 866 if (wifi) {
867 DCHECK(wifi->type() == flimflam::kTypeWifi);
868 if (wifi->security() == flimflam::kSecurity8021x)
869 show_8021x = true;
856 ParseWiFiEAPUIProperty(&eap_method_ui_data_, wifi, onc::eap::kOuter); 870 ParseWiFiEAPUIProperty(&eap_method_ui_data_, wifi, onc::eap::kOuter);
857 ParseWiFiEAPUIProperty(&phase_2_auth_ui_data_, wifi, onc::eap::kInner); 871 ParseWiFiEAPUIProperty(&phase_2_auth_ui_data_, wifi, onc::eap::kInner);
858 ParseWiFiEAPUIProperty(&user_cert_ui_data_, wifi, onc::eap::kClientCertRef); 872 ParseWiFiEAPUIProperty(&user_cert_ui_data_, wifi, onc::eap::kClientCertRef);
859 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, 873 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi,
860 onc::eap::kServerCARef); 874 onc::eap::kServerCARef);
861 if (server_ca_cert_ui_data_.IsManaged()) { 875 if (server_ca_cert_ui_data_.IsManaged()) {
862 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi, 876 ParseWiFiEAPUIProperty(&server_ca_cert_ui_data_, wifi,
863 onc::eap::kUseSystemCAs); 877 onc::eap::kUseSystemCAs);
864 } 878 }
865 ParseWiFiEAPUIProperty(&identity_ui_data_, wifi, onc::eap::kIdentity); 879 ParseWiFiEAPUIProperty(&identity_ui_data_, wifi, onc::eap::kIdentity);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 // Identity 1014 // Identity
1001 layout->StartRow(0, column_view_set_id); 1015 layout->StartRow(0, column_view_set_id);
1002 string16 identity_label_text = l10n_util::GetStringUTF16( 1016 string16 identity_label_text = l10n_util::GetStringUTF16(
1003 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); 1017 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY);
1004 identity_label_ = new views::Label(identity_label_text); 1018 identity_label_ = new views::Label(identity_label_text);
1005 layout->AddView(identity_label_); 1019 layout->AddView(identity_label_);
1006 identity_textfield_ = new views::Textfield( 1020 identity_textfield_ = new views::Textfield(
1007 views::Textfield::STYLE_DEFAULT); 1021 views::Textfield::STYLE_DEFAULT);
1008 identity_textfield_->SetAccessibleName(identity_label_text); 1022 identity_textfield_->SetAccessibleName(identity_label_text);
1009 identity_textfield_->SetController(this); 1023 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()); 1024 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable());
1013 layout->AddView(identity_textfield_); 1025 layout->AddView(identity_textfield_);
1014 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); 1026 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_));
1015 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 1027 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
1016 } 1028 }
1017 1029
1018 // Passphrase input 1030 // Passphrase input
1019 layout->StartRow(0, column_view_set_id); 1031 layout->StartRow(0, column_view_set_id);
1020 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; 1032 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE;
1021 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); 1033 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id);
1022 passphrase_label_ = new views::Label(passphrase_label_text); 1034 passphrase_label_ = new views::Label(passphrase_label_text);
1023 layout->AddView(passphrase_label_); 1035 layout->AddView(passphrase_label_);
1024 passphrase_textfield_ = new views::Textfield( 1036 passphrase_textfield_ = new views::Textfield(
1025 views::Textfield::STYLE_OBSCURED); 1037 views::Textfield::STYLE_OBSCURED);
1026 passphrase_textfield_->SetController(this); 1038 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. 1039 // Disable passphrase input initially for other network.
1030 passphrase_label_->SetEnabled(wifi != NULL); 1040 passphrase_label_->SetEnabled(wifi != NULL);
1031 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); 1041 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable());
1032 passphrase_textfield_->SetAccessibleName(passphrase_label_text); 1042 passphrase_textfield_->SetAccessibleName(passphrase_label_text);
1033 layout->AddView(passphrase_textfield_); 1043 layout->AddView(passphrase_textfield_);
1034 1044
1035 if (passphrase_ui_data_.IsManaged()) { 1045 if (passphrase_ui_data_.IsManaged()) {
1036 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_)); 1046 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_));
1037 } else { 1047 } else {
1038 // Password visible button. 1048 // Password visible button.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); 1105 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS));
1096 save_credentials_checkbox_->SetEnabled( 1106 save_credentials_checkbox_->SetEnabled(
1097 save_credentials_ui_data_.IsEditable()); 1107 save_credentials_ui_data_.IsEditable());
1098 layout->SkipColumns(1); 1108 layout->SkipColumns(1);
1099 layout->AddView(save_credentials_checkbox_); 1109 layout->AddView(save_credentials_checkbox_);
1100 layout->AddView( 1110 layout->AddView(
1101 new ControlledSettingIndicatorView(save_credentials_ui_data_)); 1111 new ControlledSettingIndicatorView(save_credentials_ui_data_));
1102 } 1112 }
1103 1113
1104 // Share network 1114 // Share network
1105 if (!wifi || 1115 if (!wifi || wifi->profile_path().empty()) {
1106 (wifi->profile_type() == PROFILE_NONE &&
1107 wifi->IsPassphraseRequired() &&
1108 !wifi->RequiresUserProfile())) {
1109 layout->StartRow(0, column_view_set_id); 1116 layout->StartRow(0, column_view_set_id);
1110 share_network_checkbox_ = new views::Checkbox( 1117 share_network_checkbox_ = new views::Checkbox(
1111 l10n_util::GetStringUTF16( 1118 l10n_util::GetStringUTF16(
1112 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK)); 1119 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK));
1113 layout->SkipColumns(1); 1120 layout->SkipColumns(1);
1114 layout->AddView(share_network_checkbox_); 1121 layout->AddView(share_network_checkbox_);
1115 } 1122 }
1116 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 1123 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
1117 1124
1118 // Create an error label. 1125 // Create an error label.
1119 layout->StartRow(0, column_view_set_id); 1126 layout->StartRow(0, column_view_set_id);
1120 layout->SkipColumns(1); 1127 layout->SkipColumns(1);
1121 error_label_ = new views::Label(); 1128 error_label_ = new views::Label();
1122 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1129 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1123 error_label_->SetEnabledColor(SK_ColorRED); 1130 error_label_->SetEnabledColor(SK_ColorRED);
1124 layout->AddView(error_label_); 1131 layout->AddView(error_label_);
1125 1132
1126 // Initialize the field and checkbox values. 1133 // Initialize the field and checkbox values.
1127 1134
1128 // After creating the fields, we set the values. Fields need to be created 1135 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(); 1136 RefreshEapFields();
1149 1137
1150 // Phase 2 authentication and anonymous identity. 1138 RefreshShareCheckbox();
1151 if (Phase2AuthActive()) { 1139 UpdateErrorLabel();
1152 EAPPhase2Auth eap_phase_2_auth = 1140
1153 (wifi ? wifi->eap_phase_2_auth() : EAP_PHASE_2_AUTH_AUTO); 1141 if (wifi) {
1154 switch (eap_phase_2_auth) { 1142 NetworkHandler::Get()->network_configuration_handler()->GetProperties(
1155 case EAP_PHASE_2_AUTH_MD5: 1143 service_path_,
1156 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5); 1144 base::Bind(&WifiConfigView::InitFromProperties,
1157 break; 1145 weak_ptr_factory_.GetWeakPtr(), show_8021x),
1158 case EAP_PHASE_2_AUTH_MSCHAPV2: 1146 base::Bind(&ShillError, "GetProperties"));
1159 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2); 1147 }
1160 break; 1148 }
1161 case EAP_PHASE_2_AUTH_MSCHAP: 1149
1162 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP); 1150 void WifiConfigView::InitFromProperties(
1163 break; 1151 bool show_8021x,
1164 case EAP_PHASE_2_AUTH_PAP: 1152 const std::string& service_path,
1165 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP); 1153 const base::DictionaryValue& properties) {
1166 break; 1154 std::string passphrase;
1167 case EAP_PHASE_2_AUTH_CHAP: 1155 properties.GetStringWithoutPathExpansion(
1168 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP); 1156 flimflam::kPassphraseProperty, &passphrase);
1169 break; 1157 passphrase_textfield_->SetText(UTF8ToUTF16(passphrase));
1170 default: 1158
1171 break; 1159 if (!show_8021x)
1160 return;
1161
1162 std::string identity;
1163 properties.GetStringWithoutPathExpansion(
1164 flimflam::kIdentityProperty, &identity);
1165 identity_textfield_->SetText(UTF8ToUTF16(identity));
pneubeck (no reviews) 2013/08/07 16:20:59 set below again from kEapIdentityProperty
stevenjb 2013/08/07 20:22:05 Huh, look at that. We were doing the same before.
1166
1167 // EAP Method
1168 std::string eap_method;
1169 properties.GetStringWithoutPathExpansion(
1170 flimflam::kEapMethodProperty, &eap_method);
1171 if (eap_method == flimflam::kEapMethodPEAP)
1172 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP);
1173 else if (eap_method == flimflam::kEapMethodTTLS)
1174 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS);
1175 else if (eap_method == flimflam::kEapMethodTLS)
1176 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TLS);
1177 else if (eap_method == flimflam::kEapMethodLEAP)
1178 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_LEAP);
1179 RefreshEapFields();
pneubeck (no reviews) 2013/08/07 16:20:59 RefreshEapFields calls phase_2_auth_combobox_->Set
stevenjb 2013/08/07 20:22:05 RefreshEapFields() is called whenever eap_method_c
1180
1181 // Phase 2 authentication and anonymous identity.
1182 if (Phase2AuthActive()) {
1183 std::string eap_phase_2_auth;
1184 properties.GetStringWithoutPathExpansion(
1185 flimflam::kEapPhase2AuthProperty, &eap_phase_2_auth);
1186 if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMD5)
1187 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5);
1188 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAPV2)
1189 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2);
1190 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAP)
1191 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP);
1192 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSPAP)
1193 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP);
1194 else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSCHAP)
1195 phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP);
1196
1197 std::string eap_anonymous_identity;
1198 properties.GetStringWithoutPathExpansion(
1199 flimflam::kEapAnonymousIdentityProperty, &eap_anonymous_identity);
1200 identity_anonymous_textfield_->SetText(UTF8ToUTF16(eap_anonymous_identity));
1201 }
1202
1203 // Server CA certificate.
1204 if (CaCertActive()) {
1205 std::string eap_ca_cert_pem;
1206 const base::ListValue* pems = NULL;
1207 if (properties.GetListWithoutPathExpansion(
1208 shill::kEapCaCertPemProperty, &pems))
1209 pems->GetString(0, &eap_ca_cert_pem);
1210 if (eap_ca_cert_pem.empty()) {
1211 bool eap_use_system_cas = false;
1212 properties.GetBooleanWithoutPathExpansion(
1213 flimflam::kEapUseSystemCasProperty, &eap_use_system_cas);
1214 if (eap_use_system_cas) {
1215 // "Default"
1216 server_ca_cert_combobox_->SetSelectedIndex(0);
1217 } else {
1218 // "Do not check".
1219 server_ca_cert_combobox_->SetSelectedIndex(
1220 server_ca_cert_combobox_->model()->GetItemCount() - 1);
1172 } 1221 }
1173 1222 } else {
1174 const std::string& eap_anonymous_identity = 1223 // Select the certificate if available.
1175 (wifi ? wifi->eap_anonymous_identity() : std::string()); 1224 int cert_index = CertLibrary::Get()->GetCertIndexByPEM(
1176 identity_anonymous_textfield_->SetText( 1225 CertLibrary::CERT_TYPE_SERVER_CA, eap_ca_cert_pem);
1177 UTF8ToUTF16(eap_anonymous_identity)); 1226 if (cert_index >= 0) {
1178 } 1227 // Skip item for "Default".
1179 1228 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 } 1229 }
1202 } 1230 }
1231 }
1203 1232
1204 // User certificate. 1233 // User certificate.
1205 if (UserCertActive()) { 1234 if (UserCertActive()) {
1206 const std::string& pkcs11_id = 1235 std::string eap_cert_id;
1207 (wifi ? wifi->eap_client_cert_pkcs11_id() : std::string()); 1236 properties.GetStringWithoutPathExpansion(
1208 if (!pkcs11_id.empty()) { 1237 flimflam::kEapCertIdProperty, &eap_cert_id);
1209 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( 1238 if (!eap_cert_id.empty()) {
1210 CertLibrary::CERT_TYPE_USER, pkcs11_id); 1239 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id(
1211 if (cert_index >= 0) { 1240 CertLibrary::CERT_TYPE_USER, eap_cert_id);
1212 user_cert_combobox_->SetSelectedIndex(cert_index); 1241 if (cert_index >= 0)
1213 } 1242 user_cert_combobox_->SetSelectedIndex(cert_index);
1214 }
1215 } 1243 }
1244 }
1216 1245
1217 // Identity is always active. 1246 // Identity is always active.
1218 const std::string& eap_identity = 1247 std::string eap_identity;
1219 (wifi ? wifi->eap_identity() : std::string()); 1248 properties.GetStringWithoutPathExpansion(
1220 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); 1249 flimflam::kEapIdentityProperty, &eap_identity);
1250 identity_textfield_->SetText(UTF8ToUTF16(eap_identity));
1221 1251
1222 // Passphrase 1252 // Passphrase
1223 if (PassphraseActive()) { 1253 if (PassphraseActive()) {
1224 const std::string& eap_passphrase = 1254 std::string eap_password;
1225 (wifi ? wifi->eap_passphrase() : std::string()); 1255 properties.GetStringWithoutPathExpansion(
1226 passphrase_textfield_->SetText(UTF8ToUTF16(eap_passphrase)); 1256 flimflam::kEapPasswordProperty, &eap_password);
1227 } 1257 passphrase_textfield_->SetText(UTF8ToUTF16(eap_password));
1258 }
1228 1259
1229 // Save credentials 1260 // Save credentials
1230 bool save_credentials = (wifi ? wifi->save_credentials() : false); 1261 bool save_credentials = false;
1231 save_credentials_checkbox_->SetChecked(save_credentials); 1262 properties.GetBooleanWithoutPathExpansion(
1232 } 1263 flimflam::kSaveCredentialsProperty, &save_credentials);
1264 save_credentials_checkbox_->SetChecked(save_credentials);
1233 1265
1234 RefreshShareCheckbox(); 1266 RefreshShareCheckbox();
1235 UpdateErrorLabel(); 1267 UpdateErrorLabel();
1236 } 1268 }
1237 1269
1238 void WifiConfigView::InitFocus() { 1270 void WifiConfigView::InitFocus() {
1239 views::View* view_to_focus = GetInitiallyFocusedView(); 1271 views::View* view_to_focus = GetInitiallyFocusedView();
1240 if (view_to_focus) 1272 if (view_to_focus)
1241 view_to_focus->RequestFocus(); 1273 view_to_focus->RequestFocus();
1242 } 1274 }
1243 1275
1244 // static 1276 // static
1245 void WifiConfigView::ParseWiFiUIProperty( 1277 void WifiConfigView::ParseWiFiUIProperty(
1246 NetworkPropertyUIData* property_ui_data, 1278 NetworkPropertyUIData* property_ui_data,
1247 Network* network, 1279 const NetworkState* network,
1248 const std::string& key) { 1280 const std::string& key) {
1249 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; 1281 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE;
1250 const base::DictionaryValue* onc = 1282 const base::DictionaryValue* onc =
1251 NetworkConfigView::FindPolicyForActiveUser(network, &onc_source); 1283 network_connect::FindPolicyForActiveUser(network, &onc_source);
1252 1284
1253 property_ui_data->ParseOncProperty( 1285 property_ui_data->ParseOncProperty(
1254 onc_source, 1286 onc_source,
1255 onc, 1287 onc,
1256 base::StringPrintf("%s.%s", onc::network_config::kWiFi, key.c_str())); 1288 base::StringPrintf("%s.%s", onc::network_config::kWiFi, key.c_str()));
1257 } 1289 }
1258 1290
1259 // static 1291 // static
1260 void WifiConfigView::ParseWiFiEAPUIProperty( 1292 void WifiConfigView::ParseWiFiEAPUIProperty(
1261 NetworkPropertyUIData* property_ui_data, 1293 NetworkPropertyUIData* property_ui_data,
1262 Network* network, 1294 const NetworkState* network,
1263 const std::string& key) { 1295 const std::string& key) {
1264 ParseWiFiUIProperty( 1296 ParseWiFiUIProperty(
1265 property_ui_data, network, 1297 property_ui_data, network,
1266 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); 1298 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str()));
1267 } 1299 }
1268 1300
1269 } // namespace chromeos 1301 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/options/wifi_config_view.h ('k') | chrome/browser/chromeos/options/wimax_config_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698