| 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 * '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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * Highest priority connected network or null. | 67 * Highest priority connected network or null. |
| 68 * @type {?CrOnc.NetworkStateProperties} | 68 * @type {?CrOnc.NetworkStateProperties} |
| 69 */ | 69 */ |
| 70 defaultNetwork: { | 70 defaultNetwork: { |
| 71 type: Object, | 71 type: Object, |
| 72 value: null, | 72 value: null, |
| 73 }, | 73 }, |
| 74 | 74 |
| 75 /** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */ |
| 76 globalPolicy: Object, |
| 77 |
| 75 /** | 78 /** |
| 76 * Interface for networkingPrivate calls, passed from internet_page. | 79 * Interface for networkingPrivate calls, passed from internet_page. |
| 77 * @type {NetworkingPrivate} | 80 * @type {NetworkingPrivate} |
| 78 */ | 81 */ |
| 79 networkingPrivate: Object, | 82 networkingPrivate: Object, |
| 80 | 83 |
| 81 /** | 84 /** |
| 82 * The network AutoConnect state. | 85 * The network AutoConnect state. |
| 83 * @private | 86 * @private |
| 84 */ | 87 */ |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 * @return {boolean} | 338 * @return {boolean} |
| 336 * @private | 339 * @private |
| 337 */ | 340 */ |
| 338 isRememberedOrConnected_: function(networkProperties) { | 341 isRememberedOrConnected_: function(networkProperties) { |
| 339 return this.isRemembered_(networkProperties) || | 342 return this.isRemembered_(networkProperties) || |
| 340 this.isConnectedState_(networkProperties); | 343 this.isConnectedState_(networkProperties); |
| 341 }, | 344 }, |
| 342 | 345 |
| 343 /** | 346 /** |
| 344 * @param {!CrOnc.NetworkProperties} networkProperties | 347 * @param {!CrOnc.NetworkProperties} networkProperties |
| 348 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy |
| 345 * @return {boolean} | 349 * @return {boolean} |
| 346 * @private | 350 * @private |
| 347 */ | 351 */ |
| 348 showConnect_: function(networkProperties) { | 352 connectNotAllowed_: function(networkProperties, globalPolicy) { |
| 353 return networkProperties.Type == CrOnc.Type.WI_FI && |
| 354 !!globalPolicy.AllowOnlyPolicyNetworksToConnect && |
| 355 !this.isPolicySource(networkProperties.Source); |
| 356 }, |
| 357 |
| 358 /** |
| 359 * @param {!CrOnc.NetworkProperties} networkProperties |
| 360 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy |
| 361 * @return {boolean} |
| 362 * @private |
| 363 */ |
| 364 showConnect_: function(networkProperties, globalPolicy) { |
| 365 if (this.connectNotAllowed_(networkProperties, globalPolicy)) |
| 366 return false; |
| 349 return networkProperties.Type != CrOnc.Type.ETHERNET && | 367 return networkProperties.Type != CrOnc.Type.ETHERNET && |
| 350 networkProperties.ConnectionState == | 368 networkProperties.ConnectionState == |
| 351 CrOnc.ConnectionState.NOT_CONNECTED; | 369 CrOnc.ConnectionState.NOT_CONNECTED; |
| 352 }, | 370 }, |
| 353 | 371 |
| 354 /** | 372 /** |
| 355 * @param {!CrOnc.NetworkProperties} networkProperties | 373 * @param {!CrOnc.NetworkProperties} networkProperties |
| 356 * @return {boolean} | 374 * @return {boolean} |
| 357 * @private | 375 * @private |
| 358 */ | 376 */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 382 showActivate_: function(networkProperties) { | 400 showActivate_: function(networkProperties) { |
| 383 if (networkProperties.Type != CrOnc.Type.CELLULAR) | 401 if (networkProperties.Type != CrOnc.Type.CELLULAR) |
| 384 return false; | 402 return false; |
| 385 var activation = networkProperties.Cellular.ActivationState; | 403 var activation = networkProperties.Cellular.ActivationState; |
| 386 return activation == CrOnc.ActivationState.NOT_ACTIVATED || | 404 return activation == CrOnc.ActivationState.NOT_ACTIVATED || |
| 387 activation == CrOnc.ActivationState.PARTIALLY_ACTIVATED; | 405 activation == CrOnc.ActivationState.PARTIALLY_ACTIVATED; |
| 388 }, | 406 }, |
| 389 | 407 |
| 390 /** | 408 /** |
| 391 * @param {!CrOnc.NetworkProperties} networkProperties | 409 * @param {!CrOnc.NetworkProperties} networkProperties |
| 410 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy |
| 392 * @return {boolean} | 411 * @return {boolean} |
| 393 * @private | 412 * @private |
| 394 */ | 413 */ |
| 395 showConfigure_: function(networkProperties) { | 414 showConfigure_: function(networkProperties, globalPolicy) { |
| 415 if (this.connectNotAllowed_(networkProperties, globalPolicy)) |
| 416 return false; |
| 396 var type = networkProperties.Type; | 417 var type = networkProperties.Type; |
| 397 if (type == CrOnc.Type.CELLULAR || type == CrOnc.Type.WI_MAX) | 418 if (type == CrOnc.Type.CELLULAR || type == CrOnc.Type.WI_MAX) |
| 398 return false; | 419 return false; |
| 399 if (type == CrOnc.Type.WI_FI && | 420 if (type == CrOnc.Type.WI_FI && |
| 400 networkProperties.ConnectionState != | 421 networkProperties.ConnectionState != |
| 401 CrOnc.ConnectionState.NOT_CONNECTED) { | 422 CrOnc.ConnectionState.NOT_CONNECTED) { |
| 402 return false; | 423 return false; |
| 403 } | 424 } |
| 404 return this.isRemembered_(networkProperties); | 425 return this.isRemembered_(networkProperties); |
| 405 }, | 426 }, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 if (!networkProperties.Cellular.MDN) | 458 if (!networkProperties.Cellular.MDN) |
| 438 return false; | 459 return false; |
| 439 } | 460 } |
| 440 | 461 |
| 441 return true; | 462 return true; |
| 442 }, | 463 }, |
| 443 | 464 |
| 444 /** | 465 /** |
| 445 * @param {!CrOnc.NetworkProperties} networkProperties | 466 * @param {!CrOnc.NetworkProperties} networkProperties |
| 446 * @param {?CrOnc.NetworkStateProperties} defaultNetwork | 467 * @param {?CrOnc.NetworkStateProperties} defaultNetwork |
| 468 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy |
| 447 * @return {boolean} Whether or not to enable the network connect button. | 469 * @return {boolean} Whether or not to enable the network connect button. |
| 448 * @private | 470 * @private |
| 449 */ | 471 */ |
| 450 enableConnect_: function(networkProperties, defaultNetwork) { | 472 enableConnect_: function(networkProperties, defaultNetwork, globalPolicy) { |
| 451 if (!this.showConnect_(networkProperties)) | 473 if (!this.showConnect_(networkProperties, globalPolicy)) |
| 452 return false; | 474 return false; |
| 453 if (networkProperties.Type == CrOnc.Type.CELLULAR && | 475 if (networkProperties.Type == CrOnc.Type.CELLULAR && |
| 454 CrOnc.isSimLocked(networkProperties)) { | 476 CrOnc.isSimLocked(networkProperties)) { |
| 455 return false; | 477 return false; |
| 456 } | 478 } |
| 457 if (networkProperties.Type == CrOnc.Type.VPN && !defaultNetwork) | 479 if (networkProperties.Type == CrOnc.Type.VPN && !defaultNetwork) |
| 458 return false; | 480 return false; |
| 459 return true; | 481 return true; |
| 460 }, | 482 }, |
| 461 | 483 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 * @param {!CrOnc.NetworkProperties} networkProperties | 653 * @param {!CrOnc.NetworkProperties} networkProperties |
| 632 * @return {boolean} True if the AutoConnect checkbox should be shown. | 654 * @return {boolean} True if the AutoConnect checkbox should be shown. |
| 633 * @private | 655 * @private |
| 634 */ | 656 */ |
| 635 showAutoConnect_: function(networkProperties) { | 657 showAutoConnect_: function(networkProperties) { |
| 636 return this.networkProperties.Type != CrOnc.Type.ETHERNET && | 658 return this.networkProperties.Type != CrOnc.Type.ETHERNET && |
| 637 this.isRemembered_(networkProperties); | 659 this.isRemembered_(networkProperties); |
| 638 }, | 660 }, |
| 639 | 661 |
| 640 /** | 662 /** |
| 663 * @param {!CrOnc.NetworkProperties} networkProperties |
| 664 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy |
| 665 * @return {boolean} |
| 666 * @private |
| 667 */ |
| 668 enableAutoConnect_: function(networkProperties, globalPolicy) { |
| 669 if (networkProperties.Type == CrOnc.Type.WI_FI && |
| 670 !!globalPolicy.AllowOnlyPolicyNetworksToAutoconnect && |
| 671 !this.isPolicySource(networkProperties.Source)) { |
| 672 return false; |
| 673 } |
| 674 return !this.isNetworkPolicyEnforced( |
| 675 this.getManagedAutoConnect_(networkProperties)); |
| 676 }, |
| 677 |
| 678 /** |
| 679 * @param {!CrOnc.NetworkProperties} networkProperties |
| 641 * @return {!CrOnc.ManagedProperty|undefined} Managed AutoConnect property. | 680 * @return {!CrOnc.ManagedProperty|undefined} Managed AutoConnect property. |
| 642 * @private | 681 * @private |
| 643 */ | 682 */ |
| 644 getManagedAutoConnect_: function() { | 683 getManagedAutoConnect_: function(networkProperties) { |
| 645 return CrOnc.getManagedAutoConnect(this.networkProperties); | 684 return CrOnc.getManagedAutoConnect(networkProperties); |
| 646 }, | 685 }, |
| 647 | 686 |
| 648 /** | 687 /** |
| 649 * @param {!CrOnc.NetworkProperties} networkProperties | 688 * @param {!CrOnc.NetworkProperties} networkProperties |
| 650 * @return {boolean} True if the prefer network checkbox should be shown. | 689 * @return {boolean} True if the prefer network checkbox should be shown. |
| 651 * @private | 690 * @private |
| 652 */ | 691 */ |
| 653 showPreferNetwork_: function(networkProperties) { | 692 showPreferNetwork_: function(networkProperties) { |
| 654 // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for | 693 // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for |
| 655 // networkProperties.Type == CrOnc.Type.ETHERNET. | 694 // networkProperties.Type == CrOnc.Type.ETHERNET. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 */ | 867 */ |
| 829 allPropertiesMatch_: function(curValue, newValue) { | 868 allPropertiesMatch_: function(curValue, newValue) { |
| 830 for (let key in newValue) { | 869 for (let key in newValue) { |
| 831 if (newValue[key] != curValue[key]) | 870 if (newValue[key] != curValue[key]) |
| 832 return false; | 871 return false; |
| 833 } | 872 } |
| 834 return true; | 873 return true; |
| 835 } | 874 } |
| 836 }); | 875 }); |
| 837 })(); | 876 })(); |
| OLD | NEW |