summaryrefslogtreecommitdiff
path: root/chromium/ui/webui/resources/cr_components/chromeos/network/network_ip_config.js
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/webui/resources/cr_components/chromeos/network/network_ip_config.js')
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/network/network_ip_config.js63
1 files changed, 48 insertions, 15 deletions
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/network/network_ip_config.js b/chromium/ui/webui/resources/cr_components/chromeos/network/network_ip_config.js
index 7f3cb3dd6ec..dea3b183e3b 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/network/network_ip_config.js
+++ b/chromium/ui/webui/resources/cr_components/chromeos/network/network_ip_config.js
@@ -10,7 +10,7 @@
Polymer({
is: 'network-ip-config',
- behaviors: [I18nBehavior],
+ behaviors: [I18nBehavior, CrPolicyNetworkBehavior],
properties: {
/**
@@ -78,12 +78,14 @@ Polymer({
* Polymer networkProperties changed method.
*/
networkPropertiesChanged_: function(newValue, oldValue) {
- if (!this.networkProperties)
+ if (!this.networkProperties) {
return;
+ }
const properties = this.networkProperties;
- if (newValue.GUID != (oldValue && oldValue.GUID))
+ if (newValue.GUID != (oldValue && oldValue.GUID)) {
this.savedStaticIp_ = undefined;
+ }
// Update the 'automatic' property.
if (properties.IPAddressConfigType) {
@@ -108,6 +110,28 @@ Polymer({
}
},
+ /**
+ * Checks whether IP address config type can be changed.
+ * @param {boolean} editable
+ * @param {!CrOnc.NetworkProperties} networkProperties
+ * @return {boolean} true only if 'IPAddressConfigType' as well as all other
+ * IP address config related fields are editable.
+ * @private
+ */
+ canChangeIPConfigType_: function(editable, networkProperties) {
+ if (!editable) {
+ return false;
+ }
+ const controlledProps = [
+ 'IPAddressConfigType', 'StaticIPConfig.IPAddress',
+ 'StaticIPConfig.RoutingPrefix', 'StaticIPConfig.Gateway'
+ ];
+
+ return controlledProps.every(
+ setting =>
+ !this.isNetworkPolicyPathEnforced(networkProperties, setting));
+ },
+
/** @private */
onAutomaticChange_: function() {
if (!this.automatic_) {
@@ -119,17 +143,19 @@ Polymer({
};
// Ensure that there is a valid IPConfig object. Copy any set properties
// over the default properties to ensure all properties are set.
- if (this.ipConfig_)
+ if (this.ipConfig_) {
this.ipConfig_.ipv4 = Object.assign(defaultIpv4, this.ipConfig_.ipv4);
- else
+ } else {
this.ipConfig_ = {ipv4: defaultIpv4};
+ }
this.sendStaticIpConfig_();
return;
}
// Save the static IP configuration when switching to automatic.
- if (this.ipConfig_)
+ if (this.ipConfig_) {
this.savedStaticIp_ = this.ipConfig_.ipv4;
+ }
// Send the change.
this.fire('ip-change', {
field: 'IPAddressConfigType',
@@ -145,15 +171,17 @@ Polymer({
* @private
*/
getIPConfigUIProperties_: function(ipconfig) {
- if (!ipconfig)
+ if (!ipconfig) {
return undefined;
+ }
const result = {};
for (const key in ipconfig) {
const value = ipconfig[key];
- if (key == 'RoutingPrefix')
+ if (key == 'RoutingPrefix') {
result.RoutingPrefix = CrOnc.getRoutingPrefixAsNetmask(value);
- else
+ } else {
result[key] = value;
+ }
}
return result;
},
@@ -168,10 +196,11 @@ Polymer({
const result = {};
for (const key in ipconfig) {
const value = ipconfig[key];
- if (key == 'RoutingPrefix')
+ if (key == 'RoutingPrefix') {
result.RoutingPrefix = CrOnc.getRoutingPrefixAsLength(value);
- else
+ } else {
result[key] = value;
+ }
}
return result;
},
@@ -181,11 +210,13 @@ Polymer({
* @private
*/
hasIpConfigFields_: function() {
- if (!this.ipConfigFields_)
+ if (!this.ipConfigFields_) {
return false;
+ }
for (let i = 0; i < this.ipConfigFields_.length; ++i) {
- if (this.get(this.ipConfigFields_[i], this.ipConfig_) != undefined)
+ if (this.get(this.ipConfigFields_[i], this.ipConfig_) != undefined) {
return true;
+ }
}
return false;
},
@@ -195,8 +226,9 @@ Polymer({
* @private
*/
getIPEditFields_: function() {
- if (!this.editable || this.automatic_)
+ if (!this.editable || this.automatic_) {
return {};
+ }
return {
'ipv4.IPAddress': 'String',
'ipv4.RoutingPrefix': 'String',
@@ -211,8 +243,9 @@ Polymer({
* @private
*/
onIPChange_: function(event) {
- if (!this.ipConfig_)
+ if (!this.ipConfig_) {
return;
+ }
const field = event.detail.field;
const value = event.detail.value;
// Note: |field| includes the 'ipv4.' prefix.