Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @fileoverview ONC Data support class. Wraps a dictionary object containing | 6 * @fileoverview ONC Data support class. Wraps a dictionary object containing |
| 7 * ONC managed or unmanaged dictionaries. Supports nested dictionaries, | 7 * ONC managed or unmanaged dictionaries. Supports nested dictionaries, |
| 8 * e.g. data.getManagedProperty('VPN.Type'). | 8 * e.g. data.getManagedProperty('VPN.Type'). |
| 9 */ | 9 */ |
| 10 cr.define('cr.onc', function() { | 10 cr.define('cr.onc', function() { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 }, | 93 }, |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * Gets the translated ONC value from the result of getActiveValue() using | 96 * Gets the translated ONC value from the result of getActiveValue() using |
| 97 * loadTimeData. If no translation exists, returns the untranslated value. | 97 * loadTimeData. If no translation exists, returns the untranslated value. |
| 98 * @param {string} key The property key. | 98 * @param {string} key The property key. |
| 99 * @return {*} The translation if available or the value if not. | 99 * @return {*} The translation if available or the value if not. |
| 100 */ | 100 */ |
| 101 getTranslatedValue: function(key) { | 101 getTranslatedValue: function(key) { |
| 102 var value = this.getActiveValue(key); | 102 var value = this.getActiveValue(key); |
| 103 if (typeof value != 'string') | 103 if (typeof value == 'boolean') |
| 104 value = value ? 'True' : 'False'; | |
|
pneubeck (no reviews)
2014/09/05 16:05:44
this could always map to the translation of 'True'
stevenjb
2014/09/05 16:54:21
Sometimes we may want to map 'True' -> "True", oth
| |
| 105 else if (typeof value != 'string') | |
| 104 return value; | 106 return value; |
|
pneubeck (no reviews)
2014/09/05 16:05:44
nit: to prevent surprises, maybe convert |value| t
stevenjb
2014/09/05 16:54:21
Until/unless we have a situation where we wanted t
| |
| 105 var oncString = 'Onc' + key + value; | 107 var oncString = 'Onc' + key + value; |
| 106 // Handle special cases | 108 // Handle special cases |
| 107 if (key == 'Name' && this.type == 'Ethernet') | 109 if (key == 'Name' && this.type == 'Ethernet') |
| 108 return loadTimeData.getString('ethernetName'); | 110 return loadTimeData.getString('ethernetName'); |
| 109 if (key == 'VPN.Type' && value == 'L2TP-IPsec') { | 111 if (key == 'VPN.Type' && value == 'L2TP-IPsec') { |
| 110 var auth = this.getActiveValue('VPN.IPsec.AuthenticationType'); | 112 var auth = this.getActiveValue('VPN.IPsec.AuthenticationType'); |
| 111 if (auth != undefined) | 113 if (auth != undefined) |
| 112 oncString += auth; | 114 oncString += auth; |
| 113 } | 115 } |
| 114 oncString = oncString.replace(/\./g, '-'); | 116 oncString = oncString.replace(/\./g, '-'); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 return property[effective]; | 149 return property[effective]; |
| 148 } | 150 } |
| 149 return undefined; | 151 return undefined; |
| 150 } | 152 } |
| 151 }; | 153 }; |
| 152 | 154 |
| 153 return { | 155 return { |
| 154 OncData: OncData | 156 OncData: OncData |
| 155 }; | 157 }; |
| 156 }); | 158 }); |
| OLD | NEW |