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

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

Issue 552113002: Add ONC 'Source' configuration property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_279351_internet_options_9a
Patch Set: Rebase Created 6 years, 3 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 | chrome/browser/resources/options/chromeos/onc_data.js » ('j') | 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 // require: onc_data.js 5 // require: onc_data.js
6 6
7 // NOTE(stevenjb): This code is in the process of being converted to be 7 // NOTE(stevenjb): This code is in the process of being converted to be
8 // compatible with the networkingPrivate extension API: 8 // compatible with the networkingPrivate extension API:
9 // * The network property dictionaries are being converted to use ONC values. 9 // * The network property dictionaries are being converted to use ONC values.
10 // * chrome.send calls will be replaced with an API object that simulates the 10 // * chrome.send calls will be replaced with an API object that simulates the
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 event.value.controlledBy = 'policy'; 372 event.value.controlledBy = 'policy';
373 } 373 }
374 374
375 return event; 375 return event;
376 }, 376 },
377 377
378 /** 378 /**
379 * Update details page controls. 379 * Update details page controls.
380 */ 380 */
381 updateControls: function() { 381 updateControls: function() {
382 var onc = this.onc_;
383 if (onc == undefined)
384 return; // May get called from a pref update before initialized.
385
382 // Only show ipconfig section if network is connected OR if nothing on 386 // Only show ipconfig section if network is connected OR if nothing on
383 // this device is connected. This is so that you can fix the ip configs 387 // this device is connected. This is so that you can fix the ip configs
384 // if you can't connect to any network. 388 // if you can't connect to any network.
385 // TODO(chocobo): Once ipconfig is moved to flimflam service objects, 389 // TODO(chocobo): Once ipconfig is moved to flimflam service objects,
386 // we need to redo this logic to allow configuration of all networks. 390 // we need to redo this logic to allow configuration of all networks.
387 $('ipconfig-section').hidden = !this.connected && this.deviceConnected; 391 var connected = onc.getActiveValue('ConnectionState') == 'Connected';
388 $('ipconfig-dns-section').hidden = 392 $('ipconfig-section').hidden = !connected && this.deviceConnected;
389 !this.connected && this.deviceConnected; 393 $('ipconfig-dns-section').hidden = !connected && this.deviceConnected;
390 394
391 // Network type related. 395 // Network type related.
392 updateHidden('#details-internet-page .cellular-details', 396 updateHidden('#details-internet-page .cellular-details',
393 this.type_ != 'Cellular'); 397 this.type_ != 'Cellular');
394 updateHidden('#details-internet-page .wifi-details', 398 updateHidden('#details-internet-page .wifi-details',
395 this.type_ != 'WiFi'); 399 this.type_ != 'WiFi');
396 updateHidden('#details-internet-page .wimax-details', 400 updateHidden('#details-internet-page .wimax-details',
397 this.type_ != 'Wimax'); 401 this.type_ != 'Wimax');
398 updateHidden('#details-internet-page .vpn-details', this.type_ != 'VPN'); 402 updateHidden('#details-internet-page .vpn-details', this.type_ != 'VPN');
399 updateHidden('#details-internet-page .proxy-details', !this.showProxy); 403 updateHidden('#details-internet-page .proxy-details', !this.showProxy);
400 404
401 // Cellular 405 // Cellular
402 406
403 // Conditionally call updateHidden on .gsm-only, so that we don't unhide 407 // Conditionally call updateHidden on .gsm-only, so that we don't unhide
404 // a previously hidden element. 408 // a previously hidden element.
405 if (this.gsm) 409 if (this.gsm)
406 updateHidden('#details-internet-page .cdma-only', true); 410 updateHidden('#details-internet-page .cdma-only', true);
407 else 411 else
408 updateHidden('#details-internet-page .gsm-only', true); 412 updateHidden('#details-internet-page .gsm-only', true);
409 413
410 // Wifi 414 // Wifi
411 415
412 // Hide network tab for VPN. 416 // Hide network tab for VPN.
413 updateHidden('#details-internet-page .network-details', 417 updateHidden('#details-internet-page .network-details',
414 this.type_ == 'VPN'); 418 this.type_ == 'VPN');
415 419
416 // Password and shared. 420 // Password and shared.
421 var source = onc.getSource();
422 var shared = (source == 'Device' || source == 'DevicePolicy');
417 updateHidden('#details-internet-page #password-details', 423 updateHidden('#details-internet-page #password-details',
418 this.type_ != 'WiFi' || !this.hasSecurity); 424 this.type_ != 'WiFi' || onc.getWiFiSecurity() == 'None');
419 updateHidden('#details-internet-page #wifi-shared-network', 425 updateHidden('#details-internet-page #wifi-shared-network', !shared);
420 !this.shared); 426 updateHidden('#details-internet-page #prefer-network', source == 'None');
421 updateHidden('#details-internet-page #prefer-network',
422 !this.showPreferred);
423 427
424 // WiMAX. 428 // WiMAX.
425 updateHidden('#details-internet-page #wimax-shared-network', 429 updateHidden('#details-internet-page #wimax-shared-network', !shared);
426 !this.shared);
427 430
428 // Proxy 431 // Proxy
429 this.updateProxyBannerVisibility_(); 432 this.updateProxyBannerVisibility_();
430 this.toggleSingleProxy_(); 433 this.toggleSingleProxy_();
431 if ($('manual-proxy').checked) 434 if ($('manual-proxy').checked)
432 this.enableManualProxy_(); 435 this.enableManualProxy_();
433 else 436 else
434 this.disableManualProxy_(); 437 this.disableManualProxy_();
435 }, 438 },
436 439
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // Connect button. 574 // Connect button.
572 $('details-internet-login').disabled = false; 575 $('details-internet-login').disabled = false;
573 $('details-internet-disconnect').hidden = true; 576 $('details-internet-disconnect').hidden = true;
574 } else { 577 } else {
575 $('details-internet-login').hidden = true; 578 $('details-internet-login').hidden = true;
576 $('details-internet-disconnect').hidden = false; 579 $('details-internet-disconnect').hidden = false;
577 } 580 }
578 581
579 var connectable = onc.getActiveValue('Connectable'); 582 var connectable = onc.getActiveValue('Connectable');
580 if (connectState != 'Connected' && 583 if (connectState != 'Connected' &&
581 (!connectable || this.hasSecurity || 584 (!connectable || onc.getWiFiSecurity() != 'None' ||
582 (this.type_ == 'Wimax' || this.type_ == 'VPN'))) { 585 (this.type_ == 'Wimax' || this.type_ == 'VPN'))) {
583 $('details-internet-configure').hidden = false; 586 $('details-internet-configure').hidden = false;
584 } else { 587 } else {
585 $('details-internet-configure').hidden = true; 588 $('details-internet-configure').hidden = true;
586 } 589 }
587 }, 590 },
588 591
589 populateHeader_: function() { 592 populateHeader_: function() {
590 var onc = this.onc_; 593 var onc = this.onc_;
591 594
592 $('network-details-title').textContent = onc.getTranslatedValue('Name'); 595 $('network-details-title').textContent = onc.getTranslatedValue('Name');
593 var connectionState = onc.getActiveValue('ConnectionState'); 596 var connectionState = onc.getActiveValue('ConnectionState');
594 var connectionStateString = onc.getTranslatedValue('ConnectionState'); 597 var connectionStateString = onc.getTranslatedValue('ConnectionState');
595 this.connected = connectionState == 'Connected';
596 $('network-details-subtitle-status').textContent = connectionStateString; 598 $('network-details-subtitle-status').textContent = connectionStateString;
597 var typeKey; 599 var typeKey;
598 var type = this.type_; 600 var type = this.type_;
599 if (type == 'Ethernet') 601 if (type == 'Ethernet')
600 typeKey = 'ethernetTitle'; 602 typeKey = 'ethernetTitle';
601 else if (type == 'WiFi') 603 else if (type == 'WiFi')
602 typeKey = 'wifiTitle'; 604 typeKey = 'wifiTitle';
603 else if (type == 'Wimax') 605 else if (type == 'Wimax')
604 typeKey = 'wimaxTitle'; 606 typeKey = 'wimaxTitle';
605 else if (type == 'Cellular') 607 else if (type == 'Cellular')
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 // Update our cached data object. 1019 // Update our cached data object.
1018 var onc = detailsPage.onc_; 1020 var onc = detailsPage.onc_;
1019 onc.updateData(update); 1021 onc.updateData(update);
1020 1022
1021 detailsPage.populateHeader_(); 1023 detailsPage.populateHeader_();
1022 1024
1023 var connectionState = onc.getActiveValue('ConnectionState'); 1025 var connectionState = onc.getActiveValue('ConnectionState');
1024 var connectionStateString = onc.getTranslatedValue('ConnectionState'); 1026 var connectionStateString = onc.getTranslatedValue('ConnectionState');
1025 if ('deviceConnected' in update) 1027 if ('deviceConnected' in update)
1026 detailsPage.deviceConnected = update.deviceConnected; 1028 detailsPage.deviceConnected = update.deviceConnected;
1027 detailsPage.connected = connectionState == 'Connected';
1028 $('connection-state').textContent = connectionStateString; 1029 $('connection-state').textContent = connectionStateString;
1029 1030
1030 detailsPage.updateConnectionButtonVisibilty_(); 1031 detailsPage.updateConnectionButtonVisibilty_();
1031 1032
1032 var type = detailsPage.type_; 1033 var type = detailsPage.type_;
1033 if (type == 'WiFi') { 1034 if (type == 'WiFi') {
1034 $('wifi-connection-state').textContent = connectionStateString; 1035 $('wifi-connection-state').textContent = connectionStateString;
1035 } else if (type == 'Wimax') { 1036 } else if (type == 'Wimax') {
1036 $('wimax-connection-state').textContent = connectionStateString; 1037 $('wimax-connection-state').textContent = connectionStateString;
1037 } else if (type == 'Cellular') { 1038 } else if (type == 'Cellular') {
(...skipping 26 matching lines...) Expand all
1064 detailsPage.populateHeader_(); 1065 detailsPage.populateHeader_();
1065 1066
1066 $('activate-details').hidden = true; 1067 $('activate-details').hidden = true;
1067 $('view-account-details').hidden = true; 1068 $('view-account-details').hidden = true;
1068 1069
1069 detailsPage.updateConnectionButtonVisibilty_(); 1070 detailsPage.updateConnectionButtonVisibilty_();
1070 1071
1071 $('web-proxy-auto-discovery').hidden = true; 1072 $('web-proxy-auto-discovery').hidden = true;
1072 1073
1073 detailsPage.deviceConnected = data.deviceConnected; 1074 detailsPage.deviceConnected = data.deviceConnected;
1074 detailsPage.connected =
1075 onc.getActiveValue('ConnectionState') == 'Connected';
1076 1075
1077 // Only show proxy for remembered networks. 1076 // Only show proxy for remembered networks.
1078 if (data.remembered) { 1077 var remembered = onc.getSource() != 'None';
1078 if (remembered) {
1079 detailsPage.showProxy = true; 1079 detailsPage.showProxy = true;
1080 chrome.send('selectNetwork', [detailsPage.servicePath_]); 1080 chrome.send('selectNetwork', [detailsPage.servicePath_]);
1081 } else { 1081 } else {
1082 detailsPage.showProxy = false; 1082 detailsPage.showProxy = false;
1083 } 1083 }
1084 1084
1085 var connectionStateString = onc.getTranslatedValue('ConnectionState'); 1085 var connectionStateString = onc.getTranslatedValue('ConnectionState');
1086 $('connection-state').textContent = connectionStateString; 1086 $('connection-state').textContent = connectionStateString;
1087 var restricted = onc.getActiveValue('RestrictedConnectivity'); 1087 var restricted = onc.getActiveValue('RestrictedConnectivity');
1088 var restrictedString = loadTimeData.getString( 1088 var restrictedString = loadTimeData.getString(
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 var macAddress = onc.getActiveValue('MacAddress'); 1224 var macAddress = onc.getActiveValue('MacAddress');
1225 if (macAddress) { 1225 if (macAddress) {
1226 $('hardware-address').textContent = macAddress; 1226 $('hardware-address').textContent = macAddress;
1227 $('hardware-address-row').style.display = 'table-row'; 1227 $('hardware-address-row').style.display = 'table-row';
1228 } else { 1228 } else {
1229 // This is most likely a device without a hardware address. 1229 // This is most likely a device without a hardware address.
1230 $('hardware-address-row').style.display = 'none'; 1230 $('hardware-address-row').style.display = 'none';
1231 } 1231 }
1232 1232
1233 var setOrHideParent = function(field, property) { 1233 var setOrHideParent = function(field, property) {
1234 if (property) { 1234 if (property != undefined) {
1235 $(field).textContent = property; 1235 $(field).textContent = property;
1236 $(field).parentElement.hidden = false; 1236 $(field).parentElement.hidden = false;
1237 } else { 1237 } else {
1238 $(field).parentElement.hidden = true; 1238 $(field).parentElement.hidden = true;
1239 } 1239 }
1240 }; 1240 };
1241 1241
1242 var networkName = onc.getTranslatedValue('Name'); 1242 var networkName = onc.getTranslatedValue('Name');
1243 1243
1244 // Signal strength as percentage (for WiFi and Wimax). 1244 // Signal strength as percentage (for WiFi and Wimax).
1245 var signalStrength; 1245 var signalStrength;
1246 if (type == 'WiFi' || type == 'Wimax') 1246 if (type == 'WiFi' || type == 'Wimax')
1247 signalStrength = onc.getActiveValue(type + '.SignalStrength'); 1247 signalStrength = onc.getActiveValue(type + '.SignalStrength');
1248 if (!signalStrength) 1248 if (!signalStrength)
1249 signalStrength = 0; 1249 signalStrength = 0;
1250 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); 1250 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat');
1251 var strengthString = strengthFormat.replace('$1', signalStrength); 1251 var strengthString = strengthFormat.replace('$1', signalStrength);
1252 1252
1253 if (type == 'WiFi') { 1253 if (type == 'WiFi') {
1254 OptionsPage.showTab($('wifi-network-nav-tab')); 1254 OptionsPage.showTab($('wifi-network-nav-tab'));
1255 detailsPage.gsm = false; 1255 detailsPage.gsm = false;
1256 detailsPage.shared = data.shared;
1257 $('wifi-connection-state').textContent = connectionStateString; 1256 $('wifi-connection-state').textContent = connectionStateString;
1258 $('wifi-restricted-connectivity').textContent = restrictedString; 1257 $('wifi-restricted-connectivity').textContent = restrictedString;
1259 var ssid = onc.getActiveValue('WiFi.SSID'); 1258 var ssid = onc.getActiveValue('WiFi.SSID');
1260 $('wifi-ssid').textContent = ssid ? ssid : networkName; 1259 $('wifi-ssid').textContent = ssid ? ssid : networkName;
1261 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID')); 1260 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID'));
1262 var security = onc.getActiveValue('WiFi.Security'); 1261 var security = onc.getWiFiSecurity();
1263 if (security == 'None') 1262 if (security == 'None')
1264 security = undefined; 1263 security = undefined;
1265 setOrHideParent('wifi-security', security); 1264 setOrHideParent('wifi-security', security);
1266 // Frequency is in MHz. 1265 // Frequency is in MHz.
1267 var frequency = onc.getActiveValue('WiFi.Frequency'); 1266 var frequency = onc.getActiveValue('WiFi.Frequency');
1268 if (!frequency) 1267 if (!frequency)
1269 frequency = 0; 1268 frequency = 0;
1270 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); 1269 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat');
1271 frequencyFormat = frequencyFormat.replace('$1', frequency); 1270 frequencyFormat = frequencyFormat.replace('$1', frequency);
1272 $('wifi-frequency').textContent = frequencyFormat; 1271 $('wifi-frequency').textContent = frequencyFormat;
1273 $('wifi-signal-strength').textContent = strengthString; 1272 $('wifi-signal-strength').textContent = strengthString;
1274 setOrHideParent('wifi-hardware-address', 1273 setOrHideParent('wifi-hardware-address',
1275 onc.getActiveValue('MacAddress')); 1274 onc.getActiveValue('MacAddress'));
1276 detailsPage.showPreferred = data.remembered;
1277 var priority = onc.getActiveValue('Priority'); 1275 var priority = onc.getActiveValue('Priority');
1278 $('prefer-network-wifi').checked = priority > 0; 1276 $('prefer-network-wifi').checked = priority > 0;
1279 $('prefer-network-wifi').disabled = !data.remembered; 1277 $('prefer-network-wifi').disabled = !remembered;
1280 $('auto-connect-network-wifi').checked = 1278 $('auto-connect-network-wifi').checked =
1281 onc.getActiveValue('AutoConnect'); 1279 onc.getActiveValue('AutoConnect');
1282 $('auto-connect-network-wifi').disabled = !data.remembered; 1280 $('auto-connect-network-wifi').disabled = !remembered;
1283 detailsPage.hasSecurity = security != undefined;
1284 } else if (type == 'Wimax') { 1281 } else if (type == 'Wimax') {
1285 OptionsPage.showTab($('wimax-network-nav-tab')); 1282 OptionsPage.showTab($('wimax-network-nav-tab'));
1286 detailsPage.gsm = false; 1283 detailsPage.gsm = false;
1287 detailsPage.shared = data.shared;
1288 detailsPage.showPreferred = data.remembered;
1289 $('wimax-connection-state').textContent = connectionStateString; 1284 $('wimax-connection-state').textContent = connectionStateString;
1290 $('wimax-restricted-connectivity').textContent = restrictedString; 1285 $('wimax-restricted-connectivity').textContent = restrictedString;
1291 $('auto-connect-network-wimax').checked = 1286 $('auto-connect-network-wimax').checked =
1292 onc.getActiveValue('AutoConnect'); 1287 onc.getActiveValue('AutoConnect');
1293 $('auto-connect-network-wimax').disabled = !data.remembered; 1288 $('auto-connect-network-wimax').disabled = !remembered;
1294 var identity = onc.getActiveValue('Wimax.EAP.Identity'); 1289 var identity = onc.getActiveValue('Wimax.EAP.Identity');
1295 setOrHideParent('wimax-eap-identity', identity); 1290 setOrHideParent('wimax-eap-identity', identity);
1296 $('wimax-signal-strength').textContent = strengthString; 1291 $('wimax-signal-strength').textContent = strengthString;
1297 } else if (type == 'Cellular') { 1292 } else if (type == 'Cellular') {
1298 OptionsPage.showTab($('cellular-conn-nav-tab')); 1293 OptionsPage.showTab($('cellular-conn-nav-tab'));
1299 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { 1294 if (data.showCarrierSelect && data.currentCarrierIndex != -1) {
1300 var carrierSelector = $('select-carrier'); 1295 var carrierSelector = $('select-carrier');
1301 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; 1296 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged;
1302 carrierSelector.options.length = 0; 1297 carrierSelector.options.length = 0;
1303 for (var i = 0; i < data.carriers.length; ++i) { 1298 for (var i = 0; i < data.carriers.length; ++i) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 1424
1430 // Don't show page name in address bar and in history to prevent people 1425 // Don't show page name in address bar and in history to prevent people
1431 // navigate here by hand and solve issue with page session restore. 1426 // navigate here by hand and solve issue with page session restore.
1432 PageManager.showPageByName('detailsInternetPage', false); 1427 PageManager.showPageByName('detailsInternetPage', false);
1433 }; 1428 };
1434 1429
1435 return { 1430 return {
1436 DetailsInternetPage: DetailsInternetPage 1431 DetailsInternetPage: DetailsInternetPage
1437 }; 1432 };
1438 }); 1433 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options/chromeos/onc_data.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698