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 "ash/system/chromeos/network/network_connect.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 11 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
12 #include "chrome/browser/chromeos/net/onc_utils.h" | 12 #include "chrome/browser/chromeos/net/onc_utils.h" |
13 #include "chrome/browser/chromeos/options/passphrase_textfield.h" | |
13 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chromeos/login/login_state.h" | 15 #include "chromeos/login/login_state.h" |
15 #include "chromeos/network/network_configuration_handler.h" | 16 #include "chromeos/network/network_configuration_handler.h" |
16 #include "chromeos/network/network_event_log.h" | 17 #include "chromeos/network/network_event_log.h" |
17 #include "chromeos/network/network_handler.h" | 18 #include "chromeos/network/network_handler.h" |
18 #include "chromeos/network/network_state.h" | 19 #include "chromeos/network/network_state.h" |
19 #include "chromeos/network/network_state_handler.h" | 20 #include "chromeos/network/network_state_handler.h" |
20 #include "chromeos/network/network_ui_data.h" | 21 #include "chromeos/network/network_ui_data.h" |
21 #include "chromeos/network/onc/onc_constants.h" | 22 #include "chromeos/network/onc/onc_constants.h" |
22 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 } | 395 } |
395 | 396 |
396 bool WifiConfigView::CanLogin() { | 397 bool WifiConfigView::CanLogin() { |
397 static const size_t kMinWirelessPasswordLen = 5; | 398 static const size_t kMinWirelessPasswordLen = 5; |
398 | 399 |
399 // We either have an existing wifi network or the user entered an SSID. | 400 // We either have an existing wifi network or the user entered an SSID. |
400 if (service_path_.empty() && GetSsid().empty()) | 401 if (service_path_.empty() && GetSsid().empty()) |
401 return false; | 402 return false; |
402 | 403 |
403 // If the network requires a passphrase, make sure it is the right length. | 404 // If the network requires a passphrase, make sure it is the right length. |
404 if (passphrase_textfield_ != NULL | 405 if (passphrase_textfield_ != NULL && |
405 && passphrase_textfield_->enabled() | 406 passphrase_textfield_->enabled() && |
406 && passphrase_textfield_->text().length() < kMinWirelessPasswordLen) | 407 !passphrase_textfield_->show_fake() && |
408 passphrase_textfield_->text().length() < kMinWirelessPasswordLen) | |
407 return false; | 409 return false; |
408 | 410 |
409 // If we're using EAP, we must have a method. | 411 // If we're using EAP, we must have a method. |
410 if (eap_method_combobox_ && | 412 if (eap_method_combobox_ && |
411 eap_method_combobox_->selected_index() == EAP_METHOD_INDEX_NONE) | 413 eap_method_combobox_->selected_index() == EAP_METHOD_INDEX_NONE) |
412 return false; | 414 return false; |
413 | 415 |
414 // Block login if certs are required but user has none. | 416 // Block login if certs are required but user has none. |
415 if (UserCertRequired() && (!HaveUserCerts() || !IsUserCertValid())) | 417 if (UserCertRequired() && (!HaveUserCerts() || !IsUserCertValid())) |
416 return false; | 418 return false; |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1047 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); | 1049 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); |
1048 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1050 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1049 } | 1051 } |
1050 | 1052 |
1051 // Passphrase input | 1053 // Passphrase input |
1052 layout->StartRow(0, column_view_set_id); | 1054 layout->StartRow(0, column_view_set_id); |
1053 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; | 1055 int label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; |
1054 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); | 1056 string16 passphrase_label_text = l10n_util::GetStringUTF16(label_text_id); |
1055 passphrase_label_ = new views::Label(passphrase_label_text); | 1057 passphrase_label_ = new views::Label(passphrase_label_text); |
1056 layout->AddView(passphrase_label_); | 1058 layout->AddView(passphrase_label_); |
1057 passphrase_textfield_ = new views::Textfield( | 1059 passphrase_textfield_ = new PassphraseTextfield(); |
1058 views::Textfield::STYLE_OBSCURED); | |
1059 passphrase_textfield_->SetController(this); | 1060 passphrase_textfield_->SetController(this); |
1060 // Disable passphrase input initially for other network. | 1061 // Disable passphrase input initially for other network. |
1061 passphrase_label_->SetEnabled(wifi != NULL); | 1062 passphrase_label_->SetEnabled(wifi); |
1062 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); | 1063 passphrase_textfield_->SetEnabled(wifi && passphrase_ui_data_.IsEditable()); |
1063 passphrase_textfield_->SetAccessibleName(passphrase_label_text); | 1064 passphrase_textfield_->SetAccessibleName(passphrase_label_text); |
1064 layout->AddView(passphrase_textfield_); | 1065 layout->AddView(passphrase_textfield_); |
1065 | 1066 |
1066 if (passphrase_ui_data_.IsManaged()) { | 1067 if (passphrase_ui_data_.IsManaged()) { |
1067 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_)); | 1068 layout->AddView(new ControlledSettingIndicatorView(passphrase_ui_data_)); |
1068 } else { | 1069 } else { |
1069 // Password visible button. | 1070 // Password visible button. |
1070 passphrase_visible_button_ = new views::ToggleImageButton(this); | 1071 passphrase_visible_button_ = new views::ToggleImageButton(this); |
1071 passphrase_visible_button_->set_focusable(true); | 1072 passphrase_visible_button_->set_focusable(true); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1165 base::Bind(&WifiConfigView::InitFromProperties, | 1166 base::Bind(&WifiConfigView::InitFromProperties, |
1166 weak_ptr_factory_.GetWeakPtr(), show_8021x), | 1167 weak_ptr_factory_.GetWeakPtr(), show_8021x), |
1167 base::Bind(&ShillError, "GetProperties")); | 1168 base::Bind(&ShillError, "GetProperties")); |
1168 } | 1169 } |
1169 } | 1170 } |
1170 | 1171 |
1171 void WifiConfigView::InitFromProperties( | 1172 void WifiConfigView::InitFromProperties( |
1172 bool show_8021x, | 1173 bool show_8021x, |
1173 const std::string& service_path, | 1174 const std::string& service_path, |
1174 const base::DictionaryValue& properties) { | 1175 const base::DictionaryValue& properties) { |
1175 std::string passphrase; | 1176 if (!show_8021x) { |
1176 properties.GetStringWithoutPathExpansion( | 1177 std::string passphrase; |
1177 flimflam::kPassphraseProperty, &passphrase); | 1178 properties.GetStringWithoutPathExpansion( |
1178 passphrase_textfield_->SetText(UTF8ToUTF16(passphrase)); | 1179 flimflam::kPassphraseProperty, &passphrase); |
1179 | 1180 passphrase_textfield_->SetText(UTF8ToUTF16(passphrase)); |
1180 if (!show_8021x) | |
1181 return; | 1181 return; |
1182 } | |
1182 | 1183 |
1183 // EAP Method | 1184 // EAP Method |
1184 std::string eap_method; | 1185 std::string eap_method; |
1185 properties.GetStringWithoutPathExpansion( | 1186 properties.GetStringWithoutPathExpansion( |
1186 flimflam::kEapMethodProperty, &eap_method); | 1187 flimflam::kEapMethodProperty, &eap_method); |
1187 if (eap_method == flimflam::kEapMethodPEAP) | 1188 if (eap_method == flimflam::kEapMethodPEAP) |
1188 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP); | 1189 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_PEAP); |
1189 else if (eap_method == flimflam::kEapMethodTTLS) | 1190 else if (eap_method == flimflam::kEapMethodTTLS) |
1190 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS); | 1191 eap_method_combobox_->SetSelectedIndex(EAP_METHOD_INDEX_TTLS); |
1191 else if (eap_method == flimflam::kEapMethodTLS) | 1192 else if (eap_method == flimflam::kEapMethodTLS) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1270 properties.GetStringWithoutPathExpansion( | 1271 properties.GetStringWithoutPathExpansion( |
1271 flimflam::kEapIdentityProperty, &eap_identity); | 1272 flimflam::kEapIdentityProperty, &eap_identity); |
1272 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); | 1273 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); |
1273 | 1274 |
1274 // Passphrase | 1275 // Passphrase |
1275 if (PassphraseActive()) { | 1276 if (PassphraseActive()) { |
1276 std::string eap_password; | 1277 std::string eap_password; |
1277 properties.GetStringWithoutPathExpansion( | 1278 properties.GetStringWithoutPathExpansion( |
1278 flimflam::kEapPasswordProperty, &eap_password); | 1279 flimflam::kEapPasswordProperty, &eap_password); |
1279 passphrase_textfield_->SetText(UTF8ToUTF16(eap_password)); | 1280 passphrase_textfield_->SetText(UTF8ToUTF16(eap_password)); |
1281 // If 'Connectable' is True, show a fake passphrase to indicate that it | |
1282 // has already been set. | |
1283 bool connectable = false; | |
1284 properties.GetBooleanWithoutPathExpansion( | |
1285 flimflam::kConnectableProperty, &connectable); | |
armansito
2013/09/04 00:25:16
From my understanding, passphrases are not mandato
stevenjb
2013/09/04 00:41:14
So, kPassphraseRequiredProperty does not apply to
| |
1286 passphrase_textfield_->SetShowFake(connectable); | |
1280 } | 1287 } |
1281 | 1288 |
1282 // Save credentials | 1289 // Save credentials |
1283 bool save_credentials = false; | 1290 bool save_credentials = false; |
1284 properties.GetBooleanWithoutPathExpansion( | 1291 properties.GetBooleanWithoutPathExpansion( |
1285 flimflam::kSaveCredentialsProperty, &save_credentials); | 1292 flimflam::kSaveCredentialsProperty, &save_credentials); |
1286 save_credentials_checkbox_->SetChecked(save_credentials); | 1293 save_credentials_checkbox_->SetChecked(save_credentials); |
1287 | 1294 |
1288 RefreshShareCheckbox(); | 1295 RefreshShareCheckbox(); |
1289 UpdateErrorLabel(); | 1296 UpdateErrorLabel(); |
(...skipping 30 matching lines...) Expand all Loading... | |
1320 void WifiConfigView::ParseWiFiEAPUIProperty( | 1327 void WifiConfigView::ParseWiFiEAPUIProperty( |
1321 NetworkPropertyUIData* property_ui_data, | 1328 NetworkPropertyUIData* property_ui_data, |
1322 const NetworkState* network, | 1329 const NetworkState* network, |
1323 const std::string& key) { | 1330 const std::string& key) { |
1324 ParseWiFiUIProperty( | 1331 ParseWiFiUIProperty( |
1325 property_ui_data, network, | 1332 property_ui_data, network, |
1326 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); | 1333 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); |
1327 } | 1334 } |
1328 | 1335 |
1329 } // namespace chromeos | 1336 } // namespace chromeos |
OLD | NEW |