Chromium Code Reviews| Index: chrome/browser/resources/options/chromeos/internet_detail.js |
| diff --git a/chrome/browser/resources/options/chromeos/internet_detail.js b/chrome/browser/resources/options/chromeos/internet_detail.js |
| index 3fdc203184e4a3b658f36f364c861fb8ad9f6a08..6587b816480fdf3fffccf5bb042154f71fe635dd 100644 |
| --- a/chrome/browser/resources/options/chromeos/internet_detail.js |
| +++ b/chrome/browser/resources/options/chromeos/internet_detail.js |
| @@ -88,22 +88,6 @@ cr.define('options.internet', function() { |
| } |
| /** |
| - * Sends the 'checked' state of a control to chrome for a network. |
| - * @param {string} path The service path of the network. |
| - * @param {string} message The message to send to chrome. |
| - * @param {string} checkboxId The id of the checkbox with the value to send. |
| - * @param {string=} opt_action Optional action to record. |
| - */ |
| - function sendCheckedIfEnabled(path, message, checkboxId, opt_action) { |
| - var checkbox = assertInstanceof($(checkboxId), HTMLInputElement); |
| - if (!checkbox.hidden && !checkbox.disabled) { |
| - chrome.send(message, [path, !!checkbox.checked]); |
| - if (opt_action) |
| - sendChromeMetricsAction(opt_action); |
| - } |
| - } |
| - |
| - /** |
| * Send metrics to Chrome when the detailed page is opened. |
| * @param {string} type The ONC type of the network being shown. |
| * @param {string} state The ONC network state. |
| @@ -1086,32 +1070,35 @@ cr.define('options.internet', function() { |
| var detailsPage = DetailsInternetPage.getInstance(); |
| var type = detailsPage.type_; |
| var servicePath = detailsPage.servicePath_; |
| + var oncData = new OncData({}); |
| + var autoConnectCheckboxId = ''; |
| if (type == 'WiFi') { |
| - sendCheckedIfEnabled(servicePath, |
| - 'setPreferNetwork', |
| - 'prefer-network-wifi', |
| - 'Options_NetworkSetPrefer'); |
| - sendCheckedIfEnabled(servicePath, |
| - 'setAutoConnect', |
| - 'auto-connect-network-wifi', |
| - 'Options_NetworkAutoConnect'); |
| + var preferredCheckbox = |
| + assertInstanceof($('prefer-network-wifi'), HTMLInputElement); |
| + if (!preferredCheckbox.hidden && !preferredCheckbox.disabled) { |
| + var kPreferredPriority = 1; |
| + var priority = preferredCheckbox.checked ? kPreferredPriority : 0; |
| + oncData.setManagedProperty('Priority', priority); |
|
pneubeck (no reviews)
2014/11/18 13:21:38
this shouldn't create a managed dictionary.
SetPro
stevenjb
2014/11/18 23:12:06
Yes, that is poorly named, it explicitly only sets
|
| + sendChromeMetricsAction('Options_NetworkSetPrefer'); |
| + } |
| + autoConnectCheckboxId = 'auto-connect-network-wifi'; |
| } else if (type == 'WiMAX') { |
| - sendCheckedIfEnabled(servicePath, |
| - 'setAutoConnect', |
| - 'auto-connect-network-wimax', |
| - 'Options_NetworkAutoConnect'); |
| + autoConnectCheckboxId = 'auto-connect-network-wimax'; |
| } else if (type == 'Cellular') { |
| - sendCheckedIfEnabled(servicePath, |
| - 'setAutoConnect', |
| - 'auto-connect-network-cellular', |
| - 'Options_NetworkAutoConnect'); |
| + autoConnectCheckboxId = 'auto-connect-network-cellular'; |
| } else if (type == 'VPN') { |
| - chrome.send('setServerHostname', |
| - [servicePath, $('inet-server-hostname').value]); |
| - sendCheckedIfEnabled(servicePath, |
| - 'setAutoConnect', |
| - 'auto-connect-network-vpn', |
| - 'Options_NetworkAutoConnect'); |
| + oncData.setManagedProperty('VPN.Host', $('inet-server-hostname').value); |
| + autoConnectCheckboxId = 'auto-connect-network-vpn'; |
| + } |
| + if (autoConnectCheckboxId != '') { |
| + var autoConnectCheckbox = |
| + assertInstanceof($(autoConnectCheckboxId), HTMLInputElement); |
| + if (!autoConnectCheckbox.hidden && !autoConnectCheckbox.disabled) { |
| + var autoConnectKey = type + '.AutoConnect'; |
| + oncData.setManagedProperty(autoConnectKey, |
| + !!autoConnectCheckbox.checked); |
| + sendChromeMetricsAction('Options_NetworkAutoConnect'); |
| + } |
| } |
| var nameServerTypes = ['automatic', 'google', 'user']; |
| @@ -1124,6 +1111,12 @@ cr.define('options.internet', function() { |
| } |
| detailsPage.sendIpConfig_(nameServerType); |
| + var data = oncData.getData(); |
| + if (Object.keys(data).length > 0) { |
| + // TODO(stevenjb): chrome.networkingPrivate.setProperties |
| + chrome.send('setProperties', [servicePath, data]); |
| + } |
| + |
| PageManager.closeOverlay(); |
| }; |