Skip to content

Commit 4a5646e

Browse files
committed
Fix network config UI
This CL cleans up the network config UI to improve the display of 'Connecting' and improve error handling and display. [email protected] (cherry picked from commit a9bc09d) Bug: 795715, 795698 Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation Change-Id: I2f2dc1654c29524e5b7ae99cfbe43692a9fdb470 Reviewed-on: https://chromium-review.googlesource.com/874605 Commit-Queue: Steven Bennetts <[email protected]> Reviewed-by: Toni Barzic <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#530967} Reviewed-on: https://chromium-review.googlesource.com/882550 Reviewed-by: Steven Bennetts <[email protected]> Cr-Commit-Position: refs/branch-heads/3325@{#51} Cr-Branched-From: bc084a8-refs/heads/master@{#530369}
1 parent dcf94bc commit 4a5646e

File tree

7 files changed

+93
-44
lines changed

7 files changed

+93
-44
lines changed

chrome/browser/chromeos/net/shill_error.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ base::string16 GetShillErrorString(const std::string& error,
3838
return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_DHCP_FAILED);
3939
if (error == shill::kErrorConnectFailed)
4040
return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED);
41-
if (error == shill::kErrorBadPassphrase)
41+
if (error == shill::kErrorBadPassphrase ||
42+
error == shill::kErrorResultInvalidPassphrase) {
4243
return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_BAD_PASSPHRASE);
44+
}
4345
if (error == shill::kErrorBadWEPKey)
4446
return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_BAD_WEPKEY);
4547
if (error == shill::kErrorActivationFailed) {

chrome/browser/ui/webui/chromeos/internet_config_dialog.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ namespace chromeos {
2323
namespace {
2424

2525
// Dialog height for configured networks that only require a passphrase.
26-
constexpr int kDialogHeightPasswordOnly = 320;
26+
// This height includes room for a 'connecting' or error message.
27+
constexpr int kDialogHeightPasswordOnly = 365;
2728

2829
void AddInternetStrings(content::WebUIDataSource* html_source) {
2930
// Add default strings first.

chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -296,26 +296,29 @@ void AddErrorLocalizedStrings(content::WebUIDataSource* html_source) {
296296
html_source->AddLocalizedString(entry.name, entry.id);
297297

298298
// Include Shill errors.
299-
const char* shill_errors[] = {shill::kErrorOutOfRange,
300-
shill::kErrorPinMissing,
301-
shill::kErrorDhcpFailed,
302-
shill::kErrorConnectFailed,
303-
shill::kErrorBadPassphrase,
304-
shill::kErrorBadWEPKey,
305-
shill::kErrorActivationFailed,
306-
shill::kErrorNeedEvdo,
307-
shill::kErrorNeedHomeNetwork,
308-
shill::kErrorOtaspFailed,
309-
shill::kErrorAaaFailed,
310-
shill::kErrorInternal,
311-
shill::kErrorDNSLookupFailed,
312-
shill::kErrorHTTPGetFailed,
313-
shill::kErrorIpsecPskAuthFailed,
314-
shill::kErrorIpsecCertAuthFailed,
315-
shill::kErrorEapAuthenticationFailed,
316-
shill::kErrorEapLocalTlsFailed,
317-
shill::kErrorEapRemoteTlsFailed,
318-
shill::kErrorPppAuthFailed};
299+
const char* shill_errors[] = {
300+
shill::kErrorOutOfRange,
301+
shill::kErrorPinMissing,
302+
shill::kErrorDhcpFailed,
303+
shill::kErrorConnectFailed,
304+
shill::kErrorBadPassphrase,
305+
shill::kErrorBadWEPKey,
306+
shill::kErrorActivationFailed,
307+
shill::kErrorNeedEvdo,
308+
shill::kErrorNeedHomeNetwork,
309+
shill::kErrorOtaspFailed,
310+
shill::kErrorAaaFailed,
311+
shill::kErrorInternal,
312+
shill::kErrorDNSLookupFailed,
313+
shill::kErrorHTTPGetFailed,
314+
shill::kErrorIpsecPskAuthFailed,
315+
shill::kErrorIpsecCertAuthFailed,
316+
shill::kErrorEapAuthenticationFailed,
317+
shill::kErrorEapLocalTlsFailed,
318+
shill::kErrorEapRemoteTlsFailed,
319+
shill::kErrorPppAuthFailed,
320+
shill::kErrorResultInvalidPassphrase,
321+
};
319322
for (const auto* error : shill_errors) {
320323
html_source->AddString(
321324
error, base::UTF16ToUTF8(shill_error::GetShillErrorString(error, "")));

chromeos/network/network_configuration_handler.cc

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ void LogConfigProperties(const std::string& desc,
7373
}
7474
}
7575

76+
// Returns recognized dbus error names or |default_error_name|.
77+
// TODO(stevenjb): Expand this list and update
78+
// network_element::AddErrorLocalizedStrings.
79+
std::string GetErrorName(const std::string& dbus_error_name,
80+
const std::string& default_error_name) {
81+
if (dbus_error_name == shill::kErrorResultInvalidPassphrase)
82+
return dbus_error_name;
83+
return default_error_name;
84+
}
85+
7686
} // namespace
7787

7888
// Helper class to request from Shill the profile entries associated with a
@@ -362,8 +372,8 @@ void NetworkConfigurationHandler::CreateShillConfiguration(
362372
base::Bind(&NetworkConfigurationHandler::ConfigurationCompleted,
363373
weak_ptr_factory_.GetWeakPtr(), profile_path, source,
364374
base::Passed(&properties_copy), callback),
365-
base::Bind(&network_handler::ShillErrorCallbackFunction,
366-
"Config.CreateConfiguration Failed", "", error_callback));
375+
base::Bind(&NetworkConfigurationHandler::ConfigurationFailed,
376+
weak_ptr_factory_.GetWeakPtr(), error_callback));
367377
}
368378

369379
void NetworkConfigurationHandler::RemoveConfiguration(
@@ -480,6 +490,16 @@ void NetworkConfigurationHandler::Init(
480490
network_state_handler_->AddObserver(this, FROM_HERE);
481491
}
482492

493+
void NetworkConfigurationHandler::ConfigurationFailed(
494+
const network_handler::ErrorCallback& error_callback,
495+
const std::string& dbus_error_name,
496+
const std::string& dbus_error_message) {
497+
std::string error_name =
498+
GetErrorName(dbus_error_name, "Config.CreateConfiguration Failed");
499+
network_handler::ShillErrorCallbackFunction(
500+
error_name, "", error_callback, dbus_error_name, dbus_error_message);
501+
}
502+
483503
void NetworkConfigurationHandler::ConfigurationCompleted(
484504
const std::string& profile_path,
485505
NetworkConfigurationObserver::Source source,
@@ -596,9 +616,11 @@ void NetworkConfigurationHandler::SetPropertiesErrorCallback(
596616
const network_handler::ErrorCallback& error_callback,
597617
const std::string& dbus_error_name,
598618
const std::string& dbus_error_message) {
599-
network_handler::ShillErrorCallbackFunction(
600-
"Config.SetProperties Failed", service_path, error_callback,
601-
dbus_error_name, dbus_error_message);
619+
std::string error_name =
620+
GetErrorName(dbus_error_name, "Config.SetProperties Failed");
621+
network_handler::ShillErrorCallbackFunction(error_name, service_path,
622+
error_callback, dbus_error_name,
623+
dbus_error_message);
602624
// Some properties may have changed so request an update regardless.
603625
network_state_handler_->RequestUpdateForNetwork(service_path);
604626
}

chromeos/network/network_configuration_handler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ class CHROMEOS_EXPORT NetworkConfigurationHandler
161161
const network_handler::ServiceResultCallback& callback,
162162
const dbus::ObjectPath& service_path);
163163

164+
void ConfigurationFailed(const network_handler::ErrorCallback& error_callback,
165+
const std::string& dbus_error_name,
166+
const std::string& dbus_error_message);
167+
164168
// Called from ProfileEntryDeleter instances when they complete causing
165169
// this class to delete the instance.
166170
void ProfileEntryDeleterCompleted(const std::string& service_path,

ui/webui/resources/cr_components/chromeos/network/network_config.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@
163163
</div>
164164
</template>
165165

166-
<template is="dom-if" if="[[propertiesSent_]]">
166+
<template is="dom-if"
167+
if="[[connectingIsVisible_(propertiesSent_, error_)]]">
167168
<div class="property-box">
168169
<div class="start layout horizontal center">
169170
<cr-network-icon is-list-item

ui/webui/resources/cr_components/chromeos/network/network_config.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ Polymer({
478478
setNetworkProperties_: function(properties) {
479479
this.propertiesReceived_ = true;
480480
this.networkProperties = properties;
481-
this.error_ = properties.ErrorState || '';
481+
this.setError_(properties.ErrorState);
482482

483483
// Set the current shareNetwork_ value when porperties are received.
484484
this.setShareNetwork_();
@@ -884,10 +884,7 @@ Polymer({
884884

885885
var requireCerts = (this.showEap_ && this.showEap_.UserCert) ||
886886
(this.showVpn_ && this.showVpn_.UserCert);
887-
if (requireCerts && !this.userCerts_.length)
888-
this.error_ = certError;
889-
else
890-
this.error_ = '';
887+
this.setError_(requireCerts && !this.userCerts_.length ? certError : '');
891888
},
892889

893890
/**
@@ -1014,6 +1011,14 @@ Polymer({
10141011
(this.type == CrOnc.Type.WI_FI || this.type == CrOnc.Type.WI_MAX);
10151012
},
10161013

1014+
/**
1015+
* @return {boolean}
1016+
* @private
1017+
*/
1018+
connectingIsVisible_: function() {
1019+
return this.propertiesSent_ && !this.error_;
1020+
},
1021+
10171022
/**
10181023
* @return {boolean}
10191024
* @private
@@ -1179,9 +1184,10 @@ Polymer({
11791184

11801185
/** @private */
11811186
setPropertiesCallback_: function() {
1182-
this.error_ = this.getRuntimeError_();
1187+
this.setError_(this.getRuntimeError_());
11831188
if (this.error_) {
11841189
console.error('setProperties error: ' + this.guid + ': ' + this.error_);
1190+
this.propertiesSent_ = false;
11851191
return;
11861192
}
11871193
var connectState = this.networkProperties.ConnectionState;
@@ -1199,11 +1205,12 @@ Polymer({
11991205
* @private
12001206
*/
12011207
createNetworkCallback_: function(guid) {
1202-
this.error_ = this.getRuntimeError_();
1208+
this.setError_(this.getRuntimeError_());
12031209
if (this.error_) {
12041210
console.error(
12051211
'createNetworkError, type: ' + this.networkProperties.Type + ': ' +
12061212
'error: ' + this.error_);
1213+
this.propertiesSent_ = false;
12071214
return;
12081215
}
12091216
this.startConnect_(guid);
@@ -1216,18 +1223,15 @@ Polymer({
12161223
startConnect_: function(guid) {
12171224
this.networkingPrivate.startConnect(guid, () => {
12181225
var error = this.getRuntimeError_();
1219-
if (!error || error == 'connected' || error == 'connect-canceled') {
1220-
this.close_(); // Connect completed or canceled, close the dialog.
1221-
return;
1222-
}
1223-
if (error == 'connecting') {
1224-
// Keep the dialog open while connecting. TODO(stevenjb): Add a listener
1225-
// for the network properties and close the dialog if connected or show
1226-
// an error if not.
1226+
if (!error || error == 'connected' || error == 'connect-canceled' ||
1227+
error == 'connecting') {
1228+
// Connect is in progress, completed or canceled, close the dialog.
1229+
this.close_();
12271230
return;
12281231
}
1229-
this.error_ = error;
1232+
this.setError_(error);
12301233
console.error('Error connecting to network: ' + error);
1234+
this.propertiesSent_ = false;
12311235
});
12321236
},
12331237

@@ -1269,6 +1273,18 @@ Polymer({
12691273
};
12701274
},
12711275

1276+
/**
1277+
* @param {string|undefined} error
1278+
* @private
1279+
*/
1280+
setError_: function(error) {
1281+
if (!error) {
1282+
this.error_ = '';
1283+
return;
1284+
}
1285+
this.error_ = error;
1286+
},
1287+
12721288
/**
12731289
* @return {string}
12741290
* @private

0 commit comments

Comments
 (0)