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

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

Issue 694533007: Add 'setProperties' to InternetOptionsHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 6 years, 1 month 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
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 /** 83 /**
84 * @param {string} action An action to send to coreOptionsUserMetricsAction. 84 * @param {string} action An action to send to coreOptionsUserMetricsAction.
85 */ 85 */
86 function sendChromeMetricsAction(action) { 86 function sendChromeMetricsAction(action) {
87 chrome.send('coreOptionsUserMetricsAction', [action]); 87 chrome.send('coreOptionsUserMetricsAction', [action]);
88 } 88 }
89 89
90 /** 90 /**
91 * Sends the 'checked' state of a control to chrome for a network.
92 * @param {string} path The service path of the network.
93 * @param {string} message The message to send to chrome.
94 * @param {string} checkboxId The id of the checkbox with the value to send.
95 * @param {string=} opt_action Optional action to record.
96 */
97 function sendCheckedIfEnabled(path, message, checkboxId, opt_action) {
98 var checkbox = assertInstanceof($(checkboxId), HTMLInputElement);
99 if (!checkbox.hidden && !checkbox.disabled) {
100 chrome.send(message, [path, !!checkbox.checked]);
101 if (opt_action)
102 sendChromeMetricsAction(opt_action);
103 }
104 }
105
106 /**
107 * Send metrics to Chrome when the detailed page is opened. 91 * Send metrics to Chrome when the detailed page is opened.
108 * @param {string} type The ONC type of the network being shown. 92 * @param {string} type The ONC type of the network being shown.
109 * @param {string} state The ONC network state. 93 * @param {string} state The ONC network state.
110 */ 94 */
111 function sendShowDetailsMetrics(type, state) { 95 function sendShowDetailsMetrics(type, state) {
112 if (type == 'WiFi') { 96 if (type == 'WiFi') {
113 sendChromeMetricsAction('Options_NetworkShowDetailsWifi'); 97 sendChromeMetricsAction('Options_NetworkShowDetailsWifi');
114 if (state != 'NotConnected') 98 if (state != 'NotConnected')
115 sendChromeMetricsAction('Options_NetworkShowDetailsWifiConnected'); 99 sendChromeMetricsAction('Options_NetworkShowDetailsWifiConnected');
116 } else if (type == 'Cellular') { 100 } else if (type == 'Cellular') {
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 }; 1063 };
1080 1064
1081 /** 1065 /**
1082 * Event handler called when the details page is closed. Sends changed 1066 * Event handler called when the details page is closed. Sends changed
1083 * properties to Chrome and closes the overlay. 1067 * properties to Chrome and closes the overlay.
1084 */ 1068 */
1085 DetailsInternetPage.setDetails = function() { 1069 DetailsInternetPage.setDetails = function() {
1086 var detailsPage = DetailsInternetPage.getInstance(); 1070 var detailsPage = DetailsInternetPage.getInstance();
1087 var type = detailsPage.type_; 1071 var type = detailsPage.type_;
1088 var servicePath = detailsPage.servicePath_; 1072 var servicePath = detailsPage.servicePath_;
1073 var oncData = new OncData({});
1074 var autoConnectCheckboxId = '';
1089 if (type == 'WiFi') { 1075 if (type == 'WiFi') {
1090 sendCheckedIfEnabled(servicePath, 1076 var preferredCheckbox =
1091 'setPreferNetwork', 1077 assertInstanceof($('prefer-network-wifi'), HTMLInputElement);
1092 'prefer-network-wifi', 1078 if (!preferredCheckbox.hidden && !preferredCheckbox.disabled) {
1093 'Options_NetworkSetPrefer'); 1079 var kPreferredPriority = 1;
1094 sendCheckedIfEnabled(servicePath, 1080 var priority = preferredCheckbox.checked ? kPreferredPriority : 0;
1095 'setAutoConnect', 1081 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
1096 'auto-connect-network-wifi', 1082 sendChromeMetricsAction('Options_NetworkSetPrefer');
1097 'Options_NetworkAutoConnect'); 1083 }
1084 autoConnectCheckboxId = 'auto-connect-network-wifi';
1098 } else if (type == 'WiMAX') { 1085 } else if (type == 'WiMAX') {
1099 sendCheckedIfEnabled(servicePath, 1086 autoConnectCheckboxId = 'auto-connect-network-wimax';
1100 'setAutoConnect',
1101 'auto-connect-network-wimax',
1102 'Options_NetworkAutoConnect');
1103 } else if (type == 'Cellular') { 1087 } else if (type == 'Cellular') {
1104 sendCheckedIfEnabled(servicePath, 1088 autoConnectCheckboxId = 'auto-connect-network-cellular';
1105 'setAutoConnect',
1106 'auto-connect-network-cellular',
1107 'Options_NetworkAutoConnect');
1108 } else if (type == 'VPN') { 1089 } else if (type == 'VPN') {
1109 chrome.send('setServerHostname', 1090 oncData.setManagedProperty('VPN.Host', $('inet-server-hostname').value);
1110 [servicePath, $('inet-server-hostname').value]); 1091 autoConnectCheckboxId = 'auto-connect-network-vpn';
1111 sendCheckedIfEnabled(servicePath, 1092 }
1112 'setAutoConnect', 1093 if (autoConnectCheckboxId != '') {
1113 'auto-connect-network-vpn', 1094 var autoConnectCheckbox =
1114 'Options_NetworkAutoConnect'); 1095 assertInstanceof($(autoConnectCheckboxId), HTMLInputElement);
1096 if (!autoConnectCheckbox.hidden && !autoConnectCheckbox.disabled) {
1097 var autoConnectKey = type + '.AutoConnect';
1098 oncData.setManagedProperty(autoConnectKey,
1099 !!autoConnectCheckbox.checked);
1100 sendChromeMetricsAction('Options_NetworkAutoConnect');
1101 }
1115 } 1102 }
1116 1103
1117 var nameServerTypes = ['automatic', 'google', 'user']; 1104 var nameServerTypes = ['automatic', 'google', 'user'];
1118 var nameServerType = 'automatic'; 1105 var nameServerType = 'automatic';
1119 for (var i = 0; i < nameServerTypes.length; ++i) { 1106 for (var i = 0; i < nameServerTypes.length; ++i) {
1120 if ($(nameServerTypes[i] + '-dns-radio').checked) { 1107 if ($(nameServerTypes[i] + '-dns-radio').checked) {
1121 nameServerType = nameServerTypes[i]; 1108 nameServerType = nameServerTypes[i];
1122 break; 1109 break;
1123 } 1110 }
1124 } 1111 }
1125 detailsPage.sendIpConfig_(nameServerType); 1112 detailsPage.sendIpConfig_(nameServerType);
1126 1113
1114 var data = oncData.getData();
1115 if (Object.keys(data).length > 0) {
1116 // TODO(stevenjb): chrome.networkingPrivate.setProperties
1117 chrome.send('setProperties', [servicePath, data]);
1118 }
1119
1127 PageManager.closeOverlay(); 1120 PageManager.closeOverlay();
1128 }; 1121 };
1129 1122
1130 /** 1123 /**
1131 * Event handler called when the name server type changes. 1124 * Event handler called when the name server type changes.
1132 * @param {string} type The selected name sever type, 'automatic', 'google', 1125 * @param {string} type The selected name sever type, 'automatic', 'google',
1133 * or 'user'. 1126 * or 'user'.
1134 */ 1127 */
1135 DetailsInternetPage.updateNameServerDisplay = function(type) { 1128 DetailsInternetPage.updateNameServerDisplay = function(type) {
1136 var editable = type == 'user'; 1129 var editable = type == 'user';
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 1588
1596 // Don't show page name in address bar and in history to prevent people 1589 // Don't show page name in address bar and in history to prevent people
1597 // navigate here by hand and solve issue with page session restore. 1590 // navigate here by hand and solve issue with page session restore.
1598 PageManager.showPageByName('detailsInternetPage', false); 1591 PageManager.showPageByName('detailsInternetPage', false);
1599 }; 1592 };
1600 1593
1601 return { 1594 return {
1602 DetailsInternetPage: DetailsInternetPage 1595 DetailsInternetPage: DetailsInternetPage
1603 }; 1596 };
1604 }); 1597 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698