| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Partial definition of the result of networkingPrivate.getProperties()). | 6 * Partial definition of the result of networkingPrivate.getProperties()). |
| 7 * TODO(stevenjb): Replace with chrome.networkingPrivate.NetworkStateProperties | 7 * TODO(stevenjb): Replace with chrome.networkingPrivate.NetworkStateProperties |
| 8 * once that is fully speced. | 8 * once that is fully speced. |
| 9 * @typedef {{ | 9 * @typedef {{ |
| 10 * ConnectionState: string, | 10 * ConnectionState: string, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 * @param {string} type A string that may contain a valid network type. | 54 * @param {string} type A string that may contain a valid network type. |
| 55 * @return {boolean} Whether the string represents a valid network type. | 55 * @return {boolean} Whether the string represents a valid network type. |
| 56 */ | 56 */ |
| 57 function isNetworkType(type) { | 57 function isNetworkType(type) { |
| 58 return (Constants.NETWORK_TYPES.indexOf(type) != -1); | 58 return (Constants.NETWORK_TYPES.indexOf(type) != -1); |
| 59 } | 59 } |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Order in which controls are to appear in the network list sorted by key. | 62 * Order in which controls are to appear in the network list sorted by key. |
| 63 */ | 63 */ |
| 64 Constants.NETWORK_ORDER = ['Ethernet', | 64 Constants.NETWORK_ORDER = |
| 65 'WiFi', | 65 ['Ethernet', 'WiFi', 'WiMAX', 'Cellular', 'VPN', 'addConnection']; |
| 66 'WiMAX', | |
| 67 'Cellular', | |
| 68 'VPN', | |
| 69 'addConnection']; | |
| 70 | 66 |
| 71 /** | 67 /** |
| 72 * ID of the menu that is currently visible. | 68 * ID of the menu that is currently visible. |
| 73 * @type {?string} | 69 * @type {?string} |
| 74 * @private | 70 * @private |
| 75 */ | 71 */ |
| 76 var activeMenu = null; | 72 var activeMenu = null; |
| 77 | 73 |
| 78 /** | 74 /** |
| 79 * The state of the cellular device or undefined if not available. | 75 * The state of the cellular device or undefined if not available. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 */ | 158 */ |
| 163 function sendChromeMetricsAction(action) { | 159 function sendChromeMetricsAction(action) { |
| 164 chrome.send('coreOptionsUserMetricsAction', [action]); | 160 chrome.send('coreOptionsUserMetricsAction', [action]); |
| 165 } | 161 } |
| 166 | 162 |
| 167 /** | 163 /** |
| 168 * @param {string} guid The network GUID. | 164 * @param {string} guid The network GUID. |
| 169 */ | 165 */ |
| 170 function showDetails(guid) { | 166 function showDetails(guid) { |
| 171 chrome.networkingPrivate.getManagedProperties( | 167 chrome.networkingPrivate.getManagedProperties( |
| 172 guid, DetailsInternetPage.initializeDetailsPage); | 168 guid, DetailsInternetPage.initializeDetailsPage); |
| 173 } | 169 } |
| 174 | 170 |
| 175 /** | 171 /** |
| 176 * Decorate an element as a NetworkListItem. | 172 * Decorate an element as a NetworkListItem. |
| 177 * @param {!Element} el The element to decorate. | 173 * @param {!Element} el The element to decorate. |
| 178 */ | 174 */ |
| 179 NetworkListItem.decorate = function(el) { | 175 NetworkListItem.decorate = function(el) { |
| 180 el.__proto__ = NetworkListItem.prototype; | 176 el.__proto__ = NetworkListItem.prototype; |
| 181 el.decorate(); | 177 el.decorate(); |
| 182 }; | 178 }; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 * @private | 339 * @private |
| 344 */ | 340 */ |
| 345 menu_: null, | 341 menu_: null, |
| 346 | 342 |
| 347 /** @override */ | 343 /** @override */ |
| 348 decorate: function() { | 344 decorate: function() { |
| 349 this.subtitle = null; | 345 this.subtitle = null; |
| 350 if (this.data.iconType) | 346 if (this.data.iconType) |
| 351 this.iconType = this.data.iconType; | 347 this.iconType = this.data.iconType; |
| 352 this.addEventListener('click', (function() { | 348 this.addEventListener('click', (function() { |
| 353 this.showMenu(); | 349 this.showMenu(); |
| 354 }).bind(this)); | 350 }).bind(this)); |
| 355 }, | 351 }, |
| 356 | 352 |
| 357 /** | 353 /** |
| 358 * Retrieves the ID for the menu. | 354 * Retrieves the ID for the menu. |
| 359 */ | 355 */ |
| 360 getMenuName: function() { | 356 getMenuName: function() { |
| 361 return this.data_.key.toLowerCase() + '-network-menu'; | 357 return this.data_.key.toLowerCase() + '-network-menu'; |
| 362 }, | 358 }, |
| 363 | 359 |
| 364 /** | 360 /** |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 | 532 |
| 537 if (candidateData && isManaged(candidateData.Source)) | 533 if (candidateData && isManaged(candidateData.Source)) |
| 538 this.showManagedNetworkIndicator(); | 534 this.showManagedNetworkIndicator(); |
| 539 | 535 |
| 540 if (activeMenu == this.getMenuName()) { | 536 if (activeMenu == this.getMenuName()) { |
| 541 // Menu is already showing and needs to be updated. Explicitly calling | 537 // Menu is already showing and needs to be updated. Explicitly calling |
| 542 // show menu will force the existing menu to be replaced. The call | 538 // show menu will force the existing menu to be replaced. The call |
| 543 // is deferred in order to ensure that position of this element has | 539 // is deferred in order to ensure that position of this element has |
| 544 // beem properly updated. | 540 // beem properly updated. |
| 545 var self = this; | 541 var self = this; |
| 546 setTimeout(function() {self.showMenu();}, 0); | 542 setTimeout(function() { |
| 543 self.showMenu(); |
| 544 }, 0); |
| 547 } | 545 } |
| 548 }, | 546 }, |
| 549 | 547 |
| 550 /** | 548 /** |
| 551 * Creates a menu for selecting, configuring or disconnecting from a | 549 * Creates a menu for selecting, configuring or disconnecting from a |
| 552 * network. | 550 * network. |
| 553 * @return {!Element} The newly created menu. | 551 * @return {!Element} The newly created menu. |
| 554 */ | 552 */ |
| 555 createMenu: function() { | 553 createMenu: function() { |
| 556 var menu = this.ownerDocument.createElement('div'); | 554 var menu = this.ownerDocument.createElement('div'); |
| 557 menu.id = this.getMenuName(); | 555 menu.id = this.getMenuName(); |
| 558 menu.className = 'network-menu'; | 556 menu.className = 'network-menu'; |
| 559 menu.hidden = true; | 557 menu.hidden = true; |
| 560 Menu.decorate(menu); | 558 Menu.decorate(menu); |
| 561 menu.menuItemSelector = '.network-menu-item'; | 559 menu.menuItemSelector = '.network-menu-item'; |
| 562 var addendum = []; | 560 var addendum = []; |
| 563 if (this.data_.key == 'WiFi') { | 561 if (this.data_.key == 'WiFi') { |
| 564 var item = { | 562 var item = { |
| 565 label: loadTimeData.getString('joinOtherNetwork'), | 563 label: loadTimeData.getString('joinOtherNetwork'), |
| 566 data: {} | 564 data: {} |
| 567 }; | 565 }; |
| 568 if (allowUnmanagedNetworks_()) { | 566 if (allowUnmanagedNetworks_()) { |
| 569 item.command = createAddNonVPNConnectionCallback_('WiFi'); | 567 item.command = createAddNonVPNConnectionCallback_('WiFi'); |
| 570 } else { | 568 } else { |
| 571 item.command = null; | 569 item.command = null; |
| 572 item.tooltip = loadTimeData.getString('prohibitedNetworkOther'); | 570 item.tooltip = loadTimeData.getString('prohibitedNetworkOther'); |
| 573 } | 571 } |
| 574 addendum.push(item); | 572 addendum.push(item); |
| 575 } else if (this.data_.key == 'Cellular') { | 573 } else if (this.data_.key == 'Cellular') { |
| 576 if (cellularDevice.State == 'Enabled' && | 574 if (cellularDevice.State == 'Enabled' && cellularNetwork && |
| 577 cellularNetwork && cellularNetwork.Cellular && | 575 cellularNetwork.Cellular && |
| 578 cellularNetwork.Cellular.SupportNetworkScan) { | 576 cellularNetwork.Cellular.SupportNetworkScan) { |
| 579 addendum.push({ | 577 addendum.push({ |
| 580 label: loadTimeData.getString('otherCellularNetworks'), | 578 label: loadTimeData.getString('otherCellularNetworks'), |
| 581 command: createAddNonVPNConnectionCallback_('Cellular'), | 579 command: createAddNonVPNConnectionCallback_('Cellular'), |
| 582 addClass: ['other-cellulars'], | 580 addClass: ['other-cellulars'], |
| 583 data: {} | 581 data: {} |
| 584 }); | 582 }); |
| 585 } | 583 } |
| 586 | 584 |
| 587 var label = enableDataRoaming ? 'disableDataRoaming' : | 585 var label = |
| 588 'enableDataRoaming'; | 586 enableDataRoaming ? 'disableDataRoaming' : 'enableDataRoaming'; |
| 589 var disabled = !loadTimeData.getValue('loggedInAsOwner'); | 587 var disabled = !loadTimeData.getValue('loggedInAsOwner'); |
| 590 var entry = {label: loadTimeData.getString(label), | 588 var entry = {label: loadTimeData.getString(label), data: {}}; |
| 591 data: {}}; | |
| 592 if (disabled) { | 589 if (disabled) { |
| 593 entry.command = null; | 590 entry.command = null; |
| 594 entry.tooltip = | 591 entry.tooltip = |
| 595 loadTimeData.getString('dataRoamingDisableToggleTooltip'); | 592 loadTimeData.getString('dataRoamingDisableToggleTooltip'); |
| 596 } else { | 593 } else { |
| 597 var self = this; | 594 var self = this; |
| 598 entry.command = function() { | 595 entry.command = function() { |
| 599 options.Preferences.setBooleanPref( | 596 options.Preferences.setBooleanPref( |
| 600 'cros.signed.data_roaming_enabled', | 597 'cros.signed.data_roaming_enabled', !enableDataRoaming, true); |
| 601 !enableDataRoaming, true); | |
| 602 // Force revalidation of the menu the next time it is displayed. | 598 // Force revalidation of the menu the next time it is displayed. |
| 603 self.menu_ = null; | 599 self.menu_ = null; |
| 604 }; | 600 }; |
| 605 } | 601 } |
| 606 addendum.push(entry); | 602 addendum.push(entry); |
| 607 } else if (this.data_.key == 'VPN') { | 603 } else if (this.data_.key == 'VPN') { |
| 608 addendum = addendum.concat(createAddVPNConnectionEntries_()); | 604 addendum = addendum.concat(createAddVPNConnectionEntries_()); |
| 609 } | 605 } |
| 610 | 606 |
| 611 var list = this.data.rememberedNetworks; | 607 var list = this.data.rememberedNetworks; |
| 612 if (list && list.length > 0) { | 608 if (list && list.length > 0) { |
| 613 var callback = function(list) { | 609 var callback = function(list) { |
| 614 $('remembered-network-list').clear(); | 610 $('remembered-network-list').clear(); |
| 615 var dialog = options.PreferredNetworks.getInstance(); | 611 var dialog = options.PreferredNetworks.getInstance(); |
| 616 PageManager.showPageByName('preferredNetworksPage', false); | 612 PageManager.showPageByName('preferredNetworksPage', false); |
| 617 dialog.update(list); | 613 dialog.update(list); |
| 618 sendChromeMetricsAction('Options_NetworkShowPreferred'); | 614 sendChromeMetricsAction('Options_NetworkShowPreferred'); |
| 619 }; | 615 }; |
| 620 addendum.push({label: loadTimeData.getString('preferredNetworks'), | 616 addendum.push({ |
| 621 command: callback, | 617 label: loadTimeData.getString('preferredNetworks'), |
| 622 data: list}); | 618 command: callback, |
| 619 data: list |
| 620 }); |
| 623 } | 621 } |
| 624 | 622 |
| 625 var networkGroup = this.ownerDocument.createElement('div'); | 623 var networkGroup = this.ownerDocument.createElement('div'); |
| 626 networkGroup.className = 'network-menu-group'; | 624 networkGroup.className = 'network-menu-group'; |
| 627 list = this.data.networkList; | 625 list = this.data.networkList; |
| 628 var empty = !list || list.length == 0; | 626 var empty = !list || list.length == 0; |
| 629 if (list) { | 627 if (list) { |
| 630 var connectedVpnGuid = ''; | 628 var connectedVpnGuid = ''; |
| 631 for (var i = 0; i < list.length; i++) { | 629 for (var i = 0; i < list.length; i++) { |
| 632 var data = list[i]; | 630 var data = list[i]; |
| 633 this.createNetworkOptionsCallback_(networkGroup, data); | 631 this.createNetworkOptionsCallback_(networkGroup, data); |
| 634 // For VPN only, append a 'Disconnect' item to the dropdown menu. | 632 // For VPN only, append a 'Disconnect' item to the dropdown menu. |
| 635 if (!connectedVpnGuid && data.Type == 'VPN' && | 633 if (!connectedVpnGuid && data.Type == 'VPN' && |
| 636 (data.ConnectionState == 'Connected' || | 634 (data.ConnectionState == 'Connected' || |
| 637 data.ConnectionState == 'Connecting')) { | 635 data.ConnectionState == 'Connecting')) { |
| 638 connectedVpnGuid = data.GUID; | 636 connectedVpnGuid = data.GUID; |
| 639 } | 637 } |
| 640 } | 638 } |
| 641 if (connectedVpnGuid) { | 639 if (connectedVpnGuid) { |
| 642 var disconnectCallback = function() { | 640 var disconnectCallback = function() { |
| 643 sendChromeMetricsAction('Options_NetworkDisconnectVPN'); | 641 sendChromeMetricsAction('Options_NetworkDisconnectVPN'); |
| 644 chrome.networkingPrivate.startDisconnect(connectedVpnGuid); | 642 chrome.networkingPrivate.startDisconnect(connectedVpnGuid); |
| 645 }; | 643 }; |
| 646 // Add separator | 644 // Add separator |
| 647 addendum.push({}); | 645 addendum.push({}); |
| 648 addendum.push({label: loadTimeData.getString('disconnectNetwork'), | 646 addendum.push({ |
| 649 command: disconnectCallback, | 647 label: loadTimeData.getString('disconnectNetwork'), |
| 650 data: data}); | 648 command: disconnectCallback, |
| 649 data: data |
| 650 }); |
| 651 } | 651 } |
| 652 } | 652 } |
| 653 if (this.data_.key == 'WiFi' || this.data_.key == 'WiMAX' || | 653 if (this.data_.key == 'WiFi' || this.data_.key == 'WiMAX' || |
| 654 this.data_.key == 'Cellular') { | 654 this.data_.key == 'Cellular') { |
| 655 addendum.push({}); | 655 addendum.push({}); |
| 656 if (this.data_.key == 'WiFi') { | 656 if (this.data_.key == 'WiFi') { |
| 657 addendum.push({ | 657 addendum.push({ |
| 658 label: loadTimeData.getString('turnOffWifi'), | 658 label: loadTimeData.getString('turnOffWifi'), |
| 659 command: function() { | 659 command: function() { |
| 660 sendChromeMetricsAction('Options_NetworkWifiToggle'); | 660 sendChromeMetricsAction('Options_NetworkWifiToggle'); |
| 661 chrome.networkingPrivate.disableNetworkType( | 661 chrome.networkingPrivate.disableNetworkType( |
| 662 chrome.networkingPrivate.NetworkType.WI_FI); | 662 chrome.networkingPrivate.NetworkType.WI_FI); |
| 663 }, | 663 }, |
| 664 data: {}}); | 664 data: {} |
| 665 }); |
| 665 } else if (this.data_.key == 'WiMAX') { | 666 } else if (this.data_.key == 'WiMAX') { |
| 666 addendum.push({ | 667 addendum.push({ |
| 667 label: loadTimeData.getString('turnOffWimax'), | 668 label: loadTimeData.getString('turnOffWimax'), |
| 668 command: function() { | 669 command: function() { |
| 669 chrome.networkingPrivate.disableNetworkType( | 670 chrome.networkingPrivate.disableNetworkType( |
| 670 chrome.networkingPrivate.NetworkType.WI_MAX); | 671 chrome.networkingPrivate.NetworkType.WI_MAX); |
| 671 }, | 672 }, |
| 672 data: {}}); | 673 data: {} |
| 674 }); |
| 673 } else if (this.data_.key == 'Cellular') { | 675 } else if (this.data_.key == 'Cellular') { |
| 674 addendum.push({ | 676 addendum.push({ |
| 675 label: loadTimeData.getString('turnOffCellular'), | 677 label: loadTimeData.getString('turnOffCellular'), |
| 676 command: function() { | 678 command: function() { |
| 677 chrome.networkingPrivate.disableNetworkType( | 679 chrome.networkingPrivate.disableNetworkType( |
| 678 chrome.networkingPrivate.NetworkType.CELLULAR); | 680 chrome.networkingPrivate.NetworkType.CELLULAR); |
| 679 }, | 681 }, |
| 680 data: {}}); | 682 data: {} |
| 683 }); |
| 681 } | 684 } |
| 682 } | 685 } |
| 683 if (!empty) | 686 if (!empty) |
| 684 menu.appendChild(networkGroup); | 687 menu.appendChild(networkGroup); |
| 685 if (addendum.length > 0) { | 688 if (addendum.length > 0) { |
| 686 var separator = false; | 689 var separator = false; |
| 687 if (!empty) { | 690 if (!empty) { |
| 688 menu.appendChild(MenuItem.createSeparator()); | 691 menu.appendChild(MenuItem.createSeparator()); |
| 689 separator = true; | 692 separator = true; |
| 690 } | 693 } |
| 691 for (var i = 0; i < addendum.length; i++) { | 694 for (var i = 0; i < addendum.length; i++) { |
| 692 var value = addendum[i]; | 695 var value = addendum[i]; |
| 693 if (value.data) { | 696 if (value.data) { |
| 694 var item = createCallback_(menu, value.data, value.label, | 697 var item = |
| 695 value.command); | 698 createCallback_(menu, value.data, value.label, value.command); |
| 696 if (value.tooltip) | 699 if (value.tooltip) |
| 697 item.title = value.tooltip; | 700 item.title = value.tooltip; |
| 698 if (value.addClass) | 701 if (value.addClass) |
| 699 item.classList.add(value.addClass); | 702 item.classList.add(value.addClass); |
| 700 separator = false; | 703 separator = false; |
| 701 } else if (!separator) { | 704 } else if (!separator) { |
| 702 menu.appendChild(MenuItem.createSeparator()); | 705 menu.appendChild(MenuItem.createSeparator()); |
| 703 separator = true; | 706 separator = true; |
| 704 } | 707 } |
| 705 } | 708 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 726 var oldMenu = $(this.getMenuName()); | 729 var oldMenu = $(this.getMenuName()); |
| 727 var group = oldMenu.getElementsByClassName('network-menu-group')[0]; | 730 var group = oldMenu.getElementsByClassName('network-menu-group')[0]; |
| 728 if (!group) | 731 if (!group) |
| 729 return false; | 732 return false; |
| 730 var newMenu = this.createMenu(); | 733 var newMenu = this.createMenu(); |
| 731 var discardOnClose = false; | 734 var discardOnClose = false; |
| 732 var oldNetworkButtons = this.extractNetworkConnectButtons_(oldMenu); | 735 var oldNetworkButtons = this.extractNetworkConnectButtons_(oldMenu); |
| 733 var newNetworkButtons = this.extractNetworkConnectButtons_(newMenu); | 736 var newNetworkButtons = this.extractNetworkConnectButtons_(newMenu); |
| 734 for (var key in oldNetworkButtons) { | 737 for (var key in oldNetworkButtons) { |
| 735 if (newNetworkButtons[key]) { | 738 if (newNetworkButtons[key]) { |
| 736 group.replaceChild(newNetworkButtons[key].button, | 739 group.replaceChild( |
| 737 oldNetworkButtons[key].button); | 740 newNetworkButtons[key].button, oldNetworkButtons[key].button); |
| 738 if (newNetworkButtons[key].index != oldNetworkButtons[key].index) | 741 if (newNetworkButtons[key].index != oldNetworkButtons[key].index) |
| 739 discardOnClose = true; | 742 discardOnClose = true; |
| 740 newNetworkButtons[key] = null; | 743 newNetworkButtons[key] = null; |
| 741 } else { | 744 } else { |
| 742 // Leave item in list to prevent network items from jumping due to | 745 // Leave item in list to prevent network items from jumping due to |
| 743 // deletions. | 746 // deletions. |
| 744 oldNetworkButtons[key].disabled = true; | 747 oldNetworkButtons[key].disabled = true; |
| 745 discardOnClose = true; | 748 discardOnClose = true; |
| 746 } | 749 } |
| 747 } | 750 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 /** | 782 /** |
| 780 * Adds a menu item for showing network details. | 783 * Adds a menu item for showing network details. |
| 781 * @param {!Element} parent The parent element. | 784 * @param {!Element} parent The parent element. |
| 782 * @param {NetworkProperties} data Description of the network. | 785 * @param {NetworkProperties} data Description of the network. |
| 783 * @private | 786 * @private |
| 784 */ | 787 */ |
| 785 createNetworkOptionsCallback_: function(parent, data) { | 788 createNetworkOptionsCallback_: function(parent, data) { |
| 786 var menuItem = null; | 789 var menuItem = null; |
| 787 if (data.Type == 'WiFi' && !allowUnmanagedNetworks_() && | 790 if (data.Type == 'WiFi' && !allowUnmanagedNetworks_() && |
| 788 !isManaged(data.Source)) { | 791 !isManaged(data.Source)) { |
| 789 menuItem = createCallback_(parent, | 792 menuItem = createCallback_(parent, data, getNetworkName(data), null); |
| 790 data, | |
| 791 getNetworkName(data), | |
| 792 null); | |
| 793 menuItem.title = loadTimeData.getString('prohibitedNetwork'); | 793 menuItem.title = loadTimeData.getString('prohibitedNetwork'); |
| 794 } else { | 794 } else { |
| 795 menuItem = createCallback_(parent, | 795 menuItem = createCallback_( |
| 796 data, | 796 parent, data, getNetworkName(data), |
| 797 getNetworkName(data), | 797 showDetails.bind(null, data.GUID)); |
| 798 showDetails.bind(null, data.GUID)); | |
| 799 } | 798 } |
| 800 if (isManaged(data.Source)) | 799 if (isManaged(data.Source)) |
| 801 menuItem.appendChild(new ManagedNetworkIndicator()); | 800 menuItem.appendChild(new ManagedNetworkIndicator()); |
| 802 if (data.ConnectionState == 'Connected' || | 801 if (data.ConnectionState == 'Connected' || |
| 803 data.ConnectionState == 'Connecting') { | 802 data.ConnectionState == 'Connecting') { |
| 804 var label = menuItem.getElementsByClassName( | 803 var label = |
| 805 'network-menu-item-label')[0]; | 804 menuItem.getElementsByClassName('network-menu-item-label')[0]; |
| 806 label.classList.add('active-network'); | 805 label.classList.add('active-network'); |
| 807 } | 806 } |
| 808 } | 807 } |
| 809 }; | 808 }; |
| 810 | 809 |
| 811 /** | 810 /** |
| 812 * Creates a button-like control for configurating internet connectivity. | 811 * Creates a button-like control for configurating internet connectivity. |
| 813 * @param {{key: string, subtitle: string, command: Function}} data | 812 * @param {{key: string, subtitle: string, command: Function}} data |
| 814 * Description of the network control. | 813 * Description of the network control. |
| 815 * @constructor | 814 * @constructor |
| 816 * @extends {NetworkListItem} | 815 * @extends {NetworkListItem} |
| 817 */ | 816 */ |
| 818 function NetworkButtonItem(data) { | 817 function NetworkButtonItem(data) { |
| 819 var el = new NetworkListItem(data); | 818 var el = new NetworkListItem(data); |
| 820 el.__proto__ = NetworkButtonItem.prototype; | 819 el.__proto__ = NetworkButtonItem.prototype; |
| 821 el.decorate(); | 820 el.decorate(); |
| 822 return el; | 821 return el; |
| 823 } | 822 } |
| 824 | 823 |
| 825 NetworkButtonItem.prototype = { | 824 NetworkButtonItem.prototype = { |
| 826 __proto__: NetworkListItem.prototype, | 825 __proto__: NetworkListItem.prototype, |
| 827 | 826 |
| 828 /** @override */ | 827 /** @override */ |
| 829 decorate: function() { | 828 decorate: function() { |
| 830 if (this.data.subtitle) | 829 if (this.data.subtitle) |
| 831 this.subtitle = this.data.subtitle; | 830 this.subtitle = this.data.subtitle; |
| 832 else | 831 else |
| 833 this.subtitle = null; | 832 this.subtitle = null; |
| 834 if (this.data.command) | 833 if (this.data.command) |
| 835 this.addEventListener('click', this.data.command); | 834 this.addEventListener('click', this.data.command); |
| 836 if (this.data.iconData) | 835 if (this.data.iconData) |
| 837 this.iconData = this.data.iconData; | 836 this.iconData = this.data.iconData; |
| 838 else if (this.data.iconType) | 837 else if (this.data.iconType) |
| 839 this.iconType = this.data.iconType; | 838 this.iconType = this.data.iconType; |
| 840 if (isManaged(this.data.Source)) | 839 if (isManaged(this.data.Source)) |
| 841 this.showManagedNetworkIndicator(); | 840 this.showManagedNetworkIndicator(); |
| 842 }, | 841 }, |
| 843 }; | 842 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 868 } | 867 } |
| 869 | 868 |
| 870 var buttonLabel = menu.ownerDocument.createElement('span'); | 869 var buttonLabel = menu.ownerDocument.createElement('span'); |
| 871 buttonLabel.className = 'network-menu-item-label'; | 870 buttonLabel.className = 'network-menu-item-label'; |
| 872 buttonLabel.textContent = label; | 871 buttonLabel.textContent = label; |
| 873 button.appendChild(buttonLabel); | 872 button.appendChild(buttonLabel); |
| 874 var callback = null; | 873 var callback = null; |
| 875 if (command != null) { | 874 if (command != null) { |
| 876 if (data) { | 875 if (data) { |
| 877 callback = function() { | 876 callback = function() { |
| 878 (/** @type {Function} */(command))(data); | 877 (/** @type {Function} */ (command))(data); |
| 879 closeMenu_(); | 878 closeMenu_(); |
| 880 }; | 879 }; |
| 881 } else { | 880 } else { |
| 882 callback = function() { | 881 callback = function() { |
| 883 (/** @type {Function} */(command))(); | 882 (/** @type {Function} */ (command))(); |
| 884 closeMenu_(); | 883 closeMenu_(); |
| 885 }; | 884 }; |
| 886 } | 885 } |
| 887 } | 886 } |
| 888 if (callback != null) | 887 if (callback != null) |
| 889 button.addEventListener('activate', callback); | 888 button.addEventListener('activate', callback); |
| 890 else | 889 else |
| 891 buttonLabel.classList.add('network-disabled-control'); | 890 buttonLabel.classList.add('network-disabled-control'); |
| 892 | 891 |
| 893 button.data = {label: label}; | 892 button.data = {label: label}; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 907 __proto__: List.prototype, | 906 __proto__: List.prototype, |
| 908 | 907 |
| 909 /** @override */ | 908 /** @override */ |
| 910 decorate: function() { | 909 decorate: function() { |
| 911 List.prototype.decorate.call(this); | 910 List.prototype.decorate.call(this); |
| 912 this.startBatchUpdates(); | 911 this.startBatchUpdates(); |
| 913 this.autoExpands = true; | 912 this.autoExpands = true; |
| 914 this.dataModel = new ArrayDataModel([]); | 913 this.dataModel = new ArrayDataModel([]); |
| 915 this.selectionModel = new ListSingleSelectionModel(); | 914 this.selectionModel = new ListSingleSelectionModel(); |
| 916 this.addEventListener('blur', this.onBlur_.bind(this)); | 915 this.addEventListener('blur', this.onBlur_.bind(this)); |
| 917 this.selectionModel.addEventListener('change', | 916 this.selectionModel.addEventListener( |
| 918 this.onSelectionChange_.bind(this)); | 917 'change', this.onSelectionChange_.bind(this)); |
| 919 | 918 |
| 920 // Wi-Fi control is always visible. | 919 // Wi-Fi control is always visible. |
| 921 this.update({key: 'WiFi', networkList: []}); | 920 this.update({key: 'WiFi', networkList: []}); |
| 922 | 921 |
| 923 this.updateAddConnectionMenuEntries_(); | 922 this.updateAddConnectionMenuEntries_(); |
| 924 | 923 |
| 925 var prefs = options.Preferences.getInstance(); | 924 var prefs = options.Preferences.getInstance(); |
| 926 prefs.addEventListener('cros.signed.data_roaming_enabled', | 925 prefs.addEventListener( |
| 927 function(event) { | 926 'cros.signed.data_roaming_enabled', function(event) { |
| 928 enableDataRoaming = event.value.value; | 927 enableDataRoaming = event.value.value; |
| 929 }); | 928 }); |
| 930 this.endBatchUpdates(); | 929 this.endBatchUpdates(); |
| 931 | 930 |
| 932 this.onNetworkListChanged_(); // Trigger an initial network update | 931 this.onNetworkListChanged_(); // Trigger an initial network update |
| 933 | 932 |
| 934 chrome.networkingPrivate.onNetworkListChanged.addListener( | 933 chrome.networkingPrivate.onNetworkListChanged.addListener( |
| 935 this.onNetworkListChanged_.bind(this)); | 934 this.onNetworkListChanged_.bind(this)); |
| 936 chrome.networkingPrivate.onDeviceStateListChanged.addListener( | 935 chrome.networkingPrivate.onDeviceStateListChanged.addListener( |
| 937 this.onNetworkListChanged_.bind(this)); | 936 this.onNetworkListChanged_.bind(this)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 949 chrome.management.getAll(this.onGetAllExtensions_.bind(this)); | 948 chrome.management.getAll(this.onGetAllExtensions_.bind(this)); |
| 950 chrome.networkingPrivate.requestNetworkScan(); | 949 chrome.networkingPrivate.requestNetworkScan(); |
| 951 }, | 950 }, |
| 952 | 951 |
| 953 /** | 952 /** |
| 954 * networkingPrivate event called when the network list has changed. | 953 * networkingPrivate event called when the network list has changed. |
| 955 */ | 954 */ |
| 956 onNetworkListChanged_: function() { | 955 onNetworkListChanged_: function() { |
| 957 var networkList = this; | 956 var networkList = this; |
| 958 chrome.networkingPrivate.getDeviceStates(function(deviceStates) { | 957 chrome.networkingPrivate.getDeviceStates(function(deviceStates) { |
| 959 var filter = { | 958 var filter = {networkType: chrome.networkingPrivate.NetworkType.ALL}; |
| 960 networkType: chrome.networkingPrivate.NetworkType.ALL | |
| 961 }; | |
| 962 chrome.networkingPrivate.getNetworks(filter, function(networkStates) { | 959 chrome.networkingPrivate.getNetworks(filter, function(networkStates) { |
| 963 networkList.updateNetworkStates(deviceStates, networkStates); | 960 networkList.updateNetworkStates(deviceStates, networkStates); |
| 964 }); | 961 }); |
| 965 }); | 962 }); |
| 966 }, | 963 }, |
| 967 | 964 |
| 968 /** | 965 /** |
| 969 * chrome.management.getAll callback. | 966 * chrome.management.getAll callback. |
| 970 * @param {!Array<!ExtensionInfo>} extensions | 967 * @param {!Array<!ExtensionInfo>} extensions |
| 971 * @private | 968 * @private |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 * Updates the entries in the "add connection" menu, based on the VPN | 1044 * Updates the entries in the "add connection" menu, based on the VPN |
| 1048 * providers currently enabled in the user's profile. | 1045 * providers currently enabled in the user's profile. |
| 1049 * @private | 1046 * @private |
| 1050 */ | 1047 */ |
| 1051 updateAddConnectionMenuEntries_: function() { | 1048 updateAddConnectionMenuEntries_: function() { |
| 1052 var entries = [{ | 1049 var entries = [{ |
| 1053 label: loadTimeData.getString('addConnectionWifi'), | 1050 label: loadTimeData.getString('addConnectionWifi'), |
| 1054 command: createAddNonVPNConnectionCallback_('WiFi') | 1051 command: createAddNonVPNConnectionCallback_('WiFi') |
| 1055 }]; | 1052 }]; |
| 1056 entries = entries.concat(createAddVPNConnectionEntries_()); | 1053 entries = entries.concat(createAddVPNConnectionEntries_()); |
| 1057 this.update({key: 'addConnection', | 1054 this.update( |
| 1058 iconType: 'add-connection', | 1055 {key: 'addConnection', iconType: 'add-connection', menu: entries}); |
| 1059 menu: entries | |
| 1060 }); | |
| 1061 }, | 1056 }, |
| 1062 | 1057 |
| 1063 /** | 1058 /** |
| 1064 * When the list loses focus, unselect all items in the list and close the | 1059 * When the list loses focus, unselect all items in the list and close the |
| 1065 * active menu. | 1060 * active menu. |
| 1066 * @private | 1061 * @private |
| 1067 */ | 1062 */ |
| 1068 onBlur_: function() { | 1063 onBlur_: function() { |
| 1069 this.selectionModel.unselectAll(); | 1064 this.selectionModel.unselectAll(); |
| 1070 closeMenu_(); | 1065 closeMenu_(); |
| 1071 }, | 1066 }, |
| 1072 | 1067 |
| 1073 /** @override */ | 1068 /** @override */ |
| 1074 handleKeyDown: function(e) { | 1069 handleKeyDown: function(e) { |
| 1075 if (activeMenu) { | 1070 if (activeMenu) { |
| 1076 // keyIdentifier does not report 'Esc' correctly | 1071 // keyIdentifier does not report 'Esc' correctly |
| 1077 if (e.keyCode == 27 /* Esc */) { | 1072 if (e.keyCode == 27 /* Esc */) { |
| 1078 closeMenu_(); | 1073 closeMenu_(); |
| 1079 return; | 1074 return; |
| 1080 } | 1075 } |
| 1081 | 1076 |
| 1082 if ($(activeMenu).handleKeyDown(e)) { | 1077 if ($(activeMenu).handleKeyDown(e)) { |
| 1083 e.preventDefault(); | 1078 e.preventDefault(); |
| 1084 e.stopPropagation(); | 1079 e.stopPropagation(); |
| 1085 } | 1080 } |
| 1086 return; | 1081 return; |
| 1087 } | 1082 } |
| 1088 | 1083 |
| 1089 if (e.key == 'Enter' || | 1084 if (e.key == 'Enter' || e.key == ' ' /* Space */) { |
| 1090 e.key == ' ' /* Space */) { | 1085 var selectedListItem = |
| 1091 var selectedListItem = this.getListItemByIndex( | 1086 this.getListItemByIndex(this.selectionModel.selectedIndex); |
| 1092 this.selectionModel.selectedIndex); | |
| 1093 if (selectedListItem) { | 1087 if (selectedListItem) { |
| 1094 selectedListItem.click(); | 1088 selectedListItem.click(); |
| 1095 return; | 1089 return; |
| 1096 } | 1090 } |
| 1097 } | 1091 } |
| 1098 | 1092 |
| 1099 List.prototype.handleKeyDown.call(this, e); | 1093 List.prototype.handleKeyDown.call(this, e); |
| 1100 }, | 1094 }, |
| 1101 | 1095 |
| 1102 /** | 1096 /** |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 * @override | 1180 * @override |
| 1187 * @param {Object} entry | 1181 * @param {Object} entry |
| 1188 */ | 1182 */ |
| 1189 createItem: function(entry) { | 1183 createItem: function(entry) { |
| 1190 if (entry.networkList) | 1184 if (entry.networkList) |
| 1191 return new NetworkSelectorItem( | 1185 return new NetworkSelectorItem( |
| 1192 /** @type {{key: string, networkList: Array<!NetworkProperties>}} */ | 1186 /** @type {{key: string, networkList: Array<!NetworkProperties>}} */ |
| 1193 (entry)); | 1187 (entry)); |
| 1194 if (entry.command) | 1188 if (entry.command) |
| 1195 return new NetworkButtonItem( | 1189 return new NetworkButtonItem( |
| 1196 /** @type {{key: string, subtitle: string, command: Function}} */( | 1190 /** @type {{key: string, subtitle: string, command: Function}} */ ( |
| 1197 entry)); | 1191 entry)); |
| 1198 if (entry.menu) | 1192 if (entry.menu) |
| 1199 return new NetworkMenuItem(entry); | 1193 return new NetworkMenuItem(entry); |
| 1200 assertNotReached(); | 1194 assertNotReached(); |
| 1201 }, | 1195 }, |
| 1202 | 1196 |
| 1203 /** | 1197 /** |
| 1204 * Deletes an element from the list. | 1198 * Deletes an element from the list. |
| 1205 * @param {string} key Unique identifier for the element. | 1199 * @param {string} key Unique identifier for the element. |
| 1206 */ | 1200 */ |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 if (ethernetNetwork) { | 1276 if (ethernetNetwork) { |
| 1283 var ethernetOptions = showDetails.bind(null, ethernetNetwork.GUID); | 1277 var ethernetOptions = showDetails.bind(null, ethernetNetwork.GUID); |
| 1284 var state = ethernetNetwork.ConnectionState; | 1278 var state = ethernetNetwork.ConnectionState; |
| 1285 var subtitle; | 1279 var subtitle; |
| 1286 if (state == 'Connected') | 1280 if (state == 'Connected') |
| 1287 subtitle = loadTimeData.getString('OncConnectionStateConnected'); | 1281 subtitle = loadTimeData.getString('OncConnectionStateConnected'); |
| 1288 else if (state == 'Connecting') | 1282 else if (state == 'Connecting') |
| 1289 subtitle = loadTimeData.getString('OncConnectionStateConnecting'); | 1283 subtitle = loadTimeData.getString('OncConnectionStateConnecting'); |
| 1290 else | 1284 else |
| 1291 subtitle = loadTimeData.getString('OncConnectionStateNotConnected'); | 1285 subtitle = loadTimeData.getString('OncConnectionStateNotConnected'); |
| 1292 this.update( | 1286 this.update({ |
| 1293 { key: 'Ethernet', | 1287 key: 'Ethernet', |
| 1294 subtitle: subtitle, | 1288 subtitle: subtitle, |
| 1295 iconData: ethernetNetwork, | 1289 iconData: ethernetNetwork, |
| 1296 command: ethernetOptions, | 1290 command: ethernetOptions, |
| 1297 Source: ethernetNetwork.Source } | 1291 Source: ethernetNetwork.Source |
| 1298 ); | 1292 }); |
| 1299 } else { | 1293 } else { |
| 1300 this.deleteItem('Ethernet'); | 1294 this.deleteItem('Ethernet'); |
| 1301 } | 1295 } |
| 1302 | 1296 |
| 1303 if (wifiDeviceState == 'Enabled') | 1297 if (wifiDeviceState == 'Enabled') |
| 1304 loadData_('WiFi', networkStates); | 1298 loadData_('WiFi', networkStates); |
| 1305 else if (wifiDeviceState == | 1299 else if ( |
| 1300 wifiDeviceState == |
| 1306 chrome.networkingPrivate.DeviceStateType.PROHIBITED) | 1301 chrome.networkingPrivate.DeviceStateType.PROHIBITED) |
| 1307 setTechnologiesProhibited_(chrome.networkingPrivate.NetworkType.WI_FI); | 1302 setTechnologiesProhibited_(chrome.networkingPrivate.NetworkType.WI_FI); |
| 1308 else | 1303 else |
| 1309 addEnableNetworkButton_(chrome.networkingPrivate.NetworkType.WI_FI); | 1304 addEnableNetworkButton_(chrome.networkingPrivate.NetworkType.WI_FI); |
| 1310 | 1305 |
| 1311 // Only show cellular control if available. | 1306 // Only show cellular control if available. |
| 1312 if (cellularDevice) { | 1307 if (cellularDevice) { |
| 1313 if (cellularDevice.State == 'Enabled' && | 1308 if (cellularDevice.State == 'Enabled' && |
| 1314 !isCellularSimAbsent(cellularDevice) && | 1309 !isCellularSimAbsent(cellularDevice) && |
| 1315 !isCellularSimLocked(cellularDevice)) { | 1310 !isCellularSimLocked(cellularDevice)) { |
| 1316 loadData_('Cellular', networkStates); | 1311 loadData_('Cellular', networkStates); |
| 1317 } else if (cellularDevice.State == | 1312 } else if ( |
| 1313 cellularDevice.State == |
| 1318 chrome.networkingPrivate.DeviceStateType.PROHIBITED) { | 1314 chrome.networkingPrivate.DeviceStateType.PROHIBITED) { |
| 1319 setTechnologiesProhibited_( | 1315 setTechnologiesProhibited_( |
| 1320 chrome.networkingPrivate.NetworkType.CELLULAR); | 1316 chrome.networkingPrivate.NetworkType.CELLULAR); |
| 1321 } else { | 1317 } else { |
| 1322 addEnableNetworkButton_( | 1318 addEnableNetworkButton_( |
| 1323 chrome.networkingPrivate.NetworkType.CELLULAR); | 1319 chrome.networkingPrivate.NetworkType.CELLULAR); |
| 1324 } | 1320 } |
| 1325 } else { | 1321 } else { |
| 1326 this.deleteItem('Cellular'); | 1322 this.deleteItem('Cellular'); |
| 1327 } | 1323 } |
| 1328 | 1324 |
| 1329 // Only show wimax control if available. Uses cellular icons. | 1325 // Only show wimax control if available. Uses cellular icons. |
| 1330 if (wimaxDeviceState) { | 1326 if (wimaxDeviceState) { |
| 1331 if (wimaxDeviceState == 'Enabled') { | 1327 if (wimaxDeviceState == 'Enabled') { |
| 1332 loadData_('WiMAX', networkStates); | 1328 loadData_('WiMAX', networkStates); |
| 1333 } else if (wimaxDeviceState == | 1329 } else if ( |
| 1330 wimaxDeviceState == |
| 1334 chrome.networkingPrivate.DeviceStateType.PROHIBITED) { | 1331 chrome.networkingPrivate.DeviceStateType.PROHIBITED) { |
| 1335 setTechnologiesProhibited_( | 1332 setTechnologiesProhibited_( |
| 1336 chrome.networkingPrivate.NetworkType.WI_MAX); | 1333 chrome.networkingPrivate.NetworkType.WI_MAX); |
| 1337 } else { | 1334 } else { |
| 1338 addEnableNetworkButton_(chrome.networkingPrivate.NetworkType.WI_MAX); | 1335 addEnableNetworkButton_(chrome.networkingPrivate.NetworkType.WI_MAX); |
| 1339 } | 1336 } |
| 1340 } else { | 1337 } else { |
| 1341 this.deleteItem('WiMAX'); | 1338 this.deleteItem('WiMAX'); |
| 1342 } | 1339 } |
| 1343 | 1340 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1363 if (isCellularSimLocked(cellularDevice)) { | 1360 if (isCellularSimLocked(cellularDevice)) { |
| 1364 chrome.send('simOperation', ['unlock']); | 1361 chrome.send('simOperation', ['unlock']); |
| 1365 return; | 1362 return; |
| 1366 } else if (isCellularSimAbsent(cellularDevice)) { | 1363 } else if (isCellularSimAbsent(cellularDevice)) { |
| 1367 chrome.send('simOperation', ['configure']); | 1364 chrome.send('simOperation', ['configure']); |
| 1368 return; | 1365 return; |
| 1369 } | 1366 } |
| 1370 } | 1367 } |
| 1371 chrome.networkingPrivate.enableNetworkType(type); | 1368 chrome.networkingPrivate.enableNetworkType(type); |
| 1372 }; | 1369 }; |
| 1373 $('network-list').update({key: type, | 1370 $('network-list').update({ |
| 1374 subtitle: subtitle, | 1371 key: type, |
| 1375 iconType: type, | 1372 subtitle: subtitle, |
| 1376 command: enableNetwork}); | 1373 iconType: type, |
| 1374 command: enableNetwork |
| 1375 }); |
| 1377 } | 1376 } |
| 1378 | 1377 |
| 1379 /** | 1378 /** |
| 1380 * Replaces a network menu with a button with nothing to do. | 1379 * Replaces a network menu with a button with nothing to do. |
| 1381 * @param {!chrome.networkingPrivate.NetworkType} type | 1380 * @param {!chrome.networkingPrivate.NetworkType} type |
| 1382 * @private | 1381 * @private |
| 1383 */ | 1382 */ |
| 1384 function setTechnologiesProhibited_(type) { | 1383 function setTechnologiesProhibited_(type) { |
| 1385 var subtitle = loadTimeData.getString('networkProhibited'); | 1384 var subtitle = loadTimeData.getString('networkProhibited'); |
| 1386 var doNothingButRemoveClickShadow = function() { | 1385 var doNothingButRemoveClickShadow = function() { |
| 1387 this.removeAttribute('lead'); | 1386 this.removeAttribute('lead'); |
| 1388 this.removeAttribute('selected'); | 1387 this.removeAttribute('selected'); |
| 1389 this.parentNode.removeAttribute('has-element-focus'); | 1388 this.parentNode.removeAttribute('has-element-focus'); |
| 1390 }; | 1389 }; |
| 1391 $('network-list').update({key: type, | 1390 $('network-list').update({ |
| 1392 subtitle: subtitle, | 1391 key: type, |
| 1393 iconType: type, | 1392 subtitle: subtitle, |
| 1394 command: doNothingButRemoveClickShadow}); | 1393 iconType: type, |
| 1394 command: doNothingButRemoveClickShadow |
| 1395 }); |
| 1395 } | 1396 } |
| 1396 | 1397 |
| 1397 /** | 1398 /** |
| 1398 * Element for indicating a policy managed network. | 1399 * Element for indicating a policy managed network. |
| 1399 * @constructor | 1400 * @constructor |
| 1400 * @extends {options.ControlledSettingIndicator} | 1401 * @extends {options.ControlledSettingIndicator} |
| 1401 */ | 1402 */ |
| 1402 function ManagedNetworkIndicator() { | 1403 function ManagedNetworkIndicator() { |
| 1403 var el = cr.doc.createElement('span'); | 1404 var el = cr.doc.createElement('span'); |
| 1404 el.__proto__ = ManagedNetworkIndicator.prototype; | 1405 el.__proto__ = ManagedNetworkIndicator.prototype; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 * provider. If |opt_extensionID| is omitted, the dialog for the built-in | 1519 * provider. If |opt_extensionID| is omitted, the dialog for the built-in |
| 1519 * OpenVPN/L2TP provider is shown. Otherwise, |opt_extensionID| identifies the | 1520 * OpenVPN/L2TP provider is shown. Otherwise, |opt_extensionID| identifies the |
| 1520 * third-party provider for which the dialog should be shown. | 1521 * third-party provider for which the dialog should be shown. |
| 1521 * @param {string=} opt_extensionID Extension ID identifying the third-party | 1522 * @param {string=} opt_extensionID Extension ID identifying the third-party |
| 1522 * VPN provider for which the dialog should be shown. | 1523 * VPN provider for which the dialog should be shown. |
| 1523 * @return {function()} The created callback. | 1524 * @return {function()} The created callback. |
| 1524 * @private | 1525 * @private |
| 1525 */ | 1526 */ |
| 1526 function createVPNConnectionCallback_(opt_extensionID) { | 1527 function createVPNConnectionCallback_(opt_extensionID) { |
| 1527 return function() { | 1528 return function() { |
| 1528 sendChromeMetricsAction(opt_extensionID ? | 1529 sendChromeMetricsAction( |
| 1529 'Options_NetworkAddVPNThirdParty' : | 1530 opt_extensionID ? 'Options_NetworkAddVPNThirdParty' : |
| 1530 'Options_NetworkAddVPNBuiltIn'); | 1531 'Options_NetworkAddVPNBuiltIn'); |
| 1531 chrome.send('addVPNConnection', | 1532 chrome.send( |
| 1532 opt_extensionID ? [opt_extensionID] : undefined); | 1533 'addVPNConnection', opt_extensionID ? [opt_extensionID] : undefined); |
| 1533 }; | 1534 }; |
| 1534 } | 1535 } |
| 1535 | 1536 |
| 1536 /** | 1537 /** |
| 1537 * Generates an "add network" entry for each VPN provider currently enabled in | 1538 * Generates an "add network" entry for each VPN provider currently enabled in |
| 1538 * the user's profile. | 1539 * the user's profile. |
| 1539 * @return {!Array<{label: string, command: function(), data: !Object}>} The | 1540 * @return {!Array<{label: string, command: function(), data: !Object}>} The |
| 1540 * list of entries. | 1541 * list of entries. |
| 1541 * @private | 1542 * @private |
| 1542 */ | 1543 */ |
| 1543 function createAddVPNConnectionEntries_() { | 1544 function createAddVPNConnectionEntries_() { |
| 1544 var entries = []; | 1545 var entries = []; |
| 1545 for (var i = 0; i < vpnProviders.length; ++i) { | 1546 for (var i = 0; i < vpnProviders.length; ++i) { |
| 1546 var provider = vpnProviders[i]; | 1547 var provider = vpnProviders[i]; |
| 1547 entries.push({ | 1548 entries.push({ |
| 1548 label: loadTimeData.getStringF('addConnectionVPNTemplate', | 1549 label: loadTimeData.getStringF( |
| 1549 provider.ProviderName), | 1550 'addConnectionVPNTemplate', provider.ProviderName), |
| 1550 command: createVPNConnectionCallback_(provider.ExtensionID), | 1551 command: createVPNConnectionCallback_(provider.ExtensionID), |
| 1551 data: {} | 1552 data: {} |
| 1552 }); | 1553 }); |
| 1553 } | 1554 } |
| 1554 // Add an entry for the built-in OpenVPN/L2TP provider. | 1555 // Add an entry for the built-in OpenVPN/L2TP provider. |
| 1555 entries.push({ | 1556 entries.push({ |
| 1556 label: loadTimeData.getString('vpnBuiltInProvider'), | 1557 label: loadTimeData.getString('vpnBuiltInProvider'), |
| 1557 command: createVPNConnectionCallback_(), | 1558 command: createVPNConnectionCallback_(), |
| 1558 data: {} | 1559 data: {} |
| 1559 }); | 1560 }); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1571 } | 1572 } |
| 1572 return true; | 1573 return true; |
| 1573 } | 1574 } |
| 1574 | 1575 |
| 1575 /** | 1576 /** |
| 1576 * Whether the Network list is disabled. Only used for display purpose. | 1577 * Whether the Network list is disabled. Only used for display purpose. |
| 1577 */ | 1578 */ |
| 1578 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); | 1579 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); |
| 1579 | 1580 |
| 1580 // Export | 1581 // Export |
| 1581 return { | 1582 return {NetworkList: NetworkList}; |
| 1582 NetworkList: NetworkList | |
| 1583 }; | |
| 1584 }); | 1583 }); |
| OLD | NEW |