| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 Polymer element for displaying and editing network proxy | 6 * @fileoverview Polymer element for displaying and editing network proxy |
| 7 * values. | 7 * values. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'network-proxy', | 10 is: 'network-proxy', |
| 11 | 11 |
| 12 behaviors: [CrPolicyNetworkBehavior], | 12 behaviors: [I18nBehavior, CrPolicyNetworkBehavior], |
| 13 | 13 |
| 14 properties: { | 14 properties: { |
| 15 /** | 15 /** |
| 16 * The network properties dictionary containing the proxy properties to | 16 * The network properties dictionary containing the proxy properties to |
| 17 * display and modify. | 17 * display and modify. |
| 18 * @type {!CrOnc.NetworkProperties|undefined} | 18 * @type {!CrOnc.NetworkProperties|undefined} |
| 19 */ | 19 */ |
| 20 networkProperties: { | 20 networkProperties: { |
| 21 type: Object, | 21 type: Object, |
| 22 observer: 'networkPropertiesChanged_', | 22 observer: 'networkPropertiesChanged_', |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 */ | 248 */ |
| 249 onProxyExclusionsChange_: function(event) { | 249 onProxyExclusionsChange_: function(event) { |
| 250 this.sendProxyChange_(); | 250 this.sendProxyChange_(); |
| 251 }, | 251 }, |
| 252 | 252 |
| 253 /** | 253 /** |
| 254 * @param {string} proxyType The proxy type. | 254 * @param {string} proxyType The proxy type. |
| 255 * @return {string} The description for |proxyType|. | 255 * @return {string} The description for |proxyType|. |
| 256 * @private | 256 * @private |
| 257 */ | 257 */ |
| 258 proxyTypeDesc_: function(proxyType) { | 258 getProxyTypeDesc_: function(proxyType) { |
| 259 // TODO(stevenjb): Translate. | |
| 260 if (proxyType == CrOnc.ProxySettingsType.MANUAL) | 259 if (proxyType == CrOnc.ProxySettingsType.MANUAL) |
| 261 return 'Manual proxy configuration'; | 260 return this.i18n('networkProxyTypeManual'); |
| 262 if (proxyType == CrOnc.ProxySettingsType.PAC) | 261 if (proxyType == CrOnc.ProxySettingsType.PAC) |
| 263 return 'Automatic proxy configuration'; | 262 return this.i18n('networkProxyTypePac'); |
| 264 if (proxyType == CrOnc.ProxySettingsType.WPAD) | 263 if (proxyType == CrOnc.ProxySettingsType.WPAD) |
| 265 return 'Web proxy autodiscovery'; | 264 return this.i18n('networkProxyTypeWpad'); |
| 266 return 'Direct Internet connection'; | 265 return this.i18n('networkProxyTypeDirect'); |
| 267 }, | 266 }, |
| 268 | 267 |
| 269 /** | 268 /** |
| 269 * @param {!CrOnc.ManagedProperty|undefined} property |
| 270 * @return {string} The string describing the policy controlling |property|. |
| 271 * @private |
| 272 */ |
| 273 getEnforcedString_: function(property) { |
| 274 if (this.isExtensionControlled(property)) |
| 275 return this.i18n('networkProxyControlledExtension'); |
| 276 if (this.isNetworkPolicyEnforced(property)) |
| 277 return this.i18n('networkProxyEnforcedPolicy'); |
| 278 return ''; |
| 279 }, |
| 280 |
| 281 /** |
| 270 * @param {boolean} editable | 282 * @param {boolean} editable |
| 271 * @param {!CrOnc.NetworkProperties} networkProperties | 283 * @param {!CrOnc.NetworkProperties} networkProperties |
| 272 * @param {string} key | 284 * @param {string} key |
| 273 * @return {boolean} Whether the property is editable. | 285 * @return {boolean} Whether the property is editable. |
| 274 * @private | 286 * @private |
| 275 */ | 287 */ |
| 276 isPropertyEditable_: function(editable, networkProperties, key) { | 288 isPropertyEditable_: function(editable, networkProperties, key) { |
| 277 if (!editable) | 289 if (!editable) |
| 278 return false; | 290 return false; |
| 279 var property = /** @type {!CrOnc.ManagedProperty|undefined} */ ( | 291 var property = /** @type {!CrOnc.ManagedProperty|undefined} */ ( |
| 280 this.get(key, networkProperties)); | 292 this.get(key, networkProperties)); |
| 281 return !this.isNetworkPolicyEnforced(property); | 293 return !this.isNetworkPolicyEnforced(property); |
| 282 }, | 294 }, |
| 283 | 295 |
| 284 /** | 296 /** |
| 297 * @return {boolean} Whether changing the proxy type should be disabled. |
| 298 * @private |
| 299 */ |
| 300 isProxyTypeDisabled_: function() { |
| 301 var proxySettings = this.networkProperties.ProxySettings; |
| 302 return !!proxySettings && this.isEnforced_(proxySettings.Type); |
| 303 }, |
| 304 |
| 305 /** |
| 306 * @param {!CrOnc.ManagedProperty|undefined} property |
| 307 * @return {boolean} Whether the property setting is enforced. |
| 308 * @private |
| 309 */ |
| 310 isEnforced_: function(property) { |
| 311 return this.isNetworkPolicyEnforced(property) || |
| 312 this.isExtensionControlled(property); |
| 313 }, |
| 314 |
| 315 /** |
| 285 * @param {string} property The property to test | 316 * @param {string} property The property to test |
| 286 * @param {string} value The value to test against | 317 * @param {string} value The value to test against |
| 287 * @return {boolean} True if property == value | 318 * @return {boolean} True if property == value |
| 288 * @private | 319 * @private |
| 289 */ | 320 */ |
| 290 matches_: function(property, value) { | 321 matches_: function(property, value) { |
| 291 return property == value; | 322 return property == value; |
| 292 } | 323 } |
| 293 }); | 324 }); |
| OLD | NEW |