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

Side by Side Diff: chrome/browser/resources/settings/internet_page/internet_detail_page.js

Issue 2178083002: MD Settings: Network details cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_609156_internet_cleanup_2
Patch Set: More feedback Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'settings-internet-detail' is the settings subpage containing details 7 * 'settings-internet-detail' is the settings subpage containing details
8 * for a network. 8 * for a network.
9 */ 9 */
10 (function() { 10 (function() {
(...skipping 14 matching lines...) Expand all
25 type: String, 25 type: String,
26 value: '', 26 value: '',
27 }, 27 },
28 28
29 /** 29 /**
30 * The current properties for the network matching |guid|. 30 * The current properties for the network matching |guid|.
31 * @type {!CrOnc.NetworkProperties|undefined} 31 * @type {!CrOnc.NetworkProperties|undefined}
32 */ 32 */
33 networkProperties: { 33 networkProperties: {
34 type: Object, 34 type: Object,
35 observer: 'networkPropertiesChanged_' 35 observer: 'networkPropertiesChanged_',
36 }, 36 },
37 37
38 /** 38 /**
39 * The network AutoConnect state. 39 * The network AutoConnect state.
40 */ 40 */
41 autoConnect: { 41 autoConnect: {
42 type: Boolean, 42 type: Boolean,
43 value: false, 43 value: false,
44 observer: 'autoConnectChanged_' 44 observer: 'autoConnectChanged_',
45 }, 45 },
46 46
47 /** 47 /**
48 * The network preferred state. 48 * The network preferred state.
49 */ 49 */
50 preferNetwork: { 50 preferNetwork: {
51 type: Boolean, 51 type: Boolean,
52 value: false, 52 value: false,
53 observer: 'preferNetworkChanged_' 53 observer: 'preferNetworkChanged_',
54 }, 54 },
55 55
56 /** 56 /**
57 * The network IP Address. 57 * The network IP Address.
58 */ 58 */
59 IPAddress: { 59 IPAddress: {
60 type: String, 60 type: String,
61 value: '' 61 value: '',
62 }, 62 },
63 63
64 /** 64 /**
65 * Highest priority connected network or null. 65 * Highest priority connected network or null.
66 * @type {?CrOnc.NetworkStateProperties} 66 * @type {?CrOnc.NetworkStateProperties}
67 */ 67 */
68 defaultNetwork: { 68 defaultNetwork: {
69 type: Object, 69 type: Object,
70 value: null 70 value: null,
71 }, 71 },
72 72
73 advancedExpanded: {type: Boolean},
74
73 /** 75 /**
74 * Object providing network type values for data binding. 76 * Object providing network type values for data binding.
75 * @const 77 * @const
76 */ 78 */
77 NetworkType: { 79 NetworkType: {
78 type: Object, 80 type: Object,
79 value: { 81 value: {
80 CELLULAR: CrOnc.Type.CELLULAR, 82 CELLULAR: CrOnc.Type.CELLULAR,
81 ETHERNET: CrOnc.Type.ETHERNET, 83 ETHERNET: CrOnc.Type.ETHERNET,
82 VPN: CrOnc.Type.VPN, 84 VPN: CrOnc.Type.VPN,
83 WIFI: CrOnc.Type.WI_FI, 85 WIFI: CrOnc.Type.WI_FI,
84 WIMAX: CrOnc.Type.WI_MAX, 86 WIMAX: CrOnc.Type.WI_MAX,
85 }, 87 },
86 readOnly: true 88 readOnly: true
87 }, 89 },
88 90
89 /** 91 /**
90 * Interface for networkingPrivate calls, passed from internet_page. 92 * Interface for networkingPrivate calls, passed from internet_page.
91 * @type {NetworkingPrivate} 93 * @type {NetworkingPrivate}
92 */ 94 */
93 networkingPrivate: { 95 networkingPrivate: {type: Object},
94 type: Object,
95 },
96 }, 96 },
97 97
98 observers: [ 98 observers: [
99 'guidChanged_(guid, networkingPrivate)', 99 'guidChanged_(guid, networkingPrivate)',
100 ], 100 ],
101 101
102 /** 102 /**
103 * Listener function for chrome.networkingPrivate.onNetworksChanged event. 103 * Listener function for chrome.networkingPrivate.onNetworksChanged event.
104 * @type {function(!Array<string>)} 104 * @type {function(!Array<string>)}
105 * @private 105 * @private
106 */ 106 */
107 networksChangedListener_: function() {}, 107 networksChangedListener_: function() {},
108 108
109 /** @override */ 109 /** @override */
110 attached: function() { 110 attached: function() {
111 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this); 111 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this);
112 this.networkingPrivate.onNetworksChanged.addListener( 112 this.networkingPrivate.onNetworksChanged.addListener(
113 this.networksChangedListener_); 113 this.networksChangedListener_);
114 }, 114 },
115 115
116 /** @override */ 116 /** @override */
117 detached: function() { 117 detached: function() {
118 this.networkingPrivate.onNetworksChanged.removeListener( 118 this.networkingPrivate.onNetworksChanged.removeListener(
119 this.networksChangedListener_); 119 this.networksChangedListener_);
120 }, 120 },
121 121
122 /** 122 /** @private */
123 * Polymer guid changed method.
124 */
125 guidChanged_: function() { 123 guidChanged_: function() {
126 if (!this.guid) 124 if (!this.guid)
127 return; 125 return;
128 this.getNetworkDetails_(); 126 this.getNetworkDetails_();
129 }, 127 },
130 128
131 /** 129 /** @private */
132 * Polymer networkProperties changed method.
133 */
134 networkPropertiesChanged_: function() { 130 networkPropertiesChanged_: function() {
135 if (!this.networkProperties) 131 if (!this.networkProperties)
136 return; 132 return;
137 133
138 // Update autoConnect if it has changed. Default value is false. 134 // Update autoConnect if it has changed. Default value is false.
139 var autoConnect = CrOnc.getAutoConnect(this.networkProperties); 135 var autoConnect = CrOnc.getAutoConnect(this.networkProperties);
140 if (autoConnect != this.autoConnect) 136 if (autoConnect != this.autoConnect)
141 this.autoConnect = autoConnect; 137 this.autoConnect = autoConnect;
142 138
143 // Update preferNetwork if it has changed. Default value is false. 139 // Update preferNetwork if it has changed. Default value is false.
144 var priority = /** @type {number} */(CrOnc.getActiveValue( 140 var priority = /** @type {number} */ (
145 this.networkProperties.Priority) || 0); 141 CrOnc.getActiveValue(this.networkProperties.Priority) || 0);
146 var preferNetwork = priority > 0; 142 var preferNetwork = priority > 0;
147 if (preferNetwork != this.preferNetwork) 143 if (preferNetwork != this.preferNetwork)
148 this.preferNetwork = preferNetwork; 144 this.preferNetwork = preferNetwork;
149 145
150 // Set the IPAddress property to the IPV4 Address. 146 // Set the IPAddress property to the IPV4 Address.
151 var ipv4 = 147 var ipv4 =
152 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); 148 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4);
153 this.IPAddress = (ipv4 && ipv4.IPAddress) || ''; 149 this.IPAddress = (ipv4 && ipv4.IPAddress) || '';
154 }, 150 },
155 151
156 /** 152 /** @private */
157 * Polymer autoConnect changed method.
158 */
159 autoConnectChanged_: function() { 153 autoConnectChanged_: function() {
160 if (!this.networkProperties || !this.guid) 154 if (!this.networkProperties || !this.guid)
161 return; 155 return;
162 var onc = this.getEmptyNetworkProperties_(); 156 var onc = this.getEmptyNetworkProperties_();
163 CrOnc.setTypeProperty(onc, 'AutoConnect', this.autoConnect); 157 CrOnc.setTypeProperty(onc, 'AutoConnect', this.autoConnect);
164 this.setNetworkProperties_(onc); 158 this.setNetworkProperties_(onc);
165 }, 159 },
166 160
167 /** 161 /** @private */
168 * Polymer preferNetwork changed method.
169 */
170 preferNetworkChanged_: function() { 162 preferNetworkChanged_: function() {
171 if (!this.networkProperties || !this.guid) 163 if (!this.networkProperties || !this.guid)
172 return; 164 return;
173 var onc = this.getEmptyNetworkProperties_(); 165 var onc = this.getEmptyNetworkProperties_();
174 onc.Priority = this.preferNetwork ? 1 : 0; 166 onc.Priority = this.preferNetwork ? 1 : 0;
175 this.setNetworkProperties_(onc); 167 this.setNetworkProperties_(onc);
176 }, 168 },
177 169
178 /** 170 /**
179 * networkingPrivate.onNetworksChanged event callback. 171 * networkingPrivate.onNetworksChanged event callback.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 getEmptyNetworkProperties_: function() { 228 getEmptyNetworkProperties_: function() {
237 return {Type: this.networkProperties.Type}; 229 return {Type: this.networkProperties.Type};
238 }, 230 },
239 231
240 /** 232 /**
241 * @param {!CrOnc.NetworkProperties} properties 233 * @param {!CrOnc.NetworkProperties} properties
242 * @return {string} The text to display for the network name. 234 * @return {string} The text to display for the network name.
243 * @private 235 * @private
244 */ 236 */
245 getStateName_: function(properties) { 237 getStateName_: function(properties) {
246 return /** @type {string} */(CrOnc.getActiveValue( 238 return /** @type {string} */ (
247 this.networkProperties.Name) || ''); 239 CrOnc.getActiveValue(this.networkProperties.Name) || '');
248 }, 240 },
249 241
250 /** 242 /**
251 * @param {!CrOnc.NetworkProperties} properties 243 * @param {!CrOnc.NetworkProperties} properties
252 * @return {string} The text to display for the network connection state. 244 * @return {string} The text to display for the network connection state.
253 * @private 245 * @private
254 */ 246 */
255 getStateText_: function(properties) { 247 getStateText_: function(properties) {
256 // TODO(stevenjb): Localize. 248 // TODO(stevenjb): Localize.
257 return (properties && properties.ConnectionState) || ''; 249 return (properties && properties.ConnectionState) || '';
258 }, 250 },
259 251
260 /** 252 /**
261 * @param {!CrOnc.NetworkProperties} properties 253 * @param {!CrOnc.NetworkProperties} properties
262 * @return {boolean} True if the network is connected. 254 * @return {boolean} True if the network is connected.
263 * @private 255 * @private
264 */ 256 */
265 isConnectedState_: function(properties) { 257 isConnectedState_: function(properties) {
266 return properties.ConnectionState == CrOnc.ConnectionState.CONNECTED; 258 return properties.ConnectionState == CrOnc.ConnectionState.CONNECTED;
267 }, 259 },
268 260
269 /** 261 /**
270 * @param {!CrOnc.NetworkProperties} properties 262 * @param {!CrOnc.NetworkProperties} properties
271 * @return {boolean} Whether or not to show the 'Connect' button. 263 * @return {boolean}
272 * @private 264 * @private
273 */ 265 */
274 showConnect_: function(properties) { 266 showConnect_: function(properties) {
275 return properties.Type != CrOnc.Type.ETHERNET && 267 return properties.Type != CrOnc.Type.ETHERNET &&
276 properties.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED; 268 properties.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED;
277 }, 269 },
278 270
279 /** 271 /**
280 * @param {!CrOnc.NetworkProperties} properties 272 * @param {!CrOnc.NetworkProperties} properties
281 * @return {boolean} Whether or not to show the 'Activate' button. 273 * @return {boolean}
282 * @private 274 * @private
283 */ 275 */
284 showActivate_: function(properties) { 276 showActivate_: function(properties) {
285 if (!properties || properties.Type != CrOnc.Type.CELLULAR) 277 if (!properties || properties.Type != CrOnc.Type.CELLULAR)
286 return false; 278 return false;
287 var activation = properties.Cellular.ActivationState; 279 var activation = properties.Cellular.ActivationState;
288 return activation == CrOnc.ActivationState.NOT_ACTIVATED || 280 return activation == CrOnc.ActivationState.NOT_ACTIVATED ||
289 activation == CrOnc.ActivationState.PARTIALLY_ACTIVATED; 281 activation == CrOnc.ActivationState.PARTIALLY_ACTIVATED;
290 }, 282 },
291 283
292 /** 284 /**
293 * @param {!CrOnc.NetworkProperties} properties 285 * @param {!CrOnc.NetworkProperties} properties
294 * @return {boolean} Whether or not to show the 'View Account' button. 286 * @return {boolean}
295 * @private 287 * @private
296 */ 288 */
297 showViewAccount_: function(properties) { 289 showViewAccount_: function(properties) {
298 // Show either the 'Activate' or the 'View Account' button. 290 // Show either the 'Activate' or the 'View Account' button.
299 if (this.showActivate_(properties)) 291 if (this.showActivate_(properties))
300 return false; 292 return false;
301 293
302 if (!properties || properties.Type != CrOnc.Type.CELLULAR || 294 if (!properties || properties.Type != CrOnc.Type.CELLULAR ||
303 !properties.Cellular) { 295 !properties.Cellular) {
304 return false; 296 return false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return false; 329 return false;
338 if (properties.Type == CrOnc.Type.CELLULAR && CrOnc.isSimLocked(properties)) 330 if (properties.Type == CrOnc.Type.CELLULAR && CrOnc.isSimLocked(properties))
339 return false; 331 return false;
340 if (properties.Type == CrOnc.Type.VPN && !defaultNetwork) 332 if (properties.Type == CrOnc.Type.VPN && !defaultNetwork)
341 return false; 333 return false;
342 return true; 334 return true;
343 }, 335 },
344 336
345 /** 337 /**
346 * @param {!CrOnc.NetworkProperties} properties 338 * @param {!CrOnc.NetworkProperties} properties
347 * @return {boolean} Whether or not to show the 'Disconnect' button. 339 * @return {boolean}
348 * @private 340 * @private
349 */ 341 */
350 showDisconnect_: function(properties) { 342 showDisconnect_: function(properties) {
351 return properties.Type != CrOnc.Type.ETHERNET && 343 return properties.Type != CrOnc.Type.ETHERNET &&
352 properties.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED; 344 properties.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED;
353 }, 345 },
354 346
355 /** 347 /** @private */
356 * Callback when the Connect button is tapped.
357 * @private
358 */
359 onConnectTap_: function() { 348 onConnectTap_: function() {
360 this.networkingPrivate.startConnect(this.guid); 349 this.networkingPrivate.startConnect(this.guid);
361 }, 350 },
362 351
363 /** 352 /** @private */
364 * Callback when the Disconnect button is tapped.
365 * @private
366 */
367 onDisconnectTap_: function() { 353 onDisconnectTap_: function() {
368 this.networkingPrivate.startDisconnect(this.guid); 354 this.networkingPrivate.startDisconnect(this.guid);
369 }, 355 },
370 356
371 /** 357 /** @private */
372 * Callback when the Activate button is tapped.
373 * @private
374 */
375 onActivateTap_: function() { 358 onActivateTap_: function() {
376 this.networkingPrivate.startActivate(this.guid); 359 this.networkingPrivate.startActivate(this.guid);
377 }, 360 },
378 361
379 /** 362 /** @private */
380 * Callback when the View Account button is tapped.
381 * @private
382 */
383 onViewAccountTap_: function() { 363 onViewAccountTap_: function() {
384 // startActivate() will show the account page for activated networks. 364 // startActivate() will show the account page for activated networks.
385 this.networkingPrivate.startActivate(this.guid); 365 this.networkingPrivate.startActivate(this.guid);
386 }, 366 },
387 367
388 /** 368 /**
369 * @param {Event} event
370 * @private
371 */
372 toggleAdvancedExpanded_: function(event) {
373 if (event.target.id == 'expandButton')
374 return; // Already handled.
375 this.advancedExpanded = !this.advancedExpanded;
376 },
377
378 /**
389 * Event triggered for elements associated with network properties. 379 * Event triggered for elements associated with network properties.
390 * @param {!{detail: !{field: string, value: (string|!Object)}}} event 380 * @param {!{detail: !{field: string, value: (string|!Object)}}} event
391 * @private 381 * @private
392 */ 382 */
393 onNetworkPropertyChange_: function(event) { 383 onNetworkPropertyChange_: function(event) {
394 if (!this.networkProperties) 384 if (!this.networkProperties)
395 return; 385 return;
396 var field = event.detail.field; 386 var field = event.detail.field;
397 var value = event.detail.value; 387 var value = event.detail.value;
398 var onc = this.getEmptyNetworkProperties_(); 388 var onc = this.getEmptyNetworkProperties_();
(...skipping 18 matching lines...) Expand all
417 */ 407 */
418 onIPConfigChange_: function(event) { 408 onIPConfigChange_: function(event) {
419 if (!this.networkProperties) 409 if (!this.networkProperties)
420 return; 410 return;
421 var field = event.detail.field; 411 var field = event.detail.field;
422 var value = event.detail.value; 412 var value = event.detail.value;
423 // Get an empty ONC dictionary and set just the IP Config properties that 413 // Get an empty ONC dictionary and set just the IP Config properties that
424 // need to change. 414 // need to change.
425 var onc = this.getEmptyNetworkProperties_(); 415 var onc = this.getEmptyNetworkProperties_();
426 var ipConfigType = 416 var ipConfigType =
427 /** @type {chrome.networkingPrivate.IPConfigType|undefined} */( 417 /** @type {chrome.networkingPrivate.IPConfigType|undefined} */ (
428 CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType)); 418 CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType));
429 if (field == 'IPAddressConfigType') { 419 if (field == 'IPAddressConfigType') {
430 var newIpConfigType = 420 var newIpConfigType =
431 /** @type {chrome.networkingPrivate.IPConfigType} */(value); 421 /** @type {chrome.networkingPrivate.IPConfigType} */ (value);
432 if (newIpConfigType == ipConfigType) 422 if (newIpConfigType == ipConfigType)
433 return; 423 return;
434 onc.IPAddressConfigType = newIpConfigType; 424 onc.IPAddressConfigType = newIpConfigType;
435 } else if (field == 'NameServersConfigType') { 425 } else if (field == 'NameServersConfigType') {
436 var nsConfigType = 426 var nsConfigType =
437 /** @type {chrome.networkingPrivate.IPConfigType|undefined} */( 427 /** @type {chrome.networkingPrivate.IPConfigType|undefined} */ (
438 CrOnc.getActiveValue( 428 CrOnc.getActiveValue(
439 this.networkProperties.NameServersConfigType)); 429 this.networkProperties.NameServersConfigType));
440 var newNsConfigType = 430 var newNsConfigType =
441 /** @type {chrome.networkingPrivate.IPConfigType} */(value); 431 /** @type {chrome.networkingPrivate.IPConfigType} */ (value);
442 if (newNsConfigType == nsConfigType) 432 if (newNsConfigType == nsConfigType)
443 return; 433 return;
444 onc.NameServersConfigType = newNsConfigType; 434 onc.NameServersConfigType = newNsConfigType;
445 } else if (field == 'StaticIPConfig') { 435 } else if (field == 'StaticIPConfig') {
446 if (ipConfigType == CrOnc.IPConfigType.STATIC) { 436 if (ipConfigType == CrOnc.IPConfigType.STATIC) {
447 var staticIpConfig = this.networkProperties.StaticIPConfig; 437 let staticIpConfig = this.networkProperties.StaticIPConfig;
438 let ipConfigValue = /** @type {!Object} */ (value);
448 if (staticIpConfig && 439 if (staticIpConfig &&
449 this.allPropertiesMatch_(staticIpConfig, 440 this.allPropertiesMatch_(staticIpConfig, ipConfigValue)) {
450 /** @type {!Object} */(value))) {
451 return; 441 return;
452 } 442 }
453 } 443 }
454 onc.IPAddressConfigType = CrOnc.IPConfigType.STATIC; 444 onc.IPAddressConfigType = CrOnc.IPConfigType.STATIC;
455 if (!onc.StaticIPConfig) { 445 if (!onc.StaticIPConfig) {
456 onc.StaticIPConfig = 446 onc.StaticIPConfig =
457 /** @type {!chrome.networkingPrivate.IPConfigProperties} */({}); 447 /** @type {!chrome.networkingPrivate.IPConfigProperties} */ ({});
458 } 448 }
459 for (let key in value) 449 for (let key in value)
460 onc.StaticIPConfig[key] = value[key]; 450 onc.StaticIPConfig[key] = value[key];
461 } else if (field == 'NameServers') { 451 } else if (field == 'NameServers') {
462 // If a StaticIPConfig property is specified and its NameServers value 452 // If a StaticIPConfig property is specified and its NameServers value
463 // matches the new value, no need to set anything. 453 // matches the new value, no need to set anything.
464 var nameServers = /** @type {!Array<string>} */(value); 454 let nameServers = /** @type {!Array<string>} */ (value);
465 if (onc.NameServersConfigType == CrOnc.IPConfigType.STATIC && 455 if (onc.NameServersConfigType == CrOnc.IPConfigType.STATIC &&
466 onc.StaticIPConfig && 456 onc.StaticIPConfig && onc.StaticIPConfig.NameServers == nameServers) {
467 onc.StaticIPConfig.NameServers == nameServers) {
468 return; 457 return;
469 } 458 }
470 onc.NameServersConfigType = CrOnc.IPConfigType.STATIC; 459 onc.NameServersConfigType = CrOnc.IPConfigType.STATIC;
471 if (!onc.StaticIPConfig) { 460 if (!onc.StaticIPConfig) {
472 onc.StaticIPConfig = 461 onc.StaticIPConfig =
473 /** @type {!chrome.networkingPrivate.IPConfigProperties} */({}); 462 /** @type {!chrome.networkingPrivate.IPConfigProperties} */ ({});
474 } 463 }
475 onc.StaticIPConfig.NameServers = nameServers; 464 onc.StaticIPConfig.NameServers = nameServers;
476 } else { 465 } else {
477 console.error('Unexpected change field: ' + field); 466 console.error('Unexpected change field: ' + field);
478 return; 467 return;
479 } 468 }
480 // setValidStaticIPConfig will fill in any other properties from 469 // setValidStaticIPConfig will fill in any other properties from
481 // networkProperties. This is necessary since we update IP Address and 470 // networkProperties. This is necessary since we update IP Address and
482 // NameServers independently. 471 // NameServers independently.
483 CrOnc.setValidStaticIPConfig(onc, this.networkProperties); 472 CrOnc.setValidStaticIPConfig(onc, this.networkProperties);
484 this.setNetworkProperties_(onc); 473 this.setNetworkProperties_(onc);
485 }, 474 },
486 475
487 /** 476 /**
488 * Event triggered when the Proxy configuration element changes. 477 * Event triggered when the Proxy configuration element changes.
489 * @param {!{detail: {field: string, value: !CrOnc.ProxySettings}}} event 478 * @param {!{detail: {field: string, value: !CrOnc.ProxySettings}}} event
490 * The network-proxy change event. 479 * The network-proxy change event.
491 * @private 480 * @private
492 */ 481 */
493 onProxyChange_: function(event) { 482 onProxyChange_: function(event) {
494 if (!this.networkProperties) 483 if (!this.networkProperties)
495 return; 484 return;
496 var field = event.detail.field; 485 var field = event.detail.field;
497 var value = event.detail.value; 486 var value = event.detail.value;
498 if (field != 'ProxySettings') 487 if (field != 'ProxySettings')
499 return; 488 return;
500 var onc = this.getEmptyNetworkProperties_(); 489 var onc = this.getEmptyNetworkProperties_();
501 CrOnc.setProperty(onc, 'ProxySettings', /** @type {!Object} */(value)); 490 CrOnc.setProperty(onc, 'ProxySettings', /** @type {!Object} */ (value));
502 this.setNetworkProperties_(onc); 491 this.setNetworkProperties_(onc);
503 }, 492 },
504 493
505 /** 494 /**
506 * @param {!CrOnc.NetworkProperties} properties 495 * @param {!CrOnc.NetworkProperties} properties
507 * @return {boolean} True if the shared message should be shown. 496 * @return {boolean} True if the shared message should be shown.
508 * @private 497 * @private
509 */ 498 */
510 showShared_: function(properties) { 499 showShared_: function(properties) {
511 return properties.Source == 'Device' || properties.Source == 'DevicePolicy'; 500 return properties.Source == 'Device' || properties.Source == 'DevicePolicy';
512 }, 501 },
513 502
514 /** 503 /**
515 * @param {!CrOnc.NetworkProperties} properties 504 * @param {!CrOnc.NetworkProperties} properties
516 * @return {boolean} True if the AutoConnect checkbox should be shown. 505 * @return {boolean} True if the AutoConnect checkbox should be shown.
517 * @private 506 * @private
518 */ 507 */
519 showAutoConnect_: function(properties) { 508 showAutoConnect_: function(properties) {
520 return properties.Type != CrOnc.Type.ETHERNET && 509 return properties.Type != CrOnc.Type.ETHERNET &&
521 properties.Source != CrOnc.Source.NONE; 510 properties.Source != CrOnc.Source.NONE;
522 }, 511 },
523 512
524 /** 513 /**
525 * @param {!CrOnc.NetworkProperties} properties 514 * @param {!CrOnc.NetworkProperties} properties
526 * @return {!CrOnc.ManagedProperty|undefined} Managed AutoConnect property. 515 * @return {!CrOnc.ManagedProperty|undefined} Managed AutoConnect property.
527 * @private 516 * @private
528 */ 517 */
529 getManagedAutoConnect_: function(properties) { 518 getManagedAutoConnect_: function(properties) {
530 return CrOnc.getManagedAutoConnect(properties); 519 return CrOnc.getManagedAutoConnect(properties);
531 }, 520 },
532 521
533 /** 522 /**
534 * @param {!CrOnc.NetworkProperties} properties 523 * @param {!CrOnc.NetworkProperties} properties
535 * @return {boolean} True if the prefer network checkbox should be shown. 524 * @return {boolean} True if the prefer network checkbox should be shown.
536 * @private 525 * @private
537 */ 526 */
538 showPreferNetwork_: function(properties) { 527 showPreferNetwork_: function(properties) {
539 // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for 528 // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for
540 // properties.Type == CrOnc.Type.ETHERNET. 529 // properties.Type == CrOnc.Type.ETHERNET.
541 return properties.Source != CrOnc.Source.NONE; 530 return properties.Source != CrOnc.Source.NONE;
542 }, 531 },
543 532
544 /** 533 /**
545 * @param {boolean} preferNetwork 534 * @param {!Array<string>} fields
546 * @return {string} The icon to use for the preferred button. 535 * @return {boolean}
547 * @private 536 * @private
548 */ 537 */
549 getPreferredIcon_: function(preferNetwork) { 538 hasVisibleFields_: function(fields) {
550 return preferNetwork ? 'cr:star' : 'cr:star-border'; 539 for (let key of fields) {
540 let value = this.get(key, this.networkProperties);
541 if (value !== undefined && value !== '')
542 return true;
543 }
544 return false;
551 }, 545 },
552 546
553 /** 547 /**
548 * @param {!CrOnc.NetworkProperties} properties
549 * @return {boolean}
550 * @private
551 */
552 hasInfoFields_: function(properties) {
553 return this.hasVisibleFields_(this.getInfoFields_(properties));
554 },
555
556 /**
554 * @param {!CrOnc.NetworkProperties} properties 557 * @param {!CrOnc.NetworkProperties} properties
555 * @return {!Array<string>} The fields to display in the info section. 558 * @return {!Array<string>} The fields to display in the info section.
556 * @private 559 * @private
557 */ 560 */
558 getInfoFields_: function(properties) { 561 getInfoFields_: function(properties) {
559 /** @type {!Array<string>} */ var fields = []; 562 /** @type {!Array<string>} */ var fields = [];
560 if (!properties) 563 if (!properties)
561 return fields; 564 return fields;
562 565
563 if (properties.Type == CrOnc.Type.CELLULAR) { 566 if (properties.Type == CrOnc.Type.CELLULAR) {
564 fields.push('Cellular.ActivationState', 567 fields.push(
565 'Cellular.RoamingState', 568 'Cellular.ActivationState', 'Cellular.RoamingState',
566 'RestrictedConnectivity', 569 'RestrictedConnectivity', 'Cellular.ServingOperator.Name');
567 'Cellular.ServingOperator.Name');
568 } 570 }
569 if (properties.Type == CrOnc.Type.VPN) { 571 if (properties.Type == CrOnc.Type.VPN) {
570 fields.push('VPN.Host', 'VPN.Type'); 572 fields.push('VPN.Host', 'VPN.Type');
571 if (properties.VPN.Type == 'OpenVPN') 573 if (properties.VPN.Type == 'OpenVPN')
572 fields.push('VPN.OpenVPN.Username'); 574 fields.push('VPN.OpenVPN.Username');
573 else if (properties.VPN.Type == 'L2TP-IPsec') 575 else if (properties.VPN.Type == 'L2TP-IPsec')
574 fields.push('VPN.L2TP.Username'); 576 fields.push('VPN.L2TP.Username');
575 else if (properties.VPN.Type == 'ThirdPartyVPN') 577 else if (properties.VPN.Type == 'ThirdPartyVPN')
576 fields.push('VPN.ThirdPartyVPN.ProviderName'); 578 fields.push('VPN.ThirdPartyVPN.ProviderName');
577 } 579 }
578 if (properties.Type == CrOnc.Type.WI_FI) 580 if (properties.Type == CrOnc.Type.WI_FI)
579 fields.push('RestrictedConnectivity'); 581 fields.push('RestrictedConnectivity');
580 if (properties.Type == CrOnc.Type.WI_MAX) { 582 if (properties.Type == CrOnc.Type.WI_MAX) {
581 fields.push('RestrictedConnectivity', 'WiMAX.EAP.Identity'); 583 fields.push('RestrictedConnectivity', 'WiMAX.EAP.Identity');
582 } 584 }
583 return fields; 585 return fields;
584 }, 586 },
585 587
586 /** 588 /**
587 * @param {!CrOnc.NetworkProperties} properties 589 * @param {!CrOnc.NetworkProperties} properties
588 * @return {!Array<string>} The fields to display in the Advanced section. 590 * @return {!Array<string>} The fields to display in the Advanced section.
589 * @private 591 * @private
590 */ 592 */
591 getAdvancedFields_: function(properties) { 593 getAdvancedFields_: function(properties) {
592 /** @type {!Array<string>} */ var fields = []; 594 /** @type {!Array<string>} */ var fields = [];
593 if (!properties) 595 if (!properties)
594 return fields; 596 return fields;
595 fields.push('MacAddress'); 597 fields.push('MacAddress');
596 if (properties.Type == CrOnc.Type.CELLULAR) { 598 if (properties.Type == CrOnc.Type.CELLULAR) {
597 fields.push('Cellular.Carrier', 599 fields.push(
598 'Cellular.Family', 600 'Cellular.Carrier', 'Cellular.Family', 'Cellular.NetworkTechnology',
599 'Cellular.NetworkTechnology', 601 'Cellular.ServingOperator.Code');
600 'Cellular.ServingOperator.Code');
601 } 602 }
602 if (properties.Type == CrOnc.Type.WI_FI) { 603 if (properties.Type == CrOnc.Type.WI_FI) {
603 fields.push('WiFi.SSID', 604 fields.push(
604 'WiFi.BSSID', 605 'WiFi.SSID', 'WiFi.BSSID', 'WiFi.Security', 'WiFi.SignalStrength',
605 'WiFi.Security', 606 'WiFi.Frequency');
606 'WiFi.SignalStrength',
607 'WiFi.Frequency');
608 } 607 }
609 if (properties.Type == CrOnc.Type.WI_MAX) 608 if (properties.Type == CrOnc.Type.WI_MAX)
610 fields.push('WiFi.SignalStrength'); 609 fields.push('WiFi.SignalStrength');
611 return fields; 610 return fields;
612 }, 611 },
613 612
614 /** 613 /**
615 * @param {!CrOnc.NetworkProperties} properties 614 * @param {!CrOnc.NetworkProperties} properties
616 * @return {!Array<string>} The fields to display in the device section. 615 * @return {!Array<string>} The fields to display in the device section.
617 * @private 616 * @private
618 */ 617 */
619 getDeviceFields_: function(properties) { 618 getDeviceFields_: function(properties) {
620 /** @type {!Array<string>} */ var fields = []; 619 /** @type {!Array<string>} */ var fields = [];
621 if (!properties) 620 if (!properties)
622 return fields; 621 return fields;
623 if (properties.Type == CrOnc.Type.CELLULAR) { 622 if (properties.Type == CrOnc.Type.CELLULAR) {
624 fields.push('Cellular.HomeProvider.Name', 623 fields.push(
625 'Cellular.HomeProvider.Country', 624 'Cellular.HomeProvider.Name', 'Cellular.HomeProvider.Country',
626 'Cellular.HomeProvider.Code', 625 'Cellular.HomeProvider.Code', 'Cellular.Manufacturer',
627 'Cellular.Manufacturer', 626 'Cellular.ModelID', 'Cellular.FirmwareRevision',
628 'Cellular.ModelID', 627 'Cellular.HardwareRevision', 'Cellular.ESN', 'Cellular.ICCID',
629 'Cellular.FirmwareRevision', 628 'Cellular.IMEI', 'Cellular.IMSI', 'Cellular.MDN', 'Cellular.MEID',
630 'Cellular.HardwareRevision', 629 'Cellular.MIN', 'Cellular.PRLVersion');
631 'Cellular.ESN',
632 'Cellular.ICCID',
633 'Cellular.IMEI',
634 'Cellular.IMSI',
635 'Cellular.MDN',
636 'Cellular.MEID',
637 'Cellular.MIN',
638 'Cellular.PRLVersion');
639 } 630 }
640 return fields; 631 return fields;
641 }, 632 },
642 633
643 /** 634 /**
644 * @param {!CrOnc.NetworkProperties} properties 635 * @param {!CrOnc.NetworkProperties} properties
645 * @return {boolean} True if there are any advanced fields to display. 636 * @return {boolean}
646 * @private 637 * @private
647 */ 638 */
648 hasAdvancedOrDeviceFields_: function(properties) { 639 hasAdvancedOrDeviceFields_: function(properties) {
649 return this.getAdvancedFields_(properties).length > 0 || 640 return this.hasAdvancedFields_(properties) ||
650 this.hasDeviceFields_(properties); 641 this.hasDeviceFields_(properties);
651 }, 642 },
652 643
653 /** 644 /**
654 * @param {!CrOnc.NetworkProperties} properties 645 * @param {!CrOnc.NetworkProperties} properties
655 * @return {boolean} True if there are any device fields to display. 646 * @return {boolean}
647 * @private
648 */
649 hasAdvancedFields_: function(properties) {
650 return this.hasVisibleFields_(this.getAdvancedFields_(properties));
651 },
652
653 /**
654 * @param {!CrOnc.NetworkProperties} properties
655 * @return {boolean}
656 * @private 656 * @private
657 */ 657 */
658 hasDeviceFields_: function(properties) { 658 hasDeviceFields_: function(properties) {
659 var fields = this.getDeviceFields_(properties); 659 return this.hasVisibleFields_(this.getDeviceFields_(properties));
660 return fields.length > 0;
661 }, 660 },
662 661
663 /** 662 /**
664 * @param {!CrOnc.NetworkProperties} properties 663 * @param {!CrOnc.NetworkProperties} properties
665 * @return {boolean} True if the network section should be shown. 664 * @return {boolean} True if the network section should be shown.
666 * @private 665 * @private
667 */ 666 */
668 hasNetworkSection_: function(properties) { 667 hasNetworkSection_: function(properties) {
669 return properties.Type != CrOnc.Type.VPN; 668 return properties.Type != CrOnc.Type.VPN;
670 }, 669 },
(...skipping 30 matching lines...) Expand all
701 */ 700 */
702 allPropertiesMatch_: function(curValue, newValue) { 701 allPropertiesMatch_: function(curValue, newValue) {
703 for (let key in newValue) { 702 for (let key in newValue) {
704 if (newValue[key] != curValue[key]) 703 if (newValue[key] != curValue[key])
705 return false; 704 return false;
706 } 705 }
707 return true; 706 return true;
708 } 707 }
709 }); 708 });
710 })(); 709 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698