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

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: 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
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 if (guid.substring(0, 1) == '{')
pneubeck (no reviews) 2015/02/17 18:00:49 can't you just remove all '{' and '}' or replace t
stevenjb 2015/02/17 18:23:30 Sure, that works also.
153 guid = guid.substring(1, guid.length - 2);
154 return '_' + guid;
155 };
156
157 /**
146 * This callback function is triggered when visible networks are received. 158 * This callback function is triggered when visible networks are received.
147 * 159 *
148 * @param {Array} states A list of network state information for each 160 * @param {Array} states A list of network state information for each
149 * visible network. 161 * visible network.
150 */ 162 */
151 var onVisibleNetworksReceived = function(states) { 163 var onVisibleNetworksReceived = function(states) {
152 createStateTable('network-state-table', NETWORK_STATE_FIELDS, states); 164 createStateTable('network-state-table', NETWORK_STATE_FIELDS, states);
153 }; 165 };
154 166
155 /** 167 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 * @return {!HTMLElement} The created tr element for the expanded row. 203 * @return {!HTMLElement} The created tr element for the expanded row.
192 */ 204 */
193 var createExpandedRow = function(guid, baseRow) { 205 var createExpandedRow = function(guid, baseRow) {
194 var expandedRow = /** @type {!HTMLElement} */ ( 206 var expandedRow = /** @type {!HTMLElement} */ (
195 document.createElement('tr')); 207 document.createElement('tr'));
196 expandedRow.className = 'state-table-row'; 208 expandedRow.className = 'state-table-row';
197 var emptyCell = document.createElement('td'); 209 var emptyCell = document.createElement('td');
198 emptyCell.style.border = 'none'; 210 emptyCell.style.border = 'none';
199 expandedRow.appendChild(emptyCell); 211 expandedRow.appendChild(emptyCell);
200 var detailCell = document.createElement('td'); 212 var detailCell = document.createElement('td');
201 detailCell.id = guid; 213 detailCell.id = idFromGuid(guid);
202 detailCell.className = 'state-table-expanded-cell'; 214 detailCell.className = 'state-table-expanded-cell';
203 detailCell.colSpan = baseRow.childNodes.length - 1; 215 detailCell.colSpan = baseRow.childNodes.length - 1;
204 expandedRow.appendChild(detailCell); 216 expandedRow.appendChild(detailCell);
205 var showDetail = function(state, error) { 217 var showDetail = function(state, error) {
206 if (error && error.message) 218 if (error && error.message)
207 detailCell.textContent = error.message; 219 detailCell.textContent = error.message;
208 else 220 else
209 detailCell.textContent = JSON.stringify(state, null, '\t'); 221 detailCell.textContent = JSON.stringify(state, null, '\t');
210 }; 222 };
211 var selected = $('get-property-format').selectedIndex; 223 var selected = $('get-property-format').selectedIndex;
(...skipping 17 matching lines...) Expand all
229 * just the 'GUID' and 'ShillError' properties if the call failed. 241 * just the 'GUID' and 'ShillError' properties if the call failed.
230 */ 242 */
231 var getShillPropertiesResult = function(args) { 243 var getShillPropertiesResult = function(args) {
232 var properties = args.shift(); 244 var properties = args.shift();
233 var guid = properties['GUID']; 245 var guid = properties['GUID'];
234 if (!guid) { 246 if (!guid) {
235 console.error('No GUID in getShillPropertiesResult'); 247 console.error('No GUID in getShillPropertiesResult');
236 return; 248 return;
237 } 249 }
238 250
239 var detailCell = document.querySelector('td#' + guid); 251 var detailCell = document.querySelector('td#' + idFromGuid(guid));
240 if (!detailCell) { 252 if (!detailCell) {
241 console.error('No cell for GUID: ' + guid); 253 console.error('No cell for GUID: ' + guid);
242 return; 254 return;
243 } 255 }
244 256
245 if (properties['ShillError']) 257 if (properties['ShillError'])
246 detailCell.textContent = properties['ShillError']; 258 detailCell.textContent = properties['ShillError'];
247 else 259 else
248 detailCell.textContent = JSON.stringify(properties, null, '\t'); 260 detailCell.textContent = JSON.stringify(properties, null, '\t');
249 261
(...skipping 24 matching lines...) Expand all
274 document.addEventListener('DOMContentLoaded', function() { 286 document.addEventListener('DOMContentLoaded', function() {
275 $('refresh').onclick = requestNetworks; 287 $('refresh').onclick = requestNetworks;
276 setRefresh(); 288 setRefresh();
277 requestNetworks(); 289 requestNetworks();
278 }); 290 });
279 291
280 return { 292 return {
281 getShillPropertiesResult: getShillPropertiesResult 293 getShillPropertiesResult: getShillPropertiesResult
282 }; 294 };
283 })(); 295 })();
OLDNEW
« no previous file with comments | « no previous file | chromeos/network/network_configuration_handler.h » ('j') | chromeos/network/network_configuration_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698