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 ed08b6c458f5f8689b7a31d38fa213f669ab3e7d..9c680056d4cf9a522f3489076848a7014deb6d8c 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. |
@@ -1083,32 +1067,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); |
+ 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']; |
@@ -1121,6 +1108,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(); |
}; |