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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/options/wifi_config_view.cc
diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc
index 211f728cecf50854912fd1ee4304a82a2662f3d4..0da5619f44704fb309f6bfd4aa5afe181489f6da 100644
--- a/chrome/browser/chromeos/options/wifi_config_view.cc
+++ b/chrome/browser/chromeos/options/wifi_config_view.cc
@@ -4,19 +4,28 @@
#include "chrome/browser/chromeos/options/wifi_config_view.h"
+#include "ash/system/chromeos/network/network_connect.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/enrollment_dialog_view.h"
+#include "chrome/browser/chromeos/options/network_connect.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/login/login_state.h"
+#include "chromeos/network/network_configuration_handler.h"
+#include "chromeos/network/network_event_log.h"
+#include "chromeos/network/network_handler.h"
+#include "chromeos/network/network_profile.h"
+#include "chromeos/network/network_profile_handler.h"
+#include "chromeos/network/network_state.h"
+#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_ui_data.h"
#include "chromeos/network/onc/onc_constants.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
+#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/events/event.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -34,11 +43,6 @@ namespace chromeos {
namespace {
-// Returns true if network is known to require 802.1x.
-bool Is8021x(const WifiNetwork* wifi) {
- return wifi && wifi->encrypted() && wifi->encryption() == SECURITY_8021X;
-}
-
// Combobox that supports a preferred width. Used by Server CA combobox
// because the strings inside it are too wide.
class ComboboxWithWidth : public views::Combobox {
@@ -85,6 +89,12 @@ enum Phase2AuthComboboxIndex {
PHASE_2_AUTH_INDEX_COUNT = 6
};
+void ShillError(const std::string& function,
+ const std::string& error_name,
+ scoped_ptr<base::DictionaryValue> error_data) {
+ NET_LOG_ERROR("Shill Error from WifiConfigView: " + error_name, function);
+}
+
} // namespace
namespace internal {
@@ -322,8 +332,10 @@ string16 UserCertComboboxModel::GetItemAt(int index) {
} // namespace internal
-WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi)
- : ChildNetworkConfigView(parent, wifi),
+WifiConfigView::WifiConfigView(NetworkConfigView* parent,
+ const std::string& service_path,
+ bool show_8021x)
+ : ChildNetworkConfigView(parent, service_path),
ssid_textfield_(NULL),
eap_method_combobox_(NULL),
phase_2_auth_label_(NULL),
@@ -343,33 +355,9 @@ WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi)
passphrase_label_(NULL),
passphrase_textfield_(NULL),
passphrase_visible_button_(NULL),
- error_label_(NULL) {
- Init(wifi, Is8021x(wifi));
-}
-
-WifiConfigView::WifiConfigView(NetworkConfigView* parent, bool show_8021x)
- : ChildNetworkConfigView(parent),
- ssid_textfield_(NULL),
- eap_method_combobox_(NULL),
- phase_2_auth_label_(NULL),
- phase_2_auth_combobox_(NULL),
- user_cert_label_(NULL),
- user_cert_combobox_(NULL),
- server_ca_cert_label_(NULL),
- server_ca_cert_combobox_(NULL),
- identity_label_(NULL),
- identity_textfield_(NULL),
- identity_anonymous_label_(NULL),
- identity_anonymous_textfield_(NULL),
- save_credentials_checkbox_(NULL),
- share_network_checkbox_(NULL),
- shared_network_label_(NULL),
- security_combobox_(NULL),
- passphrase_label_(NULL),
- passphrase_textfield_(NULL),
- passphrase_visible_button_(NULL),
- error_label_(NULL) {
- Init(NULL, show_8021x);
+ error_label_(NULL),
+ weak_ptr_factory_(this) {
+ Init(show_8021x);
}
WifiConfigView::~WifiConfigView() {
@@ -541,8 +529,8 @@ void WifiConfigView::RefreshShareCheckbox() {
// user certificates are enabled.
share_network_checkbox_->SetEnabled(false);
share_network_checkbox_->SetChecked(false);
- } else if (!LoginState::Get()->IsUserLoggedIn()) {
- // If not logged in, networks must be shared.
+ } else if (!LoginState::Get()->IsUserAuthenticated()) {
+ // If not logged in as an authenticated user, networks must be shared.
share_network_checkbox_->SetEnabled(false);
share_network_checkbox_->SetChecked(true);
} else {
@@ -552,47 +540,29 @@ void WifiConfigView::RefreshShareCheckbox() {
}
void WifiConfigView::UpdateErrorLabel() {
- std::string error_msg;
+ base::string16 error_msg;
if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) {
if (!HaveUserCerts()) {
- if (!LoginState::Get()->IsUserLoggedIn()) {
- error_msg = l10n_util::GetStringUTF8(
+ if (!LoginState::Get()->IsUserAuthenticated()) {
+ error_msg = l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT);
} else {
- error_msg = l10n_util::GetStringUTF8(
+ error_msg = l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT);
}
} else if (!IsUserCertValid()) {
- error_msg = l10n_util::GetStringUTF8(
+ error_msg = l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED);
}
}
if (error_msg.empty() && !service_path_.empty()) {
- NetworkLibrary* cros = NetworkLibrary::Get();
- const WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_);
- if (wifi && wifi->failed()) {
- bool passphrase_empty = wifi->GetPassphrase().empty();
- switch (wifi->error()) {
- case ERROR_BAD_PASSPHRASE:
- if (!passphrase_empty) {
- error_msg = l10n_util::GetStringUTF8(
- IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE);
- }
- break;
- case ERROR_BAD_WEPKEY:
- if (!passphrase_empty) {
- error_msg = l10n_util::GetStringUTF8(
- IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_WEPKEY);
- }
- break;
- default:
- error_msg = wifi->GetErrorString();
- break;
- }
- }
+ const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()->
+ GetNetworkState(service_path_);
+ if (wifi && wifi->connection_state() == flimflam::kStateFailure)
+ error_msg = ash::network_connect::ErrorString(wifi->error());
}
if (!error_msg.empty()) {
- error_label_->SetText(UTF8ToUTF16(error_msg));
+ error_label_->SetText(error_msg);
error_label_->SetVisible(true);
} else {
error_label_->SetVisible(false);
@@ -651,83 +621,93 @@ void WifiConfigView::OnCertificatesLoaded(bool initial_load) {
}
bool WifiConfigView::Login() {
- NetworkLibrary* cros = NetworkLibrary::Get();
+ const bool share_default = true;
if (service_path_.empty()) {
- const bool share_default = true; // share networks by default
+ // Set configuration properties.
+ base::DictionaryValue properties;
+ properties.SetStringWithoutPathExpansion(
+ flimflam::kTypeProperty, flimflam::kTypeWifi);
+ properties.SetStringWithoutPathExpansion(
+ flimflam::kSSIDProperty, GetSsid());
+ properties.SetStringWithoutPathExpansion(
+ flimflam::kModeProperty, flimflam::kModeManaged);
+ properties.SetBooleanWithoutPathExpansion(
+ flimflam::kSaveCredentialsProperty, GetSaveCredentials());
+ std::string security = flimflam::kSecurityNone;
if (!eap_method_combobox_) {
// Hidden ordinary Wi-Fi connection.
- ConnectionSecurity security = SECURITY_UNKNOWN;
switch (security_combobox_->selected_index()) {
case SECURITY_INDEX_NONE:
- security = SECURITY_NONE;
+ security = flimflam::kSecurityNone;
break;
case SECURITY_INDEX_WEP:
- security = SECURITY_WEP;
+ security = flimflam::kSecurityWep;
break;
case SECURITY_INDEX_PSK:
- security = SECURITY_PSK;
+ security = flimflam::kSecurityPsk;
break;
}
- cros->ConnectToUnconfiguredWifiNetwork(
- GetSsid(),
- security,
- GetPassphrase(),
- NULL,
- GetSaveCredentials(),
- GetShareNetwork(share_default));
+ std::string passphrase = GetPassphrase();
+ if (!passphrase.empty()) {
+ properties.SetStringWithoutPathExpansion(
+ flimflam::kPassphraseProperty, GetPassphrase());
+ }
} else {
// Hidden 802.1X EAP Wi-Fi connection.
- chromeos::NetworkLibrary::EAPConfigData config_data;
- config_data.method = GetEapMethod();
- config_data.auth = GetEapPhase2Auth();
- config_data.server_ca_cert_pem = GetEapServerCaCertPEM();
- config_data.use_system_cas = GetEapUseSystemCas();
- config_data.client_cert_pkcs11_id = GetEapClientCertPkcs11Id();
- config_data.identity = GetEapIdentity();
- config_data.anonymous_identity = GetEapAnonymousIdentity();
- cros->ConnectToUnconfiguredWifiNetwork(
- GetSsid(),
- SECURITY_8021X,
- GetPassphrase(),
- &config_data,
- GetSaveCredentials(),
- GetShareNetwork(share_default));
+ security = flimflam::kSecurity8021x;
+ SetEapProperties(&properties);
}
+ properties.SetStringWithoutPathExpansion(
+ flimflam::kSecurityProperty, security);
+
+ // Configure and connect to network.
+ bool shared = GetShareNetwork(share_default);
+ ash::network_connect::CreateConfigurationAndConnect(&properties, shared);
} else {
- WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_);
+ const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()->
+ GetNetworkState(service_path_);
if (!wifi) {
// Shill no longer knows about this wifi network (edge case).
- // TODO(stevenjb): Add a notification (chromium-os13225).
- LOG(WARNING) << "Wifi network: " << service_path_ << " no longer exists.";
- return true;
+ // TODO(stevenjb): Add notification for this.
+ NET_LOG_ERROR("Network not found", service_path_);
+ return true; // Close dialog
}
+ base::DictionaryValue properties;
if (eap_method_combobox_) {
// Visible 802.1X EAP Wi-Fi connection.
- EAPMethod method = GetEapMethod();
- DCHECK(method != EAP_METHOD_UNKNOWN);
- wifi->SetEAPMethod(method);
- wifi->SetEAPPhase2Auth(GetEapPhase2Auth());
- wifi->SetEAPServerCaCertPEM(GetEapServerCaCertPEM());
- wifi->SetEAPUseSystemCAs(GetEapUseSystemCas());
- wifi->SetEAPClientCertPkcs11Id(GetEapClientCertPkcs11Id());
- wifi->SetEAPIdentity(GetEapIdentity());
- wifi->SetEAPAnonymousIdentity(GetEapAnonymousIdentity());
- wifi->SetEAPPassphrase(GetPassphrase());
- wifi->SetSaveCredentials(GetSaveCredentials());
+ SetEapProperties(&properties);
+ properties.SetBooleanWithoutPathExpansion(
+ flimflam::kSaveCredentialsProperty, GetSaveCredentials());
} else {
// Visible ordinary Wi-Fi connection.
const std::string passphrase = GetPassphrase();
- if (passphrase != wifi->passphrase())
- wifi->SetPassphrase(passphrase);
+ if (!passphrase.empty()) {
+ properties.SetStringWithoutPathExpansion(
+ flimflam::kPassphraseProperty, passphrase);
+ }
+ }
+ // If the network is not in a profile, set the Profile property
+ // based on the setting of the 'Share' checkbox.
+ if (wifi->profile_path().empty()) {
+ bool share_network = GetShareNetwork(share_default);
+ std::string profile_path;
+ if (share_network) {
+ profile_path = NetworkProfileHandler::kSharedProfilePath;
+ } else {
+ const NetworkProfile* profile =
+ NetworkHandler::Get()->network_profile_handler()->
+ GetDefaultUserProfile();
+ if (profile)
+ profile_path = profile->path;
+ else
+ NET_LOG_ERROR("Unable to set user profile", service_path_);
+ }
+ if (!profile_path.empty()) {
+ properties.SetStringWithoutPathExpansion(
+ flimflam::kProfileProperty, profile_path);
+ }
}
- bool share_default = (wifi->profile_type() != PROFILE_USER);
- wifi->SetEnrollmentDelegate(
- CreateEnrollmentDelegate(GetWidget()->GetNativeWindow(),
- wifi->name(),
- ProfileManager::GetLastUsedProfile()));
- cros->ConnectToWifiNetwork(wifi, GetShareNetwork(share_default));
- // Connection failures are responsible for updating the UI, including
- // reopening dialogs.
+ 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
}
return true; // dialog will be closed
}
@@ -760,41 +740,42 @@ bool WifiConfigView::GetShareNetwork(bool share_default) const {
return share_network_checkbox_->checked();
}
-EAPMethod WifiConfigView::GetEapMethod() const {
+std::string WifiConfigView::GetEapMethod() const {
DCHECK(eap_method_combobox_);
switch (eap_method_combobox_->selected_index()) {
- case EAP_METHOD_INDEX_NONE:
- return EAP_METHOD_UNKNOWN;
case EAP_METHOD_INDEX_PEAP:
- return EAP_METHOD_PEAP;
+ return flimflam::kEapMethodPEAP;
case EAP_METHOD_INDEX_TLS:
- return EAP_METHOD_TLS;
+ return flimflam::kEapMethodTLS;
case EAP_METHOD_INDEX_TTLS:
- return EAP_METHOD_TTLS;
+ return flimflam::kEapMethodTTLS;
case EAP_METHOD_INDEX_LEAP:
- return EAP_METHOD_LEAP;
+ return flimflam::kEapMethodLEAP;
+ case EAP_METHOD_INDEX_NONE:
default:
- return EAP_METHOD_UNKNOWN;
+ return "";
}
}
-EAPPhase2Auth WifiConfigView::GetEapPhase2Auth() const {
+std::string WifiConfigView::GetEapPhase2Auth() const {
DCHECK(phase_2_auth_combobox_);
+ bool is_peap = (GetEapMethod() == flimflam::kEapMethodPEAP);
switch (phase_2_auth_combobox_->selected_index()) {
- case PHASE_2_AUTH_INDEX_AUTO:
- return EAP_PHASE_2_AUTH_AUTO;
case PHASE_2_AUTH_INDEX_MD5:
- return EAP_PHASE_2_AUTH_MD5;
+ return is_peap ? flimflam::kEapPhase2AuthPEAPMD5
+ : flimflam::kEapPhase2AuthTTLSMD5;
case PHASE_2_AUTH_INDEX_MSCHAPV2:
- return EAP_PHASE_2_AUTH_MSCHAPV2;
+ return is_peap ? flimflam::kEapPhase2AuthPEAPMSCHAPV2
+ : flimflam::kEapPhase2AuthTTLSMSCHAPV2;
case PHASE_2_AUTH_INDEX_MSCHAP:
- return EAP_PHASE_2_AUTH_MSCHAP;
+ return flimflam::kEapPhase2AuthTTLSMSCHAP;
case PHASE_2_AUTH_INDEX_PAP:
- return EAP_PHASE_2_AUTH_PAP;
+ return flimflam::kEapPhase2AuthTTLSPAP;
case PHASE_2_AUTH_INDEX_CHAP:
- return EAP_PHASE_2_AUTH_CHAP;
+ return flimflam::kEapPhase2AuthTTLSCHAP;
+ case PHASE_2_AUTH_INDEX_AUTO:
default:
- return EAP_PHASE_2_AUTH_AUTO;
+ return "";
}
}
@@ -842,6 +823,34 @@ std::string WifiConfigView::GetEapAnonymousIdentity() const {
return UTF16ToUTF8(identity_anonymous_textfield_->text());
}
+void WifiConfigView::SetEapProperties(base::DictionaryValue* properties) {
+ properties->SetStringWithoutPathExpansion(
+ flimflam::kEapIdentityProperty, GetEapIdentity());
+ properties->SetStringWithoutPathExpansion(
+ flimflam::kEapMethodProperty, GetEapMethod());
+ properties->SetStringWithoutPathExpansion(
+ flimflam::kEapPhase2AuthProperty, GetEapPhase2Auth());
+ properties->SetStringWithoutPathExpansion(
+ flimflam::kEapAnonymousIdentityProperty, GetEapAnonymousIdentity());
+
+ // shill requires both CertID and KeyID for TLS connections, despite
+ // the fact that by convention they are the same ID.
+ properties->SetStringWithoutPathExpansion(
+ flimflam::kEapCertIdProperty, GetEapClientCertPkcs11Id());
+ properties->SetStringWithoutPathExpansion(
+ flimflam::kEapKeyIdProperty, GetEapClientCertPkcs11Id());
+
+ properties->SetBooleanWithoutPathExpansion(
+ flimflam::kEapUseSystemCasProperty, GetEapUseSystemCas());
+ properties->SetStringWithoutPathExpansion(
+ flimflam::kEapPasswordProperty, GetPassphrase());
+
+ base::ListValue* pem_list = new base::ListValue;
+ pem_list->AppendString(GetEapServerCaCertPEM());
+ properties->SetWithoutPathExpansion(
+ shill::kEapCaCertPemProperty, pem_list);
+}
+
void WifiConfigView::Cancel() {
}
@@ -851,8 +860,13 @@ void WifiConfigView::Cancel() {
// If we are creating the "Join other network..." dialog, we will allow user
// to enter the data. And if they select the 802.1x encryption, we will show
// the 802.1x fields.
-void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) {
+void WifiConfigView::Init(bool show_8021x) {
+ const NetworkState* wifi = NetworkHandler::Get()->network_state_handler()->
+ GetNetworkState(service_path_);
if (wifi) {
+ DCHECK(wifi->type() == flimflam::kTypeWifi);
+ if (wifi->security() == flimflam::kSecurity8021x)
+ show_8021x = true;
ParseWiFiEAPUIProperty(&eap_method_ui_data_, wifi, onc::eap::kOuter);
ParseWiFiEAPUIProperty(&phase_2_auth_ui_data_, wifi, onc::eap::kInner);
ParseWiFiEAPUIProperty(&user_cert_ui_data_, wifi, onc::eap::kClientCertRef);
@@ -1007,8 +1021,6 @@ void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) {
views::Textfield::STYLE_DEFAULT);
identity_textfield_->SetAccessibleName(identity_label_text);
identity_textfield_->SetController(this);
- if (wifi && !wifi->identity().empty())
- identity_textfield_->SetText(UTF8ToUTF16(wifi->identity()));
identity_textfield_->SetEnabled(identity_ui_data_.IsEditable());
layout->AddView(identity_textfield_);
layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_));
@@ -1024,8 +1036,6 @@ void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) {
passphrase_textfield_ = new views::Textfield(
views::Textfield::STYLE_OBSCURED);
passphrase_textfield_->SetController(this);
- if (wifi && !wifi->GetPassphrase().empty())
- passphrase_textfield_->SetText(UTF8ToUTF16(wifi->GetPassphrase()));
// Disable passphrase input initially for other network.
passphrase_label_->SetEnabled(wifi != NULL);
passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable());
@@ -1102,10 +1112,7 @@ void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) {
}
// Share network
- if (!wifi ||
- (wifi->profile_type() == PROFILE_NONE &&
- wifi->IsPassphraseRequired() &&
- !wifi->RequiresUserProfile())) {
+ if (!wifi || wifi->profile_path().empty()) {
layout->StartRow(0, column_view_set_id);
share_network_checkbox_ = new views::Checkbox(
l10n_util::GetStringUTF16(
@@ -1125,112 +1132,137 @@ void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) {
// Initialize the field and checkbox values.
- // After creating the fields, we set the values. Fields need to be created
- // first because RefreshEapFields() will enable/disable them as appropriate.
- if (show_8021x) {
- EAPMethod eap_method = (wifi ? wifi->eap_method() : EAP_METHOD_UNKNOWN);
- switch (eap_method) {
- case EAP_METHOD_PEAP:
- eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP);
- break;
- case EAP_METHOD_TTLS:
- eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS);
- break;
- case EAP_METHOD_TLS:
- eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TLS);
- break;
- case EAP_METHOD_LEAP:
- eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_LEAP);
- break;
- default:
- break;
- }
+ if (!wifi && show_8021x)
RefreshEapFields();
- // Phase 2 authentication and anonymous identity.
- if (Phase2AuthActive()) {
- EAPPhase2Auth eap_phase_2_auth =
- (wifi ? wifi->eap_phase_2_auth() : EAP_PHASE_2_AUTH_AUTO);
- switch (eap_phase_2_auth) {
- case EAP_PHASE_2_AUTH_MD5:
- phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5);
- break;
- case EAP_PHASE_2_AUTH_MSCHAPV2:
- phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2);
- break;
- case EAP_PHASE_2_AUTH_MSCHAP:
- phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP);
- break;
- case EAP_PHASE_2_AUTH_PAP:
- phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP);
- break;
- case EAP_PHASE_2_AUTH_CHAP:
- phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP);
- break;
- default:
- break;
- }
+ RefreshShareCheckbox();
+ UpdateErrorLabel();
- const std::string& eap_anonymous_identity =
- (wifi ? wifi->eap_anonymous_identity() : std::string());
- identity_anonymous_textfield_->SetText(
- UTF8ToUTF16(eap_anonymous_identity));
- }
+ if (wifi) {
+ NetworkHandler::Get()->network_configuration_handler()->GetProperties(
+ service_path_,
+ base::Bind(&WifiConfigView::InitFromProperties,
+ weak_ptr_factory_.GetWeakPtr(), show_8021x),
+ base::Bind(&ShillError, "GetProperties"));
+ }
+}
+
+void WifiConfigView::InitFromProperties(
+ bool show_8021x,
+ const std::string& service_path,
+ const base::DictionaryValue& properties) {
+ std::string passphrase;
+ properties.GetStringWithoutPathExpansion(
+ flimflam::kPassphraseProperty, &passphrase);
+ passphrase_textfield_->SetText(UTF8ToUTF16(passphrase));
+
+ if (!show_8021x)
+ return;
+
+ std::string identity;
+ properties.GetStringWithoutPathExpansion(
+ flimflam::kIdentityProperty, &identity);
+ 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.
+
+ // EAP Method
+ std::string eap_method;
+ properties.GetStringWithoutPathExpansion(
+ flimflam::kEapMethodProperty, &eap_method);
+ if (eap_method == flimflam::kEapMethodPEAP)
+ eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP);
+ else if (eap_method == flimflam::kEapMethodTTLS)
+ eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS);
+ else if (eap_method == flimflam::kEapMethodTLS)
+ eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TLS);
+ else if (eap_method == flimflam::kEapMethodLEAP)
+ eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_LEAP);
+ 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
+
+ // Phase 2 authentication and anonymous identity.
+ if (Phase2AuthActive()) {
+ std::string eap_phase_2_auth;
+ properties.GetStringWithoutPathExpansion(
+ flimflam::kEapPhase2AuthProperty, &eap_phase_2_auth);
+ if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMD5)
+ phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MD5);
+ else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAPV2)
+ phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAPV2);
+ else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSMSCHAP)
+ phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_MSCHAP);
+ else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSPAP)
+ phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_PAP);
+ else if (eap_phase_2_auth == flimflam::kEapPhase2AuthTTLSCHAP)
+ phase_2_auth_combobox_->SetSelectedIndex(PHASE_2_AUTH_INDEX_CHAP);
+
+ std::string eap_anonymous_identity;
+ properties.GetStringWithoutPathExpansion(
+ flimflam::kEapAnonymousIdentityProperty, &eap_anonymous_identity);
+ identity_anonymous_textfield_->SetText(UTF8ToUTF16(eap_anonymous_identity));
+ }
- // Server CA certificate.
- if (CaCertActive()) {
- const std::string& ca_cert_pem =
- (wifi ? wifi->eap_server_ca_cert_pem() : std::string());
- if (ca_cert_pem.empty()) {
- if (wifi->eap_use_system_cas()) {
- // "Default".
- server_ca_cert_combobox_->SetSelectedIndex(0);
- } else {
- // "Do not check".
- server_ca_cert_combobox_->SetSelectedIndex(
- server_ca_cert_combobox_->model()->GetItemCount() - 1);
- }
+ // Server CA certificate.
+ if (CaCertActive()) {
+ std::string eap_ca_cert_pem;
+ const base::ListValue* pems = NULL;
+ if (properties.GetListWithoutPathExpansion(
+ shill::kEapCaCertPemProperty, &pems))
+ pems->GetString(0, &eap_ca_cert_pem);
+ if (eap_ca_cert_pem.empty()) {
+ bool eap_use_system_cas = false;
+ properties.GetBooleanWithoutPathExpansion(
+ flimflam::kEapUseSystemCasProperty, &eap_use_system_cas);
+ if (eap_use_system_cas) {
+ // "Default"
+ server_ca_cert_combobox_->SetSelectedIndex(0);
} else {
- // Select the certificate if available.
- int cert_index = CertLibrary::Get()->GetCertIndexByPEM(
- CertLibrary::CERT_TYPE_SERVER_CA, ca_cert_pem);
- if (cert_index >= 0) {
- // Skip item for "Default".
- server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index);
- }
+ // "Do not check".
+ server_ca_cert_combobox_->SetSelectedIndex(
+ server_ca_cert_combobox_->model()->GetItemCount() - 1);
}
- }
-
- // User certificate.
- if (UserCertActive()) {
- const std::string& pkcs11_id =
- (wifi ? wifi->eap_client_cert_pkcs11_id() : std::string());
- if (!pkcs11_id.empty()) {
- int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id(
- CertLibrary::CERT_TYPE_USER, pkcs11_id);
- if (cert_index >= 0) {
- user_cert_combobox_->SetSelectedIndex(cert_index);
- }
+ } else {
+ // Select the certificate if available.
+ int cert_index = CertLibrary::Get()->GetCertIndexByPEM(
+ CertLibrary::CERT_TYPE_SERVER_CA, eap_ca_cert_pem);
+ if (cert_index >= 0) {
+ // Skip item for "Default".
+ server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index);
}
}
+ }
- // Identity is always active.
- const std::string& eap_identity =
- (wifi ? wifi->eap_identity() : std::string());
- identity_textfield_->SetText(UTF8ToUTF16(eap_identity));
-
- // Passphrase
- if (PassphraseActive()) {
- const std::string& eap_passphrase =
- (wifi ? wifi->eap_passphrase() : std::string());
- passphrase_textfield_->SetText(UTF8ToUTF16(eap_passphrase));
+ // User certificate.
+ if (UserCertActive()) {
+ std::string eap_cert_id;
+ properties.GetStringWithoutPathExpansion(
+ flimflam::kEapCertIdProperty, &eap_cert_id);
+ if (!eap_cert_id.empty()) {
+ int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id(
+ CertLibrary::CERT_TYPE_USER, eap_cert_id);
+ if (cert_index >= 0)
+ user_cert_combobox_->SetSelectedIndex(cert_index);
}
+ }
- // Save credentials
- bool save_credentials = (wifi ? wifi->save_credentials() : false);
- save_credentials_checkbox_->SetChecked(save_credentials);
+ // Identity is always active.
+ std::string eap_identity;
+ properties.GetStringWithoutPathExpansion(
+ flimflam::kEapIdentityProperty, &eap_identity);
+ identity_textfield_->SetText(UTF8ToUTF16(eap_identity));
+
+ // Passphrase
+ if (PassphraseActive()) {
+ std::string eap_password;
+ properties.GetStringWithoutPathExpansion(
+ flimflam::kEapPasswordProperty, &eap_password);
+ passphrase_textfield_->SetText(UTF8ToUTF16(eap_password));
}
+ // Save credentials
+ bool save_credentials = false;
+ properties.GetBooleanWithoutPathExpansion(
+ flimflam::kSaveCredentialsProperty, &save_credentials);
+ save_credentials_checkbox_->SetChecked(save_credentials);
+
RefreshShareCheckbox();
UpdateErrorLabel();
}
@@ -1244,11 +1276,11 @@ void WifiConfigView::InitFocus() {
// static
void WifiConfigView::ParseWiFiUIProperty(
NetworkPropertyUIData* property_ui_data,
- Network* network,
+ const NetworkState* network,
const std::string& key) {
onc::ONCSource onc_source = onc::ONC_SOURCE_NONE;
const base::DictionaryValue* onc =
- NetworkConfigView::FindPolicyForActiveUser(network, &onc_source);
+ network_connect::FindPolicyForActiveUser(network, &onc_source);
property_ui_data->ParseOncProperty(
onc_source,
@@ -1259,7 +1291,7 @@ void WifiConfigView::ParseWiFiUIProperty(
// static
void WifiConfigView::ParseWiFiEAPUIProperty(
NetworkPropertyUIData* property_ui_data,
- Network* network,
+ const NetworkState* network,
const std::string& key) {
ParseWiFiUIProperty(
property_ui_data, network,
« 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