| OLD | NEW |
| 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 |
| 6 |
| 5 // 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 |
| 6 // compatible with the networkingPrivate extension API: | 8 // compatible with the networkingPrivate extension API: |
| 7 // * The network property dictionaries are being converted to use ONC values. | 9 // * The network property dictionaries are being converted to use ONC values. |
| 8 // * 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 |
| 9 // networkingPrivate API. See network_config.js. | 11 // networkingPrivate API. See network_config.js. |
| 10 // See crbug.com/279351 for more info. | 12 // See crbug.com/279351 for more info. |
| 11 | 13 |
| 12 cr.define('options.internet', function() { | 14 cr.define('options.internet', function() { |
| 15 var OncData = cr.onc.OncData; |
| 13 var Page = cr.ui.pageManager.Page; | 16 var Page = cr.ui.pageManager.Page; |
| 14 var PageManager = cr.ui.pageManager.PageManager; | 17 var PageManager = cr.ui.pageManager.PageManager; |
| 15 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | |
| 16 /** @const */ var IPAddressField = options.internet.IPAddressField; | 18 /** @const */ var IPAddressField = options.internet.IPAddressField; |
| 17 | 19 |
| 18 var GetManagedTypes = { | |
| 19 ACTIVE: 0, | |
| 20 TRANSLATED: 1, | |
| 21 RECOMMENDED: 2 | |
| 22 }; | |
| 23 | |
| 24 /** | |
| 25 * Gets the value of a property from a dictionary |data| that includes ONC | |
| 26 * managed properties, e.g. getManagedValue(data, 'Name'). See notes for | |
| 27 * getManagedProperty. | |
| 28 * @param {object} data The properties dictionary. | |
| 29 * @param {string} key The property key. | |
| 30 * @param {string} type (Optional) The type of property to get as defined in | |
| 31 * GetManagedTypes: | |
| 32 * 'ACTIVE' (default) - gets the active value | |
| 33 * 'TRANSLATED' - gets the traslated or active value | |
| 34 * 'RECOMMENDED' - gets the recommended value | |
| 35 * @return {*} The property value or undefined. | |
| 36 */ | |
| 37 function getManagedValue(data, key, type) { | |
| 38 var property = getManagedProperty(data, key); | |
| 39 if (Array.isArray(property) || typeof property != 'object') | |
| 40 return property; | |
| 41 if (type == GetManagedTypes.RECOMMENDED) | |
| 42 return getRecommendedValue(property); | |
| 43 if (type == GetManagedTypes.TRANSLATED && 'Translated' in property) | |
| 44 return property['Translated']; | |
| 45 // Otherwise get the Active value (defalt behavior). | |
| 46 if ('Active' in property) | |
| 47 return property['Active']; | |
| 48 // If no Active value is defined, return the effective value if present. | |
| 49 var effective = getEffectiveValue(property); | |
| 50 if (effective != undefined) | |
| 51 return effective; | |
| 52 // Otherwise this is an Object but not a Managed one. | |
| 53 return property; | |
| 54 } | |
| 55 | |
| 56 /** | |
| 57 * Get the recommended value from a Managed property ONC dictionary. | |
| 58 * @param {object} property The managed property ONC dictionary. | |
| 59 * @return {*} the effective value or undefined. | |
| 60 */ | |
| 61 function getRecommendedValue(property) { | |
| 62 if (property['UserEditable']) | |
| 63 return property['UserPolicy']; | |
| 64 if (property['DeviceEditable']) | |
| 65 return property['DevicePolicy']; | |
| 66 // No value recommended by policy. | |
| 67 return undefined; | |
| 68 } | |
| 69 | |
| 70 /** | |
| 71 * Get the effective value from a Managed property ONC dictionary. | |
| 72 * @param {object} property The managed property ONC dictionary. | |
| 73 * @return {*} The effective value or undefined. | |
| 74 */ | |
| 75 function getEffectiveValue(property) { | |
| 76 if ('Effective' in property) { | |
| 77 var effective = property.Effective; | |
| 78 if (effective in property) | |
| 79 return property[effective]; | |
| 80 } | |
| 81 return undefined; | |
| 82 } | |
| 83 | |
| 84 /** | |
| 85 * Gets either a managed property dictionary or an unmanaged value from | |
| 86 * dictionary |data| that includes ONC managed properties. This supports | |
| 87 * nested dictionaries, e.g. getManagedProperty(data, 'VPN.Type'). | |
| 88 * @param {object} data The properties dictionary. | |
| 89 * @param {string} key The property key. | |
| 90 * @return {*} The property value or dictionary if it exists, otherwise | |
| 91 * undefined. | |
| 92 */ | |
| 93 function getManagedProperty(data, key) { | |
| 94 while (true) { | |
| 95 var index = key.indexOf('.'); | |
| 96 if (index < 0) | |
| 97 break; | |
| 98 var keyComponent = key.substr(0, index); | |
| 99 if (!(keyComponent in data)) | |
| 100 return undefined; | |
| 101 data = data[keyComponent]; | |
| 102 key = key.substr(index + 1); | |
| 103 } | |
| 104 return data[key]; | |
| 105 } | |
| 106 | |
| 107 /** | |
| 108 * Set the value of a property in dictionary |data| that includes ONC | |
| 109 * managed properties, e.g. setManagedValue(data, 'Name', 'MyNetwork'). | |
| 110 * See notes for getManagedProperty. | |
| 111 * @param {object} data The properties dictionary. | |
| 112 * @param {string} key The property key. | |
| 113 * @param {string} value The property value to set. | |
| 114 */ | |
| 115 function setManagedProperty(data, key, value) { | |
| 116 while (true) { | |
| 117 var index = key.indexOf('.'); | |
| 118 if (index < 0) | |
| 119 break; | |
| 120 var keyComponent = key.substr(0, index); | |
| 121 if (!(keyComponent in data)) | |
| 122 data[keyComponent] = {}; | |
| 123 data = data[keyComponent]; | |
| 124 key = key.substr(index + 1); | |
| 125 } | |
| 126 if (!(key in data) || | |
| 127 (typeof data[key] != 'object') || | |
| 128 (!('Active' in data[key]) && !('Effective' in data[key]))) { | |
| 129 data[key] = value; | |
| 130 } else { | |
| 131 var effective = data[key]['Effective']; | |
| 132 assert(effective != 'UserPolicy' || data[key]['UserEditable']); | |
| 133 assert(effective != 'DevicePolicy' || data[key]['DeviceEditable']); | |
| 134 // For now, just uodare the active value. TODO(stevenjb): Eventually we | |
| 135 // should update the 'UserSetting' and 'Effective' properties correctly | |
| 136 // and send that back to Chrome. | |
| 137 data[key]['Active'] = value; | |
| 138 } | |
| 139 } | |
| 140 | |
| 141 /** | 20 /** |
| 142 * Helper function to set hidden attribute for elements matching a selector. | 21 * Helper function to set hidden attribute for elements matching a selector. |
| 143 * @param {string} selector CSS selector for extracting a list of elements. | 22 * @param {string} selector CSS selector for extracting a list of elements. |
| 144 * @param {bool} hidden New hidden value. | 23 * @param {bool} hidden New hidden value. |
| 145 */ | 24 */ |
| 146 function updateHidden(selector, hidden) { | 25 function updateHidden(selector, hidden) { |
| 147 var elements = cr.doc.querySelectorAll(selector); | 26 var elements = cr.doc.querySelectorAll(selector); |
| 148 for (var i = 0, el; el = elements[i]; i++) { | 27 for (var i = 0, el; el = elements[i]; i++) { |
| 149 el.hidden = hidden; | 28 el.hidden = hidden; |
| 150 } | 29 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 * Sends the 'checked' state of a control to chrome for a network. | 72 * Sends the 'checked' state of a control to chrome for a network. |
| 194 * @param {string} path The service path of the network. | 73 * @param {string} path The service path of the network. |
| 195 * @param {string} message The message to send to chrome. | 74 * @param {string} message The message to send to chrome. |
| 196 * @param {HTMLInputElement} checkbox The checkbox storing the value to send. | 75 * @param {HTMLInputElement} checkbox The checkbox storing the value to send. |
| 197 */ | 76 */ |
| 198 function sendCheckedIfEnabled(path, message, checkbox) { | 77 function sendCheckedIfEnabled(path, message, checkbox) { |
| 199 if (!checkbox.hidden && !checkbox.disabled) | 78 if (!checkbox.hidden && !checkbox.disabled) |
| 200 chrome.send(message, [path, checkbox.checked ? 'true' : 'false']); | 79 chrome.send(message, [path, checkbox.checked ? 'true' : 'false']); |
| 201 } | 80 } |
| 202 | 81 |
| 203 /** | |
| 204 * Looks up the string to display for 'state' in loadTimeData. | |
| 205 * @param {string} state The ONC State property of a network. | |
| 206 */ | |
| 207 function networkOncStateString(state) { | |
| 208 if (state == 'NotConnected') | |
| 209 return loadTimeData.getString('OncStateNotConnected'); | |
| 210 else if (state == 'Connecting') | |
| 211 return loadTimeData.getString('OncStateConnecting'); | |
| 212 else if (state == 'Connected') | |
| 213 return loadTimeData.getString('OncStateConnected'); | |
| 214 return loadTimeData.getString('OncStateUnknown'); | |
| 215 } | |
| 216 | |
| 217 /** | |
| 218 * Returns the display name for the network represented by 'data'. | |
| 219 * @param {Object} data The network ONC dictionary. | |
| 220 */ | |
| 221 function getNetworkName(data) { | |
| 222 if (data.type == 'Ethernet') | |
| 223 return loadTimeData.getString('ethernetName'); | |
| 224 return getManagedValue(data, 'Name'); | |
| 225 } | |
| 226 | |
| 227 ///////////////////////////////////////////////////////////////////////////// | 82 ///////////////////////////////////////////////////////////////////////////// |
| 228 // DetailsInternetPage class: | 83 // DetailsInternetPage class: |
| 229 | 84 |
| 230 /** | 85 /** |
| 231 * Encapsulated handling of ChromeOS internet details overlay page. | 86 * Encapsulated handling of ChromeOS internet details overlay page. |
| 232 * @constructor | 87 * @constructor |
| 233 */ | 88 */ |
| 234 function DetailsInternetPage() { | 89 function DetailsInternetPage() { |
| 235 Page.call(this, 'detailsInternetPage', null, 'details-internet-page'); | 90 Page.call(this, 'detailsInternetPage', null, 'details-internet-page'); |
| 236 } | 91 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 }); | 151 }); |
| 297 | 152 |
| 298 $('view-account-details').addEventListener('click', function(event) { | 153 $('view-account-details').addEventListener('click', function(event) { |
| 299 var data = $('connection-state').data; | 154 var data = $('connection-state').data; |
| 300 chrome.send('showMorePlanInfo', [data.servicePath]); | 155 chrome.send('showMorePlanInfo', [data.servicePath]); |
| 301 PageManager.closeOverlay(); | 156 PageManager.closeOverlay(); |
| 302 }); | 157 }); |
| 303 | 158 |
| 304 $('cellular-apn-use-default').addEventListener('click', function(event) { | 159 $('cellular-apn-use-default').addEventListener('click', function(event) { |
| 305 var data = $('connection-state').data; | 160 var data = $('connection-state').data; |
| 161 var onc = $('connection-state').onc; |
| 306 var apnSelector = $('select-apn'); | 162 var apnSelector = $('select-apn'); |
| 307 | 163 |
| 308 if (data.userApnIndex != -1) { | 164 if (data.userApnIndex != -1) { |
| 309 apnSelector.remove(data.userApnIndex); | 165 apnSelector.remove(data.userApnIndex); |
| 310 data.userApnIndex = -1; | 166 data.userApnIndex = -1; |
| 311 } | 167 } |
| 312 | 168 |
| 313 var activeApn; | 169 var activeApn; |
| 314 var iApn = -1; | 170 var iApn = -1; |
| 315 var apnList = getManagedValue(data, 'Cellular.APNList'); | 171 var apnList = onc.getActiveValue('Cellular.APNList'); |
| 316 if (apnList != undefined && apnList.length > 0) { | 172 if (apnList != undefined && apnList.length > 0) { |
| 317 iApn = 0; | 173 iApn = 0; |
| 318 var defaultApn = apnList[iApn]; | 174 var defaultApn = apnList[iApn]; |
| 319 activeApn['AccessPointName'] = | 175 activeApn['AccessPointName'] = |
| 320 stringFromValue(defaultApn['AccessPointName']); | 176 stringFromValue(defaultApn['AccessPointName']); |
| 321 activeApn['Username'] = stringFromValue(defaultApn['Username']); | 177 activeApn['Username'] = stringFromValue(defaultApn['Username']); |
| 322 activeApn['Password'] = stringFromValue(defaultApn['Password']); | 178 activeApn['Password'] = stringFromValue(defaultApn['Password']); |
| 323 chrome.send('setApn', [data.servicePath, | 179 chrome.send('setApn', [data.servicePath, |
| 324 activeApn['AccessPointName'], | 180 activeApn['AccessPointName'], |
| 325 activeApn['Username'], | 181 activeApn['Username'], |
| 326 activeApn['Password']]); | 182 activeApn['Password']]); |
| 327 } | 183 } |
| 328 setManagedProperty(data, 'Cellular.APN', activeApn); | 184 onc.setManagedProperty('Cellular.APN', activeApn); |
| 329 apnSelector.selectedIndex = iApn; | 185 apnSelector.selectedIndex = iApn; |
| 330 data.selectedApn = iApn; | 186 data.selectedApn = iApn; |
| 331 | 187 |
| 332 updateHidden('.apn-list-view', false); | 188 updateHidden('.apn-list-view', false); |
| 333 updateHidden('.apn-details-view', true); | 189 updateHidden('.apn-details-view', true); |
| 334 }); | 190 }); |
| 335 | 191 |
| 336 $('cellular-apn-set').addEventListener('click', function(event) { | 192 $('cellular-apn-set').addEventListener('click', function(event) { |
| 337 if ($('cellular-apn').value == '') | 193 if ($('cellular-apn').value == '') |
| 338 return; | 194 return; |
| 339 | 195 |
| 340 var data = $('connection-state').data; | 196 var data = $('connection-state').data; |
| 197 var onc = $('connection-state').onc; |
| 341 var apnSelector = $('select-apn'); | 198 var apnSelector = $('select-apn'); |
| 342 | 199 |
| 343 var activeApn = {}; | 200 var activeApn = {}; |
| 344 activeApn['AccessPointName'] = | 201 activeApn['AccessPointName'] = |
| 345 stringFromValue($('cellular-apn').value); | 202 stringFromValue($('cellular-apn').value); |
| 346 activeApn['Username'] = | 203 activeApn['Username'] = |
| 347 stringFromValue($('cellular-apn-username').value); | 204 stringFromValue($('cellular-apn-username').value); |
| 348 activeApn['Password'] = | 205 activeApn['Password'] = |
| 349 stringFromValue($('cellular-apn-password').value); | 206 stringFromValue($('cellular-apn-password').value); |
| 350 setManagedProperty(data, 'Cellular.APN', activeApn); | 207 onc.setManagedProperty('Cellular.APN', activeApn); |
| 351 data.userApn = activeApn; | 208 data.userApn = activeApn; |
| 352 chrome.send('setApn', [data.servicePath, | 209 chrome.send('setApn', [data.servicePath, |
| 353 activeApn['AccessPointName'], | 210 activeApn['AccessPointName'], |
| 354 activeApn['Username'], | 211 activeApn['Username'], |
| 355 activeApn['Password']]); | 212 activeApn['Password']]); |
| 356 | 213 |
| 357 if (data.userApnIndex != -1) { | 214 if (data.userApnIndex != -1) { |
| 358 apnSelector.remove(data.userApnIndex); | 215 apnSelector.remove(data.userApnIndex); |
| 359 data.userApnIndex = -1; | 216 data.userApnIndex = -1; |
| 360 } | 217 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 372 }); | 229 }); |
| 373 | 230 |
| 374 $('cellular-apn-cancel').addEventListener('click', function(event) { | 231 $('cellular-apn-cancel').addEventListener('click', function(event) { |
| 375 $('select-apn').selectedIndex = $('connection-state').data.selectedApn; | 232 $('select-apn').selectedIndex = $('connection-state').data.selectedApn; |
| 376 updateHidden('.apn-list-view', false); | 233 updateHidden('.apn-list-view', false); |
| 377 updateHidden('.apn-details-view', true); | 234 updateHidden('.apn-details-view', true); |
| 378 }); | 235 }); |
| 379 | 236 |
| 380 $('select-apn').addEventListener('change', function(event) { | 237 $('select-apn').addEventListener('change', function(event) { |
| 381 var data = $('connection-state').data; | 238 var data = $('connection-state').data; |
| 239 var onc = $('connection-state').onc; |
| 382 var apnSelector = $('select-apn'); | 240 var apnSelector = $('select-apn'); |
| 383 var apnDict; | 241 var apnDict; |
| 384 if (apnSelector[apnSelector.selectedIndex].value != -1) { | 242 if (apnSelector[apnSelector.selectedIndex].value != -1) { |
| 385 var apnList = getManagedValue(data, 'Cellular.APNList'); | 243 var apnList = onc.getActiveValue('Cellular.APNList'); |
| 386 var apnIndex = apnSelector.selectedIndex; | 244 var apnIndex = apnSelector.selectedIndex; |
| 387 assert(apnIndex < apnList.length); | 245 assert(apnIndex < apnList.length); |
| 388 apnDict = apnList[apnIndex]; | 246 apnDict = apnList[apnIndex]; |
| 389 chrome.send('setApn', [data.servicePath, | 247 chrome.send('setApn', [data.servicePath, |
| 390 stringFromValue(apnDict['AccessPointName']), | 248 stringFromValue(apnDict['AccessPointName']), |
| 391 stringFromValue(apnDict['Username']), | 249 stringFromValue(apnDict['Username']), |
| 392 stringFromValue(apnDict['Password'])]); | 250 stringFromValue(apnDict['Password'])]); |
| 393 data.selectedApn = apnIndex; | 251 data.selectedApn = apnIndex; |
| 394 } else if (apnSelector.selectedIndex == data.userApnIndex) { | 252 } else if (apnSelector.selectedIndex == data.userApnIndex) { |
| 395 apnDict = data.userApn; | 253 apnDict = data.userApn; |
| 396 chrome.send('setApn', [data.servicePath, | 254 chrome.send('setApn', [data.servicePath, |
| 397 stringFromValue(apnDict['AccessPointName']), | 255 stringFromValue(apnDict['AccessPointName']), |
| 398 stringFromValue(apnDict['Username']), | 256 stringFromValue(apnDict['Username']), |
| 399 stringFromValue(apnDict['Password'])]); | 257 stringFromValue(apnDict['Password'])]); |
| 400 data.selectedApn = apnSelector.selectedIndex; | 258 data.selectedApn = apnSelector.selectedIndex; |
| 401 } else { | 259 } else { |
| 402 apnDict = getManagedValue(data, 'Cellular.APN'); | 260 apnDict = onc.getActiveValue('Cellular.APN'); |
| 403 $('cellular-apn').value = stringFromValue(apnDict['AccessPointName']); | 261 $('cellular-apn').value = stringFromValue(apnDict['AccessPointName']); |
| 404 $('cellular-apn-username').value = | 262 $('cellular-apn-username').value = |
| 405 stringFromValue(apnDict['Username']); | 263 stringFromValue(apnDict['Username']); |
| 406 $('cellular-apn-password').value = | 264 $('cellular-apn-password').value = |
| 407 stringFromValue(apnDict['Password']); | 265 stringFromValue(apnDict['Password']); |
| 408 | 266 |
| 409 updateHidden('.apn-list-view', true); | 267 updateHidden('.apn-list-view', true); |
| 410 updateHidden('.apn-details-view', false); | 268 updateHidden('.apn-details-view', false); |
| 411 } | 269 } |
| 412 }); | 270 }); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 */ | 386 */ |
| 529 handleNameServerTypeChange_: function(event) { | 387 handleNameServerTypeChange_: function(event) { |
| 530 var type = event.target.value; | 388 var type = event.target.value; |
| 531 DetailsInternetPage.updateNameServerDisplay(type); | 389 DetailsInternetPage.updateNameServerDisplay(type); |
| 532 }, | 390 }, |
| 533 | 391 |
| 534 /** | 392 /** |
| 535 * Creates an indicator event for controlled properties using | 393 * Creates an indicator event for controlled properties using |
| 536 * the same dictionary format as CoreOptionsHandler::CreateValueForPref. | 394 * the same dictionary format as CoreOptionsHandler::CreateValueForPref. |
| 537 * @param {string} name The name for the Event. | 395 * @param {string} name The name for the Event. |
| 538 * @param {Object} data Property dictionary with |value|, |controlledBy|, | 396 * @param {Object} propData Property dictionary with |value|, |controlledBy| |
| 539 * and |recommendedValue| properties set. | 397 * and |recommendedValue| properties set. |
| 540 * @private | 398 * @private |
| 541 */ | 399 */ |
| 542 createControlledEvent_: function(name, propData) { | 400 createControlledEvent_: function(name, propData) { |
| 543 var event = new Event(name); | 401 var event = new Event(name); |
| 544 event.value = { | 402 event.value = { |
| 545 value: propData.value, | 403 value: propData.value, |
| 546 controlledBy: propData.controlledBy, | 404 controlledBy: propData.controlledBy, |
| 547 recommendedValue: propData.recommendedValue | 405 recommendedValue: propData.recommendedValue |
| 548 }; | 406 }; |
| 549 return event; | 407 return event; |
| 550 }, | 408 }, |
| 551 | 409 |
| 552 /** | 410 /** |
| 553 * Creates an indicator event for controlled properties using | 411 * Creates an indicator event for controlled properties using |
| 554 * the ONC getManagedProperties dictionary format. | 412 * the ONC getManagedProperties dictionary format. |
| 555 * @param {string} name The name for the Event. | 413 * @param {string} name The name for the Event. |
| 556 * @param {Object} data ONC managed network property dictionary. | 414 * @param {Object} propData ONC managed network property dictionary. |
| 557 * @private | 415 * @private |
| 558 */ | 416 */ |
| 559 createManagedEvent_: function(name, propData) { | 417 createManagedEvent_: function(name, propData) { |
| 560 var event = new Event(name); | 418 var event = new Event(name); |
| 561 event.value = {}; | 419 event.value = {}; |
| 562 | 420 |
| 563 // Set the current value and recommended value. | 421 // Set the current value and recommended value. |
| 564 var activeValue = propData['Active']; | 422 var activeValue = propData['Active']; |
| 565 var effective = propData['Effective']; | 423 var effective = propData['Effective']; |
| 566 if (activeValue == undefined) | 424 if (activeValue == undefined) |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 DetailsInternetPage.configureNetwork = function() { | 752 DetailsInternetPage.configureNetwork = function() { |
| 895 var data = $('connection-state').data; | 753 var data = $('connection-state').data; |
| 896 var servicePath = data.servicePath; | 754 var servicePath = data.servicePath; |
| 897 chrome.send('networkCommand', [data.type, servicePath, 'configure']); | 755 chrome.send('networkCommand', [data.type, servicePath, 'configure']); |
| 898 PageManager.closeOverlay(); | 756 PageManager.closeOverlay(); |
| 899 }; | 757 }; |
| 900 | 758 |
| 901 DetailsInternetPage.activateFromDetails = function() { | 759 DetailsInternetPage.activateFromDetails = function() { |
| 902 var data = $('connection-state').data; | 760 var data = $('connection-state').data; |
| 903 var servicePath = data.servicePath; | 761 var servicePath = data.servicePath; |
| 904 if (data.Type == 'Cellular') | 762 if (data.type == 'Cellular') |
| 905 chrome.send('networkCommand', [data.type, servicePath, 'activate']); | 763 chrome.send('networkCommand', [data.type, servicePath, 'activate']); |
| 906 PageManager.closeOverlay(); | 764 PageManager.closeOverlay(); |
| 907 }; | 765 }; |
| 908 | 766 |
| 909 DetailsInternetPage.setDetails = function() { | 767 DetailsInternetPage.setDetails = function() { |
| 910 var data = $('connection-state').data; | 768 var data = $('connection-state').data; |
| 911 var servicePath = data.servicePath; | 769 var servicePath = data.servicePath; |
| 912 if (data.type == 'WiFi') { | 770 if (data.type == 'WiFi') { |
| 913 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', | 771 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', |
| 914 $('prefer-network-wifi')); | 772 $('prefer-network-wifi')); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 userDns.removeAttribute('selected'); | 843 userDns.removeAttribute('selected'); |
| 986 break; | 844 break; |
| 987 case 'user': | 845 case 'user': |
| 988 automaticDns.removeAttribute('selected'); | 846 automaticDns.removeAttribute('selected'); |
| 989 googleDns.removeAttribute('selected'); | 847 googleDns.removeAttribute('selected'); |
| 990 userDns.setAttribute('selected', ''); | 848 userDns.setAttribute('selected', ''); |
| 991 break; | 849 break; |
| 992 } | 850 } |
| 993 }; | 851 }; |
| 994 | 852 |
| 995 DetailsInternetPage.updateConnectionButtonVisibilty = function(data) { | 853 DetailsInternetPage.updateConnectionButtonVisibilty = function(onc) { |
| 996 if (data.type == 'Ethernet') { | 854 if (onc.type == 'Ethernet') { |
| 997 // Ethernet can never be connected or disconnected and can always be | 855 // Ethernet can never be connected or disconnected and can always be |
| 998 // configured (e.g. to set security). | 856 // configured (e.g. to set security). |
| 999 $('details-internet-login').hidden = true; | 857 $('details-internet-login').hidden = true; |
| 1000 $('details-internet-disconnect').hidden = true; | 858 $('details-internet-disconnect').hidden = true; |
| 1001 $('details-internet-configure').hidden = false; | 859 $('details-internet-configure').hidden = false; |
| 1002 return; | 860 return; |
| 1003 } | 861 } |
| 1004 | 862 |
| 1005 var connectState = getManagedValue(data, 'ConnectionState'); | 863 var connectState = onc.getActiveValue('ConnectionState'); |
| 1006 if (connectState == 'NotConnected') { | 864 if (connectState == 'NotConnected') { |
| 1007 $('details-internet-login').hidden = false; | 865 $('details-internet-login').hidden = false; |
| 1008 // Connecting to an unconfigured network might trigger certificate | 866 // Connecting to an unconfigured network might trigger certificate |
| 1009 // installation UI. Until that gets handled here, always enable the | 867 // installation UI. Until that gets handled here, always enable the |
| 1010 // Connect button. | 868 // Connect button. |
| 1011 $('details-internet-login').disabled = false; | 869 $('details-internet-login').disabled = false; |
| 1012 $('details-internet-disconnect').hidden = true; | 870 $('details-internet-disconnect').hidden = true; |
| 1013 } else { | 871 } else { |
| 1014 $('details-internet-login').hidden = true; | 872 $('details-internet-login').hidden = true; |
| 1015 $('details-internet-disconnect').hidden = false; | 873 $('details-internet-disconnect').hidden = false; |
| 1016 } | 874 } |
| 1017 | 875 |
| 1018 var connectable = getManagedValue(data, 'Connectable'); | 876 var connectable = onc.getActiveValue('Connectable'); |
| 1019 if (connectState != 'Connected' && | 877 if (connectState != 'Connected' && |
| 1020 (!connectable || this.hasSecurity || | 878 (!connectable || this.hasSecurity || |
| 1021 (data.type == 'Wimax' || data.type == 'VPN'))) { | 879 (onc.type == 'Wimax' || onc.type == 'VPN'))) { |
| 1022 $('details-internet-configure').hidden = false; | 880 $('details-internet-configure').hidden = false; |
| 1023 } else { | 881 } else { |
| 1024 $('details-internet-configure').hidden = true; | 882 $('details-internet-configure').hidden = true; |
| 1025 } | 883 } |
| 1026 }; | 884 }; |
| 1027 | 885 |
| 1028 DetailsInternetPage.updateConnectionData = function(update) { | 886 DetailsInternetPage.updateConnectionData = function(update) { |
| 1029 var detailsPage = DetailsInternetPage.getInstance(); | 887 var detailsPage = DetailsInternetPage.getInstance(); |
| 1030 if (!detailsPage.visible) | 888 if (!detailsPage.visible) |
| 1031 return; | 889 return; |
| 1032 | 890 |
| 1033 var data = $('connection-state').data; | 891 var data = $('connection-state').data; |
| 1034 if (!data) | 892 if (!data) |
| 1035 return; | 893 return; |
| 1036 | 894 |
| 1037 if (update.servicePath != data.servicePath) | 895 if (update.servicePath != data.servicePath) |
| 1038 return; | 896 return; |
| 1039 | 897 |
| 1040 // Update our cached data object. | 898 // Update our cached data object. |
| 1041 updateDataObject(data, update); | 899 updateDataObject(data, update); |
| 900 var onc = new OncData(data); |
| 1042 | 901 |
| 1043 var connectionState = getManagedValue(data, 'ConnectionState'); | 902 var connectionState = onc.getActiveValue('ConnectionState'); |
| 1044 var connectionStateString = networkOncStateString(connectionState); | 903 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
| 1045 detailsPage.deviceConnected = data.deviceConnected; | 904 detailsPage.deviceConnected = data.deviceConnected; |
| 1046 detailsPage.connected = connectionState == 'Connected'; | 905 detailsPage.connected = connectionState == 'Connected'; |
| 1047 $('connection-state').textContent = connectionStateString; | 906 $('connection-state').textContent = connectionStateString; |
| 1048 | 907 |
| 1049 this.updateConnectionButtonVisibilty(data); | 908 this.updateConnectionButtonVisibilty(onc); |
| 1050 | 909 |
| 1051 if (data.type == 'WiFi') { | 910 if (onc.type == 'WiFi') { |
| 1052 $('wifi-connection-state').textContent = connectionStateString; | 911 $('wifi-connection-state').textContent = connectionStateString; |
| 1053 } else if (data.type == 'Wimax') { | 912 } else if (onc.type == 'Wimax') { |
| 1054 $('wimax-connection-state').textContent = connectionStateString; | 913 $('wimax-connection-state').textContent = connectionStateString; |
| 1055 } else if (data.type == 'Cellular') { | 914 } else if (onc.type == 'Cellular') { |
| 1056 $('activation-state').textContent = data.activationState; | 915 $('activation-state').textContent = data.activationState; |
| 1057 | 916 |
| 1058 $('buyplan-details').hidden = !data.showBuyButton; | 917 $('buyplan-details').hidden = !data.showBuyButton; |
| 1059 $('view-account-details').hidden = !data.showViewAccountButton; | 918 $('view-account-details').hidden = !data.showViewAccountButton; |
| 1060 | 919 |
| 1061 $('activate-details').hidden = !data.showActivateButton; | 920 $('activate-details').hidden = !data.showActivateButton; |
| 1062 if (data.showActivateButton) | 921 if (data.showActivateButton) |
| 1063 $('details-internet-login').hidden = true; | 922 $('details-internet-login').hidden = true; |
| 1064 | 923 |
| 1065 if (detailsPage.gsm) { | 924 if (detailsPage.gsm) { |
| 1066 var lockEnabled = | 925 var lockEnabled = |
| 1067 getManagedValue(data, 'Cellular.SIMLockStatus.LockEnabled'); | 926 onc.getActiveValue('Cellular.SIMLockStatus.LockEnabled'); |
| 1068 $('sim-card-lock-enabled').checked = lockEnabled; | 927 $('sim-card-lock-enabled').checked = lockEnabled; |
| 1069 $('change-pin').hidden = !lockEnabled; | 928 $('change-pin').hidden = !lockEnabled; |
| 1070 } | 929 } |
| 1071 } | 930 } |
| 1072 | 931 |
| 1073 $('connection-state').data = data; | 932 $('connection-state').data = data; |
| 933 $('connection-state').onc = onc; |
| 1074 }; | 934 }; |
| 1075 | 935 |
| 1076 DetailsInternetPage.showDetailedInfo = function(data) { | 936 DetailsInternetPage.showDetailedInfo = function(data) { |
| 1077 var detailsPage = DetailsInternetPage.getInstance(); | 937 var detailsPage = DetailsInternetPage.getInstance(); |
| 1078 | 938 |
| 1079 data.type = getManagedValue(data, 'Type'); // Get Active Type value. | 939 var onc = new OncData(data); |
| 940 data.type = onc.type; |
| 1080 | 941 |
| 1081 // Populate header | 942 // Populate header |
| 1082 $('network-details-title').textContent = getNetworkName(data); | 943 $('network-details-title').textContent = onc.getTranslatedValue('Name'); |
| 1083 var connectionState = getManagedValue(data, 'ConnectionState'); | 944 var connectionState = onc.getActiveValue('ConnectionState'); |
| 1084 var connectionStateString = networkOncStateString(connectionState); | 945 var connectionStateString = onc.getTranslatedValue('ConnectionState'); |
| 1085 detailsPage.connected = connectionState == 'Connected'; | 946 detailsPage.connected = connectionState == 'Connected'; |
| 1086 $('network-details-subtitle-status').textContent = connectionStateString; | 947 $('network-details-subtitle-status').textContent = connectionStateString; |
| 1087 var typeKey = null; | 948 var typeKey = null; |
| 1088 switch (data.type) { | 949 switch (onc.type) { |
| 1089 case 'Ethernet': | 950 case 'Ethernet': |
| 1090 typeKey = 'ethernetTitle'; | 951 typeKey = 'ethernetTitle'; |
| 1091 break; | 952 break; |
| 1092 case 'WiFi': | 953 case 'WiFi': |
| 1093 typeKey = 'wifiTitle'; | 954 typeKey = 'wifiTitle'; |
| 1094 break; | 955 break; |
| 1095 case 'Wimax': | 956 case 'Wimax': |
| 1096 typeKey = 'wimaxTitle'; | 957 typeKey = 'wimaxTitle'; |
| 1097 break; | 958 break; |
| 1098 case 'Cellular': | 959 case 'Cellular': |
| 1099 typeKey = 'cellularTitle'; | 960 typeKey = 'cellularTitle'; |
| 1100 break; | 961 break; |
| 1101 case 'VPN': | 962 case 'VPN': |
| 1102 typeKey = 'vpnTitle'; | 963 typeKey = 'vpnTitle'; |
| 1103 break; | 964 break; |
| 1104 } | 965 } |
| 1105 var typeLabel = $('network-details-subtitle-type'); | 966 var typeLabel = $('network-details-subtitle-type'); |
| 1106 var typeSeparator = $('network-details-subtitle-separator'); | 967 var typeSeparator = $('network-details-subtitle-separator'); |
| 1107 if (typeKey) { | 968 if (typeKey) { |
| 1108 typeLabel.textContent = loadTimeData.getString(typeKey); | 969 typeLabel.textContent = loadTimeData.getString(typeKey); |
| 1109 typeLabel.hidden = false; | 970 typeLabel.hidden = false; |
| 1110 typeSeparator.hidden = false; | 971 typeSeparator.hidden = false; |
| 1111 } else { | 972 } else { |
| 1112 typeLabel.hidden = true; | 973 typeLabel.hidden = true; |
| 1113 typeSeparator.hidden = true; | 974 typeSeparator.hidden = true; |
| 1114 } | 975 } |
| 1115 | 976 |
| 1116 // TODO(stevenjb): Find a more appropriate place to cache data. | 977 // TODO(stevenjb): Find a more appropriate place to cache data. |
| 1117 $('connection-state').data = data; | 978 $('connection-state').data = data; |
| 979 $('connection-state').onc = onc; |
| 1118 | 980 |
| 1119 $('buyplan-details').hidden = true; | 981 $('buyplan-details').hidden = true; |
| 1120 $('activate-details').hidden = true; | 982 $('activate-details').hidden = true; |
| 1121 $('view-account-details').hidden = true; | 983 $('view-account-details').hidden = true; |
| 1122 | 984 |
| 1123 this.updateConnectionButtonVisibilty(data); | 985 this.updateConnectionButtonVisibilty(onc); |
| 1124 | 986 |
| 1125 $('web-proxy-auto-discovery').hidden = true; | 987 $('web-proxy-auto-discovery').hidden = true; |
| 1126 | 988 |
| 1127 detailsPage.deviceConnected = data.deviceConnected; | 989 detailsPage.deviceConnected = data.deviceConnected; |
| 1128 detailsPage.connected = connectionState == 'Connected'; | 990 detailsPage.connected = connectionState == 'Connected'; |
| 1129 | 991 |
| 1130 // Only show proxy for remembered networks. | 992 // Only show proxy for remembered networks. |
| 1131 if (data.remembered) { | 993 if (data.remembered) { |
| 1132 detailsPage.showProxy = true; | 994 detailsPage.showProxy = true; |
| 1133 chrome.send('selectNetwork', [data.servicePath]); | 995 chrome.send('selectNetwork', [data.servicePath]); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 nameServerModels.push({value: nameServersUser[i] || ''}); | 1079 nameServerModels.push({value: nameServersUser[i] || ''}); |
| 1218 | 1080 |
| 1219 $(data.nameServerType + '-dns-radio').checked = true; | 1081 $(data.nameServerType + '-dns-radio').checked = true; |
| 1220 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); | 1082 configureAddressField($('ipconfig-dns1'), nameServerModels[0]); |
| 1221 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); | 1083 configureAddressField($('ipconfig-dns2'), nameServerModels[1]); |
| 1222 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); | 1084 configureAddressField($('ipconfig-dns3'), nameServerModels[2]); |
| 1223 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); | 1085 configureAddressField($('ipconfig-dns4'), nameServerModels[3]); |
| 1224 | 1086 |
| 1225 DetailsInternetPage.updateNameServerDisplay(data.nameServerType); | 1087 DetailsInternetPage.updateNameServerDisplay(data.nameServerType); |
| 1226 | 1088 |
| 1227 var macAddress = getManagedValue(data, 'MacAddress'); | 1089 var macAddress = onc.getActiveValue('MacAddress'); |
| 1228 if (macAddress) { | 1090 if (macAddress) { |
| 1229 $('hardware-address').textContent = macAddress; | 1091 $('hardware-address').textContent = macAddress; |
| 1230 $('hardware-address-row').style.display = 'table-row'; | 1092 $('hardware-address-row').style.display = 'table-row'; |
| 1231 } else { | 1093 } else { |
| 1232 // This is most likely a device without a hardware address. | 1094 // This is most likely a device without a hardware address. |
| 1233 $('hardware-address-row').style.display = 'none'; | 1095 $('hardware-address-row').style.display = 'none'; |
| 1234 } | 1096 } |
| 1235 | 1097 |
| 1236 var setOrHideParent = function(field, property) { | 1098 var setOrHideParent = function(field, property) { |
| 1237 if (property) { | 1099 if (property) { |
| 1238 $(field).textContent = property; | 1100 $(field).textContent = property; |
| 1239 $(field).parentElement.hidden = false; | 1101 $(field).parentElement.hidden = false; |
| 1240 } else { | 1102 } else { |
| 1241 $(field).parentElement.hidden = true; | 1103 $(field).parentElement.hidden = true; |
| 1242 } | 1104 } |
| 1243 }; | 1105 }; |
| 1244 | 1106 |
| 1245 var networkName = getNetworkName(data); | 1107 var networkName = onc.getTranslatedValue('Name'); |
| 1246 | 1108 |
| 1247 // Signal strength as percentage (for WiFi and Wimax). | 1109 // Signal strength as percentage (for WiFi and Wimax). |
| 1248 var signalStrength; | 1110 var signalStrength; |
| 1249 if (data.type == 'WiFi' || data.type == 'Wimax') { | 1111 if (onc.type == 'WiFi' || onc.type == 'Wimax') { |
| 1250 signalStrength = getManagedValue(data, data.type + '.SignalStrength'); | 1112 signalStrength = onc.getActiveValue(onc.type + '.SignalStrength'); |
| 1251 } | 1113 } |
| 1252 if (!signalStrength) | 1114 if (!signalStrength) |
| 1253 signalStrength = 0; | 1115 signalStrength = 0; |
| 1254 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); | 1116 var strengthFormat = loadTimeData.getString('inetSignalStrengthFormat'); |
| 1255 var strengthString = strengthFormat.replace('$1', signalStrength); | 1117 var strengthString = strengthFormat.replace('$1', signalStrength); |
| 1256 | 1118 |
| 1257 detailsPage.type = data.type; | 1119 detailsPage.type = onc.type; |
| 1258 if (data.type == 'WiFi') { | 1120 if (onc.type == 'WiFi') { |
| 1259 assert('WiFi' in data, 'WiFi network has no WiFi object' + networkName); | |
| 1260 OptionsPage.showTab($('wifi-network-nav-tab')); | 1121 OptionsPage.showTab($('wifi-network-nav-tab')); |
| 1261 detailsPage.gsm = false; | 1122 detailsPage.gsm = false; |
| 1262 detailsPage.shared = data.shared; | 1123 detailsPage.shared = data.shared; |
| 1263 $('wifi-connection-state').textContent = connectionStateString; | 1124 $('wifi-connection-state').textContent = connectionStateString; |
| 1264 var ssid = getManagedValue(data, 'WiFi.SSID'); | 1125 var ssid = onc.getActiveValue('WiFi.SSID'); |
| 1265 $('wifi-ssid').textContent = ssid ? ssid : networkName; | 1126 $('wifi-ssid').textContent = ssid ? ssid : networkName; |
| 1266 setOrHideParent('wifi-bssid', getManagedValue(data, 'WiFi.BSSID')); | 1127 setOrHideParent('wifi-bssid', onc.getActiveValue('WiFi.BSSID')); |
| 1267 var security = getManagedValue(data, 'WiFi.Security'); | 1128 var security = onc.getActiveValue('WiFi.Security'); |
| 1268 if (security == 'None') | 1129 if (security == 'None') |
| 1269 security = undefined; | 1130 security = undefined; |
| 1270 setOrHideParent('wifi-security', security); | 1131 setOrHideParent('wifi-security', security); |
| 1271 // Frequency is in MHz. | 1132 // Frequency is in MHz. |
| 1272 var frequency = getManagedValue(data, 'WiFi.Frequency'); | 1133 var frequency = onc.getActiveValue('WiFi.Frequency'); |
| 1273 if (!frequency) | 1134 if (!frequency) |
| 1274 frequency = 0; | 1135 frequency = 0; |
| 1275 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); | 1136 var frequencyFormat = loadTimeData.getString('inetFrequencyFormat'); |
| 1276 frequencyFormat = frequencyFormat.replace('$1', frequency); | 1137 frequencyFormat = frequencyFormat.replace('$1', frequency); |
| 1277 $('wifi-frequency').textContent = frequencyFormat; | 1138 $('wifi-frequency').textContent = frequencyFormat; |
| 1278 $('wifi-signal-strength').textContent = strengthString; | 1139 $('wifi-signal-strength').textContent = strengthString; |
| 1279 setOrHideParent('wifi-hardware-address', | 1140 setOrHideParent('wifi-hardware-address', |
| 1280 getManagedValue(data, 'MacAddress')); | 1141 onc.getActiveValue('MacAddress')); |
| 1281 detailsPage.showPreferred = data.remembered; | 1142 detailsPage.showPreferred = data.remembered; |
| 1282 var priority = getManagedValue(data, 'Priority'); | 1143 var priority = onc.getActiveValue('Priority'); |
| 1283 $('prefer-network-wifi').checked = priority > 0; | 1144 $('prefer-network-wifi').checked = priority > 0; |
| 1284 $('prefer-network-wifi').disabled = !data.remembered; | 1145 $('prefer-network-wifi').disabled = !data.remembered; |
| 1285 $('auto-connect-network-wifi').checked = | 1146 $('auto-connect-network-wifi').checked = |
| 1286 getManagedValue(data, 'AutoConnect'); | 1147 onc.getActiveValue('AutoConnect'); |
| 1287 $('auto-connect-network-wifi').disabled = !data.remembered; | 1148 $('auto-connect-network-wifi').disabled = !data.remembered; |
| 1288 detailsPage.hasSecurity = security != undefined; | 1149 detailsPage.hasSecurity = security != undefined; |
| 1289 } else if (data.type == 'Wimax') { | 1150 } else if (onc.type == 'Wimax') { |
| 1290 assert('Wimax' in data, | |
| 1291 'Wimax network has no Wimax object' + networkName); | |
| 1292 OptionsPage.showTab($('wimax-network-nav-tab')); | 1151 OptionsPage.showTab($('wimax-network-nav-tab')); |
| 1293 detailsPage.gsm = false; | 1152 detailsPage.gsm = false; |
| 1294 detailsPage.shared = data.shared; | 1153 detailsPage.shared = data.shared; |
| 1295 detailsPage.showPreferred = data.remembered; | 1154 detailsPage.showPreferred = data.remembered; |
| 1296 $('wimax-connection-state').textContent = connectionStateString; | 1155 $('wimax-connection-state').textContent = connectionStateString; |
| 1297 $('auto-connect-network-wimax').checked = | 1156 $('auto-connect-network-wimax').checked = |
| 1298 getManagedValue(data, 'AutoConnect'); | 1157 onc.getActiveValue('AutoConnect'); |
| 1299 $('auto-connect-network-wimax').disabled = !data.remembered; | 1158 $('auto-connect-network-wimax').disabled = !data.remembered; |
| 1300 var identity; | 1159 var identity = onc.getActiveValue('Wimax.EAP.Identity'); |
| 1301 if (data.Wimax.EAP) | |
| 1302 identity = getManagedValue(data.Wimax.EAP, 'Identity'); | |
| 1303 setOrHideParent('wimax-eap-identity', identity); | 1160 setOrHideParent('wimax-eap-identity', identity); |
| 1304 $('wimax-signal-strength').textContent = strengthString; | 1161 $('wimax-signal-strength').textContent = strengthString; |
| 1305 } else if (data.type == 'Cellular') { | 1162 } else if (onc.type == 'Cellular') { |
| 1306 assert('Cellular' in data, | |
| 1307 'Cellular network has no Cellular object' + networkName); | |
| 1308 OptionsPage.showTab($('cellular-conn-nav-tab')); | 1163 OptionsPage.showTab($('cellular-conn-nav-tab')); |
| 1309 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { | 1164 if (data.showCarrierSelect && data.currentCarrierIndex != -1) { |
| 1310 var carrierSelector = $('select-carrier'); | 1165 var carrierSelector = $('select-carrier'); |
| 1311 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; | 1166 carrierSelector.onchange = DetailsInternetPage.handleCarrierChanged; |
| 1312 carrierSelector.options.length = 0; | 1167 carrierSelector.options.length = 0; |
| 1313 for (var i = 0; i < data.carriers.length; ++i) { | 1168 for (var i = 0; i < data.carriers.length; ++i) { |
| 1314 var option = document.createElement('option'); | 1169 var option = document.createElement('option'); |
| 1315 option.textContent = data.carriers[i]; | 1170 option.textContent = data.carriers[i]; |
| 1316 carrierSelector.add(option); | 1171 carrierSelector.add(option); |
| 1317 } | 1172 } |
| 1318 carrierSelector.selectedIndex = data.currentCarrierIndex; | 1173 carrierSelector.selectedIndex = data.currentCarrierIndex; |
| 1319 } else { | 1174 } else { |
| 1320 $('service-name').textContent = networkName; | 1175 $('service-name').textContent = networkName; |
| 1321 } | 1176 } |
| 1322 | 1177 |
| 1323 $('network-technology').textContent = | 1178 $('network-technology').textContent = |
| 1324 getManagedValue(data, 'Cellular.NetworkTechnology'); | 1179 onc.getActiveValue('Cellular.NetworkTechnology'); |
| 1325 $('activation-state').textContent = data.activationState; | 1180 $('activation-state').textContent = data.activationState; |
| 1326 $('roaming-state').textContent = data.roamingState; | 1181 $('roaming-state').textContent = data.roamingState; |
| 1327 $('restricted-pool').textContent = data.restrictedPool; | 1182 $('restricted-pool').textContent = data.restrictedPool; |
| 1328 $('error-state').textContent = data.errorMessage; | 1183 $('error-state').textContent = data.errorMessage; |
| 1329 $('manufacturer').textContent = | 1184 $('manufacturer').textContent = |
| 1330 getManagedValue(data, 'Cellular.Manufacturer'); | 1185 onc.getActiveValue('Cellular.Manufacturer'); |
| 1331 $('model-id').textContent = getManagedValue(data, 'Cellular.ModelID'); | 1186 $('model-id').textContent = onc.getActiveValue('Cellular.ModelID'); |
| 1332 $('firmware-revision').textContent = | 1187 $('firmware-revision').textContent = |
| 1333 getManagedValue(data, 'Cellular.FirmwareRevision'); | 1188 onc.getActiveValue('Cellular.FirmwareRevision'); |
| 1334 $('hardware-revision').textContent = | 1189 $('hardware-revision').textContent = |
| 1335 getManagedValue(data, 'Cellular.HardwareRevision'); | 1190 onc.getActiveValue('Cellular.HardwareRevision'); |
| 1336 $('mdn').textContent = getManagedValue(data, 'Cellular.MDN'); | 1191 $('mdn').textContent = onc.getActiveValue('Cellular.MDN'); |
| 1337 | 1192 |
| 1338 // Show ServingOperator properties only if available. | 1193 // Show ServingOperator properties only if available. |
| 1339 var servingOperatorName = | 1194 var servingOperatorName = |
| 1340 getManagedValue(data, 'Cellular.ServingOperator.Name'); | 1195 onc.getActiveValue('Cellular.ServingOperator.Name'); |
| 1341 var servingOperatorCode = | 1196 var servingOperatorCode = |
| 1342 getManagedValue(data, 'Cellular.ServingOperator.Code'); | 1197 onc.getActiveValue('Cellular.ServingOperator.Code'); |
| 1343 if (servingOperatorName != undefined && | 1198 if (servingOperatorName != undefined && |
| 1344 servingOperatorCode != undefined) { | 1199 servingOperatorCode != undefined) { |
| 1345 $('operator-name').textContent = servingOperatorName; | 1200 $('operator-name').textContent = servingOperatorName; |
| 1346 $('operator-code').textContent = servingOperatorCode; | 1201 $('operator-code').textContent = servingOperatorCode; |
| 1347 } else { | 1202 } else { |
| 1348 $('operator-name').parentElement.hidden = true; | 1203 $('operator-name').parentElement.hidden = true; |
| 1349 $('operator-code').parentElement.hidden = true; | 1204 $('operator-code').parentElement.hidden = true; |
| 1350 } | 1205 } |
| 1351 // Make sure that GSM/CDMA specific properties that shouldn't be hidden | 1206 // Make sure that GSM/CDMA specific properties that shouldn't be hidden |
| 1352 // are visible. | 1207 // are visible. |
| 1353 updateHidden('#details-internet-page .gsm-only', false); | 1208 updateHidden('#details-internet-page .gsm-only', false); |
| 1354 updateHidden('#details-internet-page .cdma-only', false); | 1209 updateHidden('#details-internet-page .cdma-only', false); |
| 1355 | 1210 |
| 1356 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. | 1211 // Show IMEI/ESN/MEID/MIN/PRL only if they are available. |
| 1357 setOrHideParent('esn', getManagedValue(data, 'Cellular.ESN')); | 1212 setOrHideParent('esn', onc.getActiveValue('Cellular.ESN')); |
| 1358 setOrHideParent('imei', getManagedValue(data, 'Cellular.IMEI')); | 1213 setOrHideParent('imei', onc.getActiveValue('Cellular.IMEI')); |
| 1359 setOrHideParent('meid', getManagedValue(data, 'Cellular.MEID')); | 1214 setOrHideParent('meid', onc.getActiveValue('Cellular.MEID')); |
| 1360 setOrHideParent('min', getManagedValue(data, 'Cellular.MIN')); | 1215 setOrHideParent('min', onc.getActiveValue('Cellular.MIN')); |
| 1361 setOrHideParent('prl-version', | 1216 setOrHideParent('prl-version', onc.getActiveValue('Cellular.PRLVersion')); |
| 1362 getManagedValue(data, 'Cellular.PRLVersion')); | |
| 1363 | 1217 |
| 1364 var family = getManagedValue(data, 'Cellular.Family'); | 1218 var family = onc.getActiveValue('Cellular.Family'); |
| 1365 detailsPage.gsm = family == 'GSM'; | 1219 detailsPage.gsm = family == 'GSM'; |
| 1366 if (detailsPage.gsm) { | 1220 if (detailsPage.gsm) { |
| 1367 $('iccid').textContent = getManagedValue(data, 'Cellular.ICCID'); | 1221 $('iccid').textContent = onc.getActiveValue('Cellular.ICCID'); |
| 1368 $('imsi').textContent = getManagedValue(data, 'Cellular.IMSI'); | 1222 $('imsi').textContent = onc.getActiveValue('Cellular.IMSI'); |
| 1369 | 1223 |
| 1370 var apnSelector = $('select-apn'); | 1224 var apnSelector = $('select-apn'); |
| 1371 // Clear APN lists, keep only last element that "other". | 1225 // Clear APN lists, keep only last element that "other". |
| 1372 while (apnSelector.length != 1) | 1226 while (apnSelector.length != 1) |
| 1373 apnSelector.remove(0); | 1227 apnSelector.remove(0); |
| 1374 var otherOption = apnSelector[0]; | 1228 var otherOption = apnSelector[0]; |
| 1375 data.selectedApn = -1; | 1229 data.selectedApn = -1; |
| 1376 data.userApnIndex = -1; | 1230 data.userApnIndex = -1; |
| 1377 var activeApn = getManagedValue(data, 'Cellular.APN'); | 1231 var activeApn = onc.getActiveValue('Cellular.APN'); |
| 1378 var lastGoodApn = getManagedValue(data, 'Cellular.LastGoodAPN'); | 1232 var lastGoodApn = onc.getActiveValue('Cellular.LastGoodAPN'); |
| 1379 var apnList = getManagedValue(data, 'Cellular.APNList'); | 1233 var apnList = onc.getActiveValue('Cellular.APNList'); |
| 1380 for (var i = 0; i < apnList.length; i++) { | 1234 for (var i = 0; i < apnList.length; i++) { |
| 1381 var apnDict = apnList[i]; | 1235 var apnDict = apnList[i]; |
| 1382 var option = document.createElement('option'); | 1236 var option = document.createElement('option'); |
| 1383 var localizedName = apnDict['LocalizedName']; | 1237 var localizedName = apnDict['LocalizedName']; |
| 1384 var name = localizedName ? localizedName : apnDict['Name']; | 1238 var name = localizedName ? localizedName : apnDict['Name']; |
| 1385 var accessPointName = apnDict['AccessPointName']; | 1239 var accessPointName = apnDict['AccessPointName']; |
| 1386 option.textContent = | 1240 option.textContent = |
| 1387 name ? (name + ' (' + accessPointName + ')') : accessPointName; | 1241 name ? (name + ' (' + accessPointName + ')') : accessPointName; |
| 1388 option.value = i; | 1242 option.value = i; |
| 1389 // If this matches the active Apn, or LastGoodApn, set it as the | 1243 // If this matches the active Apn, or LastGoodApn, set it as the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1408 option.textContent = activeApn['AccessPointName']; | 1262 option.textContent = activeApn['AccessPointName']; |
| 1409 option.value = -1; | 1263 option.value = -1; |
| 1410 apnSelector.add(option, otherOption); | 1264 apnSelector.add(option, otherOption); |
| 1411 data.selectedApn = apnSelector.length - 2; | 1265 data.selectedApn = apnSelector.length - 2; |
| 1412 data.userApnIndex = data.selectedApn; | 1266 data.userApnIndex = data.selectedApn; |
| 1413 } | 1267 } |
| 1414 apnSelector.selectedIndex = data.selectedApn; | 1268 apnSelector.selectedIndex = data.selectedApn; |
| 1415 updateHidden('.apn-list-view', false); | 1269 updateHidden('.apn-list-view', false); |
| 1416 updateHidden('.apn-details-view', true); | 1270 updateHidden('.apn-details-view', true); |
| 1417 var lockEnabled = | 1271 var lockEnabled = |
| 1418 getManagedValue(data, 'Cellular.SIMLockStatus.LockEnabled'); | 1272 onc.getActiveValue('Cellular.SIMLockStatus.LockEnabled'); |
| 1419 $('sim-card-lock-enabled').checked = lockEnabled; | 1273 $('sim-card-lock-enabled').checked = lockEnabled; |
| 1420 $('change-pin').hidden = !lockEnabled; | 1274 $('change-pin').hidden = !lockEnabled; |
| 1421 } | 1275 } |
| 1422 $('auto-connect-network-cellular').checked = | 1276 $('auto-connect-network-cellular').checked = |
| 1423 getManagedValue(data, 'AutoConnect'); | 1277 onc.getActiveValue('AutoConnect'); |
| 1424 $('auto-connect-network-cellular').disabled = false; | 1278 $('auto-connect-network-cellular').disabled = false; |
| 1425 | 1279 |
| 1426 $('buyplan-details').hidden = !data.showBuyButton; | 1280 $('buyplan-details').hidden = !data.showBuyButton; |
| 1427 $('view-account-details').hidden = !data.showViewAccountButton; | 1281 $('view-account-details').hidden = !data.showViewAccountButton; |
| 1428 $('activate-details').hidden = !data.showActivateButton; | 1282 $('activate-details').hidden = !data.showActivateButton; |
| 1429 if (data.showActivateButton) { | 1283 if (data.showActivateButton) { |
| 1430 $('details-internet-login').hidden = true; | 1284 $('details-internet-login').hidden = true; |
| 1431 } | 1285 } |
| 1432 } else if (data.type == 'VPN') { | 1286 } else if (onc.type == 'VPN') { |
| 1433 OptionsPage.showTab($('vpn-nav-tab')); | 1287 OptionsPage.showTab($('vpn-nav-tab')); |
| 1434 detailsPage.gsm = false; | 1288 detailsPage.gsm = false; |
| 1435 $('inet-service-name').textContent = networkName; | 1289 $('inet-service-name').textContent = networkName; |
| 1436 $('inet-provider-type').textContent = | 1290 $('inet-provider-type').textContent = |
| 1437 getManagedValue(data, 'VPN.Type', GetManagedTypes.TRANSLATED); | 1291 onc.getTranslatedValue('VPN.Type'); |
| 1438 var providerType = | 1292 var providerType = onc.getActiveValue('VPN.Type'); |
| 1439 getManagedValue(data, 'VPN.Type', GetManagedTypes.ACTIVE); | |
| 1440 var providerKey = 'VPN.' + providerType; | 1293 var providerKey = 'VPN.' + providerType; |
| 1441 $('inet-username').textContent = | 1294 $('inet-username').textContent = |
| 1442 getManagedValue(data, providerKey + '.Username'); | 1295 onc.getActiveValue(providerKey + '.Username'); |
| 1443 var inetServerHostname = $('inet-server-hostname'); | 1296 var inetServerHostname = $('inet-server-hostname'); |
| 1444 inetServerHostname.value = getManagedValue(data, 'VPN.Host'); | 1297 inetServerHostname.value = onc.getActiveValue('VPN.Host'); |
| 1445 inetServerHostname.resetHandler = function() { | 1298 inetServerHostname.resetHandler = function() { |
| 1446 PageManager.hideBubble(); | 1299 PageManager.hideBubble(); |
| 1447 var recommended = | 1300 var recommended = onc.getRecommendedValue('VPN.Host'); |
| 1448 getManagedValue(data, 'VPN.Host', GetManagedTypes.RECOMMENDED); | |
| 1449 if (recommended != undefined) | 1301 if (recommended != undefined) |
| 1450 inetServerHostname.value = recommended; | 1302 inetServerHostname.value = recommended; |
| 1451 }; | 1303 }; |
| 1452 $('auto-connect-network-vpn').checked = | 1304 $('auto-connect-network-vpn').checked = |
| 1453 getManagedValue(data, 'AutoConnect'); | 1305 onc.getActiveValue('AutoConnect'); |
| 1454 $('auto-connect-network-vpn').disabled = false; | 1306 $('auto-connect-network-vpn').disabled = false; |
| 1455 } else { | 1307 } else { |
| 1456 OptionsPage.showTab($('internet-nav-tab')); | 1308 OptionsPage.showTab($('internet-nav-tab')); |
| 1457 } | 1309 } |
| 1458 | 1310 |
| 1459 // Update controlled option indicators. | 1311 // Update controlled option indicators. |
| 1460 var indicators = cr.doc.querySelectorAll( | 1312 var indicators = cr.doc.querySelectorAll( |
| 1461 '#details-internet-page .controlled-setting-indicator'); | 1313 '#details-internet-page .controlled-setting-indicator'); |
| 1462 for (var i = 0; i < indicators.length; i++) { | 1314 for (var i = 0; i < indicators.length; i++) { |
| 1463 var managed = indicators[i].hasAttribute('managed'); | 1315 var managed = indicators[i].hasAttribute('managed'); |
| 1464 var attributeName = managed ? 'managed' : 'data'; | 1316 var attributeName = managed ? 'managed' : 'data'; |
| 1465 var propName = indicators[i].getAttribute(attributeName); | 1317 var propName = indicators[i].getAttribute(attributeName); |
| 1466 if (!propName) | 1318 if (!propName) |
| 1467 continue; | 1319 continue; |
| 1468 var propValue = | 1320 var propValue = managed ? |
| 1469 managed ? getManagedProperty(data, propName) : data[propName]; | 1321 onc.getManagedProperty(propName) : |
| 1322 onc.getActiveValue(propName); |
| 1470 if (propValue == undefined) | 1323 if (propValue == undefined) |
| 1471 continue; | 1324 continue; |
| 1472 var event; | 1325 var event; |
| 1473 if (managed) | 1326 if (managed) |
| 1474 event = detailsPage.createManagedEvent_(propName, propValue); | 1327 event = detailsPage.createManagedEvent_(propName, propValue); |
| 1475 else | 1328 else |
| 1476 event = detailsPage.createControlledEvent_(propName, propValue); | 1329 event = detailsPage.createControlledEvent_(propName, propValue); |
| 1477 indicators[i].handlePrefChange(event); | 1330 indicators[i].handlePrefChange(event); |
| 1478 var forElement = $(indicators[i].getAttribute('for')); | 1331 var forElement = $(indicators[i].getAttribute('for')); |
| 1479 if (forElement) { | 1332 if (forElement) { |
| 1480 if (event.value.controlledBy == 'policy') | 1333 if (event.value.controlledBy == 'policy') |
| 1481 forElement.disabled = true; | 1334 forElement.disabled = true; |
| 1482 if (forElement.resetHandler) | 1335 if (forElement.resetHandler) |
| 1483 indicators[i].resetHandler = forElement.resetHandler; | 1336 indicators[i].resetHandler = forElement.resetHandler; |
| 1484 } | 1337 } |
| 1485 } | 1338 } |
| 1486 | 1339 |
| 1487 detailsPage.updateControls(); | 1340 detailsPage.updateControls(); |
| 1488 | 1341 |
| 1489 // Don't show page name in address bar and in history to prevent people | 1342 // Don't show page name in address bar and in history to prevent people |
| 1490 // navigate here by hand and solve issue with page session restore. | 1343 // navigate here by hand and solve issue with page session restore. |
| 1491 PageManager.showPageByName('detailsInternetPage', false); | 1344 PageManager.showPageByName('detailsInternetPage', false); |
| 1492 }; | 1345 }; |
| 1493 | 1346 |
| 1494 return { | 1347 return { |
| 1495 DetailsInternetPage: DetailsInternetPage | 1348 DetailsInternetPage: DetailsInternetPage |
| 1496 }; | 1349 }; |
| 1497 }); | 1350 }); |
| OLD | NEW |