OLD | NEW |
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 * 'cr-settings-internet-detail' is the settings subpage containing details | 7 * 'cr-settings-internet-detail' is the settings subpage containing details |
8 * for a network. | 8 * for a network. |
9 * | 9 * |
10 * @group Chrome Settings Elements | 10 * @group Chrome Settings Elements |
11 * @element cr-settings-internet-detail | 11 * @element cr-settings-internet-detail |
12 */ | 12 */ |
13 (function() { | 13 (function() { |
14 'use strict'; | 14 'use strict'; |
15 | 15 |
16 /** @const */ var CARRIER_VERIZON = 'Verizon Wireless'; | 16 /** @const */ var CARRIER_VERIZON = 'Verizon Wireless'; |
17 | 17 |
18 Polymer({ | 18 Polymer({ |
19 is: 'cr-settings-internet-detail-page', | 19 is: 'cr-settings-internet-detail-page', |
20 | 20 |
| 21 behaviors: [CrPolicyNetworkBehavior], |
| 22 |
21 properties: { | 23 properties: { |
22 /** | 24 /** |
23 * The network GUID to display details for. | 25 * The network GUID to display details for. |
24 */ | 26 */ |
25 guid: { | 27 guid: { |
26 type: String, | 28 type: String, |
27 value: '', | 29 value: '', |
28 observer: 'guidChanged_', | 30 observer: 'guidChanged_', |
29 }, | 31 }, |
30 | 32 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // TODO(stevenjb): Localize. | 239 // TODO(stevenjb): Localize. |
238 return (properties && properties.ConnectionState) || ''; | 240 return (properties && properties.ConnectionState) || ''; |
239 }, | 241 }, |
240 | 242 |
241 /** | 243 /** |
242 * @param {!CrOnc.NetworkProperties} properties | 244 * @param {!CrOnc.NetworkProperties} properties |
243 * @return {boolean} True if the network is connected. | 245 * @return {boolean} True if the network is connected. |
244 * @private | 246 * @private |
245 */ | 247 */ |
246 isConnectedState_: function(properties) { | 248 isConnectedState_: function(properties) { |
247 return !!properties && properties.ConnectionState == | 249 return properties.ConnectionState == CrOnc.ConnectionState.CONNECTED; |
248 CrOnc.ConnectionState.CONNECTED; | |
249 }, | 250 }, |
250 | 251 |
251 /** | 252 /** |
252 * @param {!CrOnc.NetworkProperties} properties | 253 * @param {!CrOnc.NetworkProperties} properties |
253 * @return {boolean} Whether or not to show the 'Connect' button. | 254 * @return {boolean} Whether or not to show the 'Connect' button. |
254 * @private | 255 * @private |
255 */ | 256 */ |
256 showConnect_: function(properties) { | 257 showConnect_: function(properties) { |
257 return !!properties && properties.Type != CrOnc.Type.ETHERNET && | 258 return properties.Type != CrOnc.Type.ETHERNET && |
258 properties.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED; | 259 properties.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED; |
259 }, | 260 }, |
260 | 261 |
261 /** | 262 /** |
262 * @param {!CrOnc.NetworkProperties} properties | 263 * @param {!CrOnc.NetworkProperties} properties |
263 * @return {boolean} Whether or not to show the 'Activate' button. | 264 * @return {boolean} Whether or not to show the 'Activate' button. |
264 * @private | 265 * @private |
265 */ | 266 */ |
266 showActivate_: function(properties) { | 267 showActivate_: function(properties) { |
267 if (!properties || properties.Type != CrOnc.Type.CELLULAR) | 268 if (!properties || properties.Type != CrOnc.Type.CELLULAR) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // TODO(stevenjb): For VPN, check connected state of any network. | 321 // TODO(stevenjb): For VPN, check connected state of any network. |
321 return true; | 322 return true; |
322 }, | 323 }, |
323 | 324 |
324 /** | 325 /** |
325 * @param {!CrOnc.NetworkProperties} properties | 326 * @param {!CrOnc.NetworkProperties} properties |
326 * @return {boolean} Whether or not to show the 'Disconnect' button. | 327 * @return {boolean} Whether or not to show the 'Disconnect' button. |
327 * @private | 328 * @private |
328 */ | 329 */ |
329 showDisconnect_: function(properties) { | 330 showDisconnect_: function(properties) { |
330 return !!properties && properties.Type != CrOnc.Type.ETHERNET && | 331 return properties.Type != CrOnc.Type.ETHERNET && |
331 properties.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED; | 332 properties.ConnectionState != CrOnc.ConnectionState.NOT_CONNECTED; |
332 }, | 333 }, |
333 | 334 |
334 /** | 335 /** |
335 * Callback when the Connect button is clicked. | 336 * Callback when the Connect button is clicked. |
336 * @private | 337 * @private |
337 */ | 338 */ |
338 onConnectClicked_: function() { | 339 onConnectClicked_: function() { |
339 chrome.networkingPrivate.startConnect(this.guid); | 340 chrome.networkingPrivate.startConnect(this.guid); |
340 }, | 341 }, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 CrOnc.setProperty(onc, 'ProxySettings', /** @type {!Object} */(value)); | 481 CrOnc.setProperty(onc, 'ProxySettings', /** @type {!Object} */(value)); |
481 this.setNetworkProperties_(onc); | 482 this.setNetworkProperties_(onc); |
482 }, | 483 }, |
483 | 484 |
484 /** | 485 /** |
485 * @param {!CrOnc.NetworkProperties} properties | 486 * @param {!CrOnc.NetworkProperties} properties |
486 * @return {boolean} True if the shared message should be shown. | 487 * @return {boolean} True if the shared message should be shown. |
487 * @private | 488 * @private |
488 */ | 489 */ |
489 showShared_: function(properties) { | 490 showShared_: function(properties) { |
490 return !!properties && (properties.Source == 'Device' || | 491 return (properties.Source == 'Device' || |
491 properties.Source == 'DevicePolicy'); | 492 properties.Source == 'DevicePolicy'); |
492 }, | 493 }, |
493 | 494 |
494 /** | 495 /** |
495 * @param {!CrOnc.NetworkProperties} properties | 496 * @param {!CrOnc.NetworkProperties} properties |
496 * @return {boolean} True if the AutoConnect checkbox should be shown. | 497 * @return {boolean} True if the AutoConnect checkbox should be shown. |
497 * @private | 498 * @private |
498 */ | 499 */ |
499 showAutoConnect_: function(properties) { | 500 showAutoConnect_: function(properties) { |
500 return !!properties && properties.Type != CrOnc.Type.ETHERNET && | 501 return properties.Type != CrOnc.Type.ETHERNET && |
501 properties.Source != CrOnc.Source.NONE; | 502 properties.Source != CrOnc.Source.NONE; |
502 }, | 503 }, |
503 | 504 |
504 /** | 505 /** |
505 * @param {!CrOnc.NetworkProperties} properties | 506 * @param {!CrOnc.NetworkProperties} properties |
| 507 * @return {!CrOnc.ManagedProperty|undefined} Managed AutoConnect property. |
| 508 * @private |
| 509 */ |
| 510 getManagedAutoConnect_: function(properties) { |
| 511 return CrOnc.getManagedAutoConnect(properties); |
| 512 }, |
| 513 |
| 514 /** |
| 515 * @param {!CrOnc.NetworkProperties} properties |
506 * @return {boolean} True if the prefer network checkbox should be shown. | 516 * @return {boolean} True if the prefer network checkbox should be shown. |
507 * @private | 517 * @private |
508 */ | 518 */ |
509 showPreferNetwork_: function(properties) { | 519 showPreferNetwork_: function(properties) { |
510 // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for | 520 // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for |
511 // properties.Type == CrOnc.Type.ETHERNET. | 521 // properties.Type == CrOnc.Type.ETHERNET. |
512 return !!properties && properties.Source != CrOnc.Source.NONE; | 522 return properties.Source != CrOnc.Source.NONE; |
513 }, | 523 }, |
514 | 524 |
515 /** | 525 /** |
516 * @param {boolean} preferNetwork | 526 * @param {boolean} preferNetwork |
517 * @return {string} The icon to use for the preferred button. | 527 * @return {string} The icon to use for the preferred button. |
518 * @private | 528 * @private |
519 */ | 529 */ |
520 getPreferredIcon_: function(preferNetwork) { | 530 getPreferredIcon_: function(preferNetwork) { |
521 return preferNetwork ? 'star' : 'star-border'; | 531 return preferNetwork ? 'star' : 'star-border'; |
522 }, | 532 }, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 var fields = this.getDeviceFields_(properties); | 640 var fields = this.getDeviceFields_(properties); |
631 return fields.length > 0; | 641 return fields.length > 0; |
632 }, | 642 }, |
633 | 643 |
634 /** | 644 /** |
635 * @param {!CrOnc.NetworkProperties} properties | 645 * @param {!CrOnc.NetworkProperties} properties |
636 * @return {boolean} True if the network section should be shown. | 646 * @return {boolean} True if the network section should be shown. |
637 * @private | 647 * @private |
638 */ | 648 */ |
639 hasNetworkSection_: function(properties) { | 649 hasNetworkSection_: function(properties) { |
640 return !!properties && properties.Type != CrOnc.Type.VPN; | 650 return properties.Type != CrOnc.Type.VPN; |
641 }, | 651 }, |
642 | 652 |
643 /** | 653 /** |
644 * @param {!CrOnc.NetworkProperties} properties | 654 * @param {!CrOnc.NetworkProperties} properties |
645 * @param {string} type The network type. | 655 * @param {string} type The network type. |
646 * @return {boolean} True if the network type matches 'type'. | 656 * @return {boolean} True if the network type matches 'type'. |
647 * @private | 657 * @private |
648 */ | 658 */ |
649 isType_: function(properties, type) { | 659 isType_: function(properties, type) { |
650 return !!properties && properties.Type == type; | 660 return properties.Type == type; |
651 }, | 661 }, |
652 | 662 |
653 /** | 663 /** |
654 * @param {!CrOnc.NetworkProperties} properties | 664 * @param {!CrOnc.NetworkProperties} properties |
655 * @return {boolean} True if the Cellular SIM section should be shown. | 665 * @return {boolean} True if the Cellular SIM section should be shown. |
656 * @private | 666 * @private |
657 */ | 667 */ |
658 showCellularSim_: function(properties) { | 668 showCellularSim_: function(properties) { |
659 if (!properties || properties.Type != 'Cellular' || !properties.Cellular) | 669 if (!properties || properties.Type != 'Cellular' || !properties.Cellular) |
660 return false; | 670 return false; |
(...skipping 11 matching lines...) Expand all Loading... |
672 */ | 682 */ |
673 allPropertiesMatch_: function(curValue, newValue) { | 683 allPropertiesMatch_: function(curValue, newValue) { |
674 for (let key in newValue) { | 684 for (let key in newValue) { |
675 if (newValue[key] != curValue[key]) | 685 if (newValue[key] != curValue[key]) |
676 return false; | 686 return false; |
677 } | 687 } |
678 return true; | 688 return true; |
679 } | 689 } |
680 }); | 690 }); |
681 })(); | 691 })(); |
OLD | NEW |