Commit 3879fc9a authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

NetworkConfig: Default to autoconnect and show connecting

This CL fixes two minor network config UI issues with
--network-settings-config:

* Adds "Connecting" to the dialog while connecting
* Sets 'AutoConnect' to true unless prohibited by policy
  (matches current UI behavior)

Bug: 380937
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I5b58d9080f555431f23eba1ffa0c3806da2a8c63
Reviewed-on: https://chromium-review.googlesource.com/801917Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520771}
parent bda7562c
......@@ -46,6 +46,7 @@
<div slot="body">
<network-config id="networkConfig" class="flex"
networking-private="[[networkingPrivate]]"
global-policy="[[globalPolicy_]]"
network-properties="{{networkProperties_}}"
enable-connect="{{enableConnect_}}" connect-on-save
share-allow-enable="[[shareAllowEnable_]]"
......
......@@ -23,6 +23,9 @@ Polymer({
value: chrome.networkingPrivate,
},
/** @private {!chrome.networkingPrivate.GlobalPolicy|undefined} */
globalPolicy_: Object,
/** @private */
shareAllowEnable_: {
type: Boolean,
......@@ -74,6 +77,10 @@ Polymer({
this.$.networkConfig.init();
this.networkingPrivate.getGlobalPolicy(policy => {
this.globalPolicy_ = policy;
});
/** @type {!CrDialogElement} */ (this.$.dialog).showModal();
},
......
......@@ -21,6 +21,7 @@
<div slot="body">
<network-config id="networkConfig" class="flex"
networking-private="[[networkingPrivate]]"
global-policy="[[globalPolicy]]"
network-properties="{{networkProperties_}}"
enable-connect="{{enableConnect_}}" enable-save="{{enableSave_}}"
share-allow-enable="[[shareAllowEnable_]]"
......
......@@ -18,6 +18,9 @@ Polymer({
*/
networkingPrivate: Object,
/** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */
globalPolicy: Object,
/** @private */
shareAllowEnable_: {
type: Boolean,
......
......@@ -132,7 +132,8 @@
</settings-animated-pages>
<internet-config id="configDialog"
networking-private="[[networkingPrivate]]">
networking-private="[[networkingPrivate]]"
global-policy="[[globalPolicy_]]">
</internet-config>
</template>
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html">
<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="network_shared_css.html">
<link rel="import" href="network_config_input.html">
......@@ -9,11 +11,15 @@
<dom-module id="network-config">
<template>
<style include="network-shared">
<style include="network-shared iron-flex">
#error {
color: red;
font-weight: 500;
}
cr-network-icon {
-webkit-margin-end: 10px;
}
</style>
<!-- SSID (WiFi) -->
......@@ -157,6 +163,17 @@
</div>
</template>
<template is="dom-if" if="[[propertiesSent_]]">
<div class="property-box">
<div class="start layout horizontal center">
<cr-network-icon is-list-item
network-state="[[getIconState_(configProperties_)]]">
</cr-network-icon>
<div>[[i18n('OncConnecting')]]</div>
</div>
</div>
</template>
<template is="dom-if" if="[[error_]]">
<div class="property-box">
<div id="error" class="start">
......
......@@ -37,6 +37,9 @@ Polymer({
*/
networkingPrivate: Object,
/** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */
globalPolicy: Object,
/**
* The GUID when an existing network is being configured. This will be
* empty when configuring a new network.
......@@ -356,6 +359,13 @@ Polymer({
this.propertiesSent_ = true;
this.error_ = '';
if (!this.guid || this.getSource_() == CrOnc.Source.NONE) {
// New network configurations default to 'AutoConnect' unless prohibited
// by policy.
CrOnc.setTypeProperty(
this.configProperties_, 'AutoConnect',
!(this.globalPolicy &&
this.globalPolicy.AllowOnlyPolicyNetworksToConnect));
// Create the configuration, then connect to it in the callback.
this.networkingPrivate.createNetwork(
this.shareNetwork_, this.configProperties_,
......@@ -1232,6 +1242,19 @@ Polymer({
return [];
},
/**
* @param {!chrome.networkingPrivate.NetworkConfigProperties} properties
* @return {!CrOnc.NetworkStateProperties}
* @private
*/
getIconState_: function(properties) {
return {
ConnectionState: CrOnc.ConnectionState.CONNECTING,
GUID: properties.GUID || '',
Type: this.type,
};
},
/**
* @return {string}
* @private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment