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

Side by Side Diff: chrome/browser/resources/options/chromeos/network_list.js

Issue 662063005: Fix VPN dropdown menu in Settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * @typedef {{ 6 * @typedef {{
7 * ConnectionState: string, 7 * ConnectionState: string,
8 * iconURL: string, 8 * iconURL: string,
9 * policyManaged: boolean, 9 * policyManaged: boolean,
10 * servicePath: string 10 * servicePath: string
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 var self = this; 504 var self = this;
505 entry.command = function() { 505 entry.command = function() {
506 options.Preferences.setBooleanPref( 506 options.Preferences.setBooleanPref(
507 'cros.signed.data_roaming_enabled', 507 'cros.signed.data_roaming_enabled',
508 !enableDataRoaming_, true); 508 !enableDataRoaming_, true);
509 // Force revalidation of the menu the next time it is displayed. 509 // Force revalidation of the menu the next time it is displayed.
510 self.menu_ = null; 510 self.menu_ = null;
511 }; 511 };
512 } 512 }
513 addendum.push(entry); 513 addendum.push(entry);
514 } else if (this.data_.key == 'VPN') {
515 addendum.push({
516 label: loadTimeData.getString('joinOtherNetwork'),
517 command: createAddConnectionCallback_('VPN'),
518 data: {}
519 });
514 } 520 }
521
515 var list = this.data.rememberedNetworks; 522 var list = this.data.rememberedNetworks;
516 if (list && list.length > 0) { 523 if (list && list.length > 0) {
517 var callback = function(list) { 524 var callback = function(list) {
518 $('remembered-network-list').clear(); 525 $('remembered-network-list').clear();
519 var dialog = options.PreferredNetworks.getInstance(); 526 var dialog = options.PreferredNetworks.getInstance();
520 PageManager.showPageByName('preferredNetworksPage', false); 527 PageManager.showPageByName('preferredNetworksPage', false);
521 dialog.update(list); 528 dialog.update(list);
522 sendChromeMetricsAction('Options_NetworkShowPreferred'); 529 sendChromeMetricsAction('Options_NetworkShowPreferred');
523 }; 530 };
524 addendum.push({label: loadTimeData.getString('preferredNetworks'), 531 addendum.push({label: loadTimeData.getString('preferredNetworks'),
525 command: callback, 532 command: callback,
526 data: list}); 533 data: list});
527 } 534 }
528 535
529 var networkGroup = this.ownerDocument.createElement('div'); 536 var networkGroup = this.ownerDocument.createElement('div');
530 networkGroup.className = 'network-menu-group'; 537 networkGroup.className = 'network-menu-group';
531 list = this.data.networkList; 538 list = this.data.networkList;
532 var empty = !list || list.length == 0; 539 var empty = !list || list.length == 0;
533 if (list) { 540 if (list) {
541 var connectedVpnServicePath = '';
534 for (var i = 0; i < list.length; i++) { 542 for (var i = 0; i < list.length; i++) {
535 var data = list[i]; 543 var data = list[i];
536 this.createNetworkOptionsCallback_(networkGroup, data); 544 this.createNetworkOptionsCallback_(networkGroup, data);
537 if (data.ConnectionState == 'Connected') { 545 // For VPN only we want to append a 'Disconnect' item to the dropdown
538 if (data.Type == 'VPN') { 546 // since there should only ever be one connected or connecting VPN.
tbarzic 2014/10/22 17:06:57 nit: Maybe it would be better to say that it shoul
stevenjb 2014/10/22 17:31:33 Actually, I guess that's true for any network type
539 var disconnectCallback = function() { 547 if (!connectedVpnServicePath &&
540 sendChromeMetricsAction('Options_NetworkDisconnectVPN'); 548 (data.Type == 'VPN') &&
tbarzic 2014/10/22 17:06:57 nit: I'd drop () here
stevenjb 2014/10/22 17:31:33 Done.
541 // TODO(stevenjb): chrome.networkingPrivate.startDisconnect 549 (data.ConnectionState == 'Connected' ||
542 chrome.send('startDisconnect', [data.servicePath]); 550 data.ConnectionState == 'Connecting')) {
543 }; 551 connectedVpnServicePath = data.servicePath;
544 // Add separator
545 addendum.push({});
546 addendum.push({label: loadTimeData.getString('disconnectNetwork'),
547 command: disconnectCallback,
548 data: data});
549 }
550 } 552 }
551 } 553 }
554 if (connectedVpnServicePath) {
555 var disconnectCallback = function() {
556 sendChromeMetricsAction('Options_NetworkDisconnectVPN');
557 // TODO(stevenjb): chrome.networkingPrivate.startDisconnect
558 chrome.send('startDisconnect', [connectedVpnServicePath]);
559 };
560 // Add separator
561 addendum.push({});
562 addendum.push({label: loadTimeData.getString('disconnectNetwork'),
563 command: disconnectCallback,
564 data: data});
565 }
552 } 566 }
553 if (this.data_.key == 'WiFi' || this.data_.key == 'WiMAX' || 567 if (this.data_.key == 'WiFi' || this.data_.key == 'WiMAX' ||
554 this.data_.key == 'Cellular') { 568 this.data_.key == 'Cellular') {
555 addendum.push({}); 569 addendum.push({});
556 if (this.data_.key == 'WiFi') { 570 if (this.data_.key == 'WiFi') {
557 addendum.push({ 571 addendum.push({
558 label: loadTimeData.getString('turnOffWifi'), 572 label: loadTimeData.getString('turnOffWifi'),
559 command: function() { 573 command: function() {
560 sendChromeMetricsAction('Options_NetworkWifiToggle'); 574 sendChromeMetricsAction('Options_NetworkWifiToggle');
561 // TODO(stevenjb): chrome.networkingPrivate.disableNetworkType 575 // TODO(stevenjb): chrome.networkingPrivate.disableNetworkType
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 /** 1243 /**
1230 * Whether the Network list is disabled. Only used for display purpose. 1244 * Whether the Network list is disabled. Only used for display purpose.
1231 */ 1245 */
1232 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); 1246 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR);
1233 1247
1234 // Export 1248 // Export
1235 return { 1249 return {
1236 NetworkList: NetworkList 1250 NetworkList: NetworkList
1237 }; 1251 };
1238 }); 1252 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698