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

Side by Side Diff: chrome/browser/resources/chromeos/network_ui/network_ui.js

Issue 917053002: Add Source property to networkingPrivate.getState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase with separated test expectations Created 5 years, 10 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/test/data/extensions/api_test/networking_private/chromeos/test.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 var NetworkUI = (function() { 5 var NetworkUI = (function() {
6 'use strict'; 6 'use strict';
7 7
8 // Properties to display in the network state table. Each entry can be either 8 // Properties to display in the network state table. Each entry can be either
9 // a single state field or an array of state fields. If more than one is 9 // a single state field or an array of state fields. If more than one is
10 // specified then the first non empty value is used. 10 // specified then the first non empty value is used.
(...skipping 14 matching lines...) Expand all
25 'WiFi.SignalStrength' 25 'WiFi.SignalStrength'
26 ]; 26 ];
27 27
28 var FAVORITE_STATE_FIELDS = [ 28 var FAVORITE_STATE_FIELDS = [
29 'GUID', 29 'GUID',
30 'service_path', 30 'service_path',
31 'Name', 31 'Name',
32 'Type', 32 'Type',
33 'profile_path', 33 'profile_path',
34 'visible', 34 'visible',
35 'onc_source' 35 'Source'
36 ]; 36 ];
37 37
38 /** 38 /**
39 * Returns the property associated with a key (which may reference a 39 * Returns the property associated with a key (which may reference a
40 * sub-object). 40 * sub-object).
41 * 41 *
42 * @param {Object} properties The object containing the network properties. 42 * @param {Object} properties The object containing the network properties.
43 * @param {string} key The ONC key for the property. May refer to a nested 43 * @param {string} key The ONC key for the property. May refer to a nested
44 * propety, e.g. 'WiFi.Security'. 44 * propety, e.g. 'WiFi.Security'.
45 * @return {*} The value associated with the property. 45 * @return {*} The value associated with the property.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 var table = $(tablename); 136 var table = $(tablename);
137 var oldRows = table.querySelectorAll('.state-table-row'); 137 var oldRows = table.querySelectorAll('.state-table-row');
138 for (var i = 0; i < oldRows.length; ++i) 138 for (var i = 0; i < oldRows.length; ++i)
139 table.removeChild(oldRows[i]); 139 table.removeChild(oldRows[i]);
140 states.forEach(function(state) { 140 states.forEach(function(state) {
141 table.appendChild(createStateTableRow(stateFields, state)); 141 table.appendChild(createStateTableRow(stateFields, state));
142 }); 142 });
143 }; 143 };
144 144
145 /** 145 /**
146 * Returns a valid HTMLElement id from |guid|.
147 *
148 * @param {string} guid A GUID which may start with a digit
149 * @return {string} A valid HTMLElement id.
150 */
151 var idFromGuid = function(guid) {
152 return '_' + guid.replace(/[{}]/g, '');
153 };
154
155 /**
146 * This callback function is triggered when visible networks are received. 156 * This callback function is triggered when visible networks are received.
147 * 157 *
148 * @param {Array} states A list of network state information for each 158 * @param {Array} states A list of network state information for each
149 * visible network. 159 * visible network.
150 */ 160 */
151 var onVisibleNetworksReceived = function(states) { 161 var onVisibleNetworksReceived = function(states) {
152 createStateTable('network-state-table', NETWORK_STATE_FIELDS, states); 162 createStateTable('network-state-table', NETWORK_STATE_FIELDS, states);
153 }; 163 };
154 164
155 /** 165 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 * @return {!HTMLElement} The created tr element for the expanded row. 201 * @return {!HTMLElement} The created tr element for the expanded row.
192 */ 202 */
193 var createExpandedRow = function(guid, baseRow) { 203 var createExpandedRow = function(guid, baseRow) {
194 var expandedRow = /** @type {!HTMLElement} */ ( 204 var expandedRow = /** @type {!HTMLElement} */ (
195 document.createElement('tr')); 205 document.createElement('tr'));
196 expandedRow.className = 'state-table-row'; 206 expandedRow.className = 'state-table-row';
197 var emptyCell = document.createElement('td'); 207 var emptyCell = document.createElement('td');
198 emptyCell.style.border = 'none'; 208 emptyCell.style.border = 'none';
199 expandedRow.appendChild(emptyCell); 209 expandedRow.appendChild(emptyCell);
200 var detailCell = document.createElement('td'); 210 var detailCell = document.createElement('td');
201 detailCell.id = guid; 211 detailCell.id = idFromGuid(guid);
202 detailCell.className = 'state-table-expanded-cell'; 212 detailCell.className = 'state-table-expanded-cell';
203 detailCell.colSpan = baseRow.childNodes.length - 1; 213 detailCell.colSpan = baseRow.childNodes.length - 1;
204 expandedRow.appendChild(detailCell); 214 expandedRow.appendChild(detailCell);
205 var showDetail = function(state, error) { 215 var showDetail = function(state, error) {
206 if (error && error.message) 216 if (error && error.message)
207 detailCell.textContent = error.message; 217 detailCell.textContent = error.message;
208 else 218 else
209 detailCell.textContent = JSON.stringify(state, null, '\t'); 219 detailCell.textContent = JSON.stringify(state, null, '\t');
210 }; 220 };
211 var selected = $('get-property-format').selectedIndex; 221 var selected = $('get-property-format').selectedIndex;
(...skipping 17 matching lines...) Expand all
229 * just the 'GUID' and 'ShillError' properties if the call failed. 239 * just the 'GUID' and 'ShillError' properties if the call failed.
230 */ 240 */
231 var getShillPropertiesResult = function(args) { 241 var getShillPropertiesResult = function(args) {
232 var properties = args.shift(); 242 var properties = args.shift();
233 var guid = properties['GUID']; 243 var guid = properties['GUID'];
234 if (!guid) { 244 if (!guid) {
235 console.error('No GUID in getShillPropertiesResult'); 245 console.error('No GUID in getShillPropertiesResult');
236 return; 246 return;
237 } 247 }
238 248
239 var detailCell = document.querySelector('td#' + guid); 249 var detailCell = document.querySelector('td#' + idFromGuid(guid));
240 if (!detailCell) { 250 if (!detailCell) {
241 console.error('No cell for GUID: ' + guid); 251 console.error('No cell for GUID: ' + guid);
242 return; 252 return;
243 } 253 }
244 254
245 if (properties['ShillError']) 255 if (properties['ShillError'])
246 detailCell.textContent = properties['ShillError']; 256 detailCell.textContent = properties['ShillError'];
247 else 257 else
248 detailCell.textContent = JSON.stringify(properties, null, '\t'); 258 detailCell.textContent = JSON.stringify(properties, null, '\t');
249 259
(...skipping 24 matching lines...) Expand all
274 document.addEventListener('DOMContentLoaded', function() { 284 document.addEventListener('DOMContentLoaded', function() {
275 $('refresh').onclick = requestNetworks; 285 $('refresh').onclick = requestNetworks;
276 setRefresh(); 286 setRefresh();
277 requestNetworks(); 287 requestNetworks();
278 }); 288 });
279 289
280 return { 290 return {
281 getShillPropertiesResult: getShillPropertiesResult 291 getShillPropertiesResult: getShillPropertiesResult
282 }; 292 };
283 })(); 293 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/networking_private/chromeos/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698