| 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: [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_', |
| 23 }, | 23 }, |
| 24 | 24 |
| 25 /** | 25 /** Whether or not the proxy values can be edited. */ |
| 26 * Whether or not the proxy values can be edited. | |
| 27 */ | |
| 28 editable: { | 26 editable: { |
| 29 type: Boolean, | 27 type: Boolean, |
| 30 value: false, | 28 value: false, |
| 31 }, | 29 }, |
| 32 | 30 |
| 33 /** | 31 /** |
| 34 * UI visible / edited proxy configuration. | 32 * UI visible / edited proxy configuration. |
| 35 * @type {!CrOnc.ProxySettings} | 33 * @type {!CrOnc.ProxySettings} |
| 36 */ | 34 */ |
| 37 proxy: { | 35 proxy: { |
| 38 type: Object, | 36 type: Object, |
| 39 value: function() { | 37 value: function() { |
| 40 return this.createDefaultProxySettings_(); | 38 return this.createDefaultProxySettings_(); |
| 41 }, | 39 }, |
| 42 }, | 40 }, |
| 43 | 41 |
| 44 /** | 42 /** The Web Proxy Auto Discovery URL extracted from networkProperties. */ |
| 45 * The Web Proxy Auto Discovery URL extracted from networkProperties. | |
| 46 */ | |
| 47 WPAD: { | 43 WPAD: { |
| 48 type: String, | 44 type: String, |
| 49 value: '', | 45 value: '', |
| 50 }, | 46 }, |
| 51 | 47 |
| 52 /** | 48 /** |
| 53 * Whetner or not to use the same manual proxy for all protocols. | 49 * Whether or not to use the same manual proxy for all protocols. |
| 50 * @private |
| 54 */ | 51 */ |
| 55 useSameProxy: { | 52 useSameProxy_: { |
| 56 type: Boolean, | 53 type: Boolean, |
| 57 value: false, | 54 value: false, |
| 58 observer: 'useSameProxyChanged_', | 55 observer: 'useSameProxyChanged_', |
| 59 }, | 56 }, |
| 60 | 57 |
| 61 /** | 58 /** |
| 62 * Array of proxy configuration types. | 59 * Array of proxy configuration types. |
| 63 * @type {!Array<string>} | 60 * @private {!Array<string>} |
| 64 * @const | 61 * @const |
| 65 */ | 62 */ |
| 66 proxyTypes_: { | 63 proxyTypes_: { |
| 67 type: Array, | 64 type: Array, |
| 68 value: [ | 65 value: [ |
| 69 CrOnc.ProxySettingsType.DIRECT, | 66 CrOnc.ProxySettingsType.DIRECT, |
| 70 CrOnc.ProxySettingsType.PAC, | 67 CrOnc.ProxySettingsType.PAC, |
| 71 CrOnc.ProxySettingsType.WPAD, | 68 CrOnc.ProxySettingsType.WPAD, |
| 72 CrOnc.ProxySettingsType.MANUAL, | 69 CrOnc.ProxySettingsType.MANUAL, |
| 73 ], | 70 ], |
| 74 readOnly: true | 71 readOnly: true |
| 75 }, | 72 }, |
| 76 | 73 |
| 77 /** | 74 /** |
| 78 * Object providing proxy type values for data binding. | 75 * Object providing proxy type values for data binding. |
| 79 * @type {!Object} | 76 * @private {!Object} |
| 80 * @const | 77 * @const |
| 81 */ | 78 */ |
| 82 ProxySettingsType: { | 79 ProxySettingsType_: { |
| 83 type: Object, | 80 type: Object, |
| 84 value: { | 81 value: { |
| 85 DIRECT: CrOnc.ProxySettingsType.DIRECT, | 82 DIRECT: CrOnc.ProxySettingsType.DIRECT, |
| 86 PAC: CrOnc.ProxySettingsType.PAC, | 83 PAC: CrOnc.ProxySettingsType.PAC, |
| 87 MANUAL: CrOnc.ProxySettingsType.MANUAL, | 84 MANUAL: CrOnc.ProxySettingsType.MANUAL, |
| 88 WPAD: CrOnc.ProxySettingsType.WPAD, | 85 WPAD: CrOnc.ProxySettingsType.WPAD, |
| 89 }, | 86 }, |
| 90 readOnly: true, | 87 readOnly: true, |
| 91 }, | 88 }, |
| 92 }, | 89 }, |
| 93 | 90 |
| 94 /** | 91 /** |
| 95 * Saved Manual properties so that switching to another type does not loose | 92 * Saved Manual properties so that switching to another type does not loose |
| 96 * any set properties while the UI is open. | 93 * any set properties while the UI is open. |
| 97 * @type {!CrOnc.ManualProxySettings|undefined} | 94 * @private {!CrOnc.ManualProxySettings|undefined} |
| 98 */ | 95 */ |
| 99 savedManual_: undefined, | 96 savedManual_: undefined, |
| 100 | 97 |
| 101 /** | 98 /** |
| 102 * Saved ExcludeDomains properties so that switching to a non-Manual type does | 99 * Saved ExcludeDomains properties so that switching to a non-Manual type does |
| 103 * not loose any set exclusions while the UI is open. | 100 * not loose any set exclusions while the UI is open. |
| 104 * @type {!Array<string>|undefined} | 101 * @private {!Array<string>|undefined} |
| 105 */ | 102 */ |
| 106 savedExcludeDomains_: undefined, | 103 savedExcludeDomains_: undefined, |
| 107 | 104 |
| 108 /** | 105 /** |
| 109 * Polymer networkProperties changed method. | 106 * Polymer networkProperties changed method. |
| 110 */ | 107 */ |
| 111 networkPropertiesChanged_: function() { | 108 networkPropertiesChanged_: function() { |
| 112 if (!this.networkProperties) | 109 if (!this.networkProperties) |
| 113 return; | 110 return; |
| 114 | 111 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 /** | 174 /** |
| 178 * Called when the proxy changes in the UI. | 175 * Called when the proxy changes in the UI. |
| 179 */ | 176 */ |
| 180 sendProxyChange_: function() { | 177 sendProxyChange_: function() { |
| 181 if (this.proxy.Type == CrOnc.ProxySettingsType.MANUAL) { | 178 if (this.proxy.Type == CrOnc.ProxySettingsType.MANUAL) { |
| 182 var proxy = | 179 var proxy = |
| 183 /** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy)); | 180 /** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy)); |
| 184 var defaultProxy = proxy.Manual.HTTPProxy; | 181 var defaultProxy = proxy.Manual.HTTPProxy; |
| 185 if (!defaultProxy || !defaultProxy.Host) | 182 if (!defaultProxy || !defaultProxy.Host) |
| 186 return; | 183 return; |
| 187 if (this.useSameProxy || !proxy.Manual.SecureHTTPProxy) { | 184 if (this.useSameProxy_ || !proxy.Manual.SecureHTTPProxy) { |
| 188 proxy.Manual.SecureHTTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( | 185 proxy.Manual.SecureHTTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( |
| 189 Object.assign({}, defaultProxy)); | 186 Object.assign({}, defaultProxy)); |
| 190 } | 187 } |
| 191 if (this.useSameProxy || !proxy.Manual.FTPProxy) { | 188 if (this.useSameProxy_ || !proxy.Manual.FTPProxy) { |
| 192 proxy.Manual.FTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( | 189 proxy.Manual.FTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( |
| 193 Object.assign({}, defaultProxy)); | 190 Object.assign({}, defaultProxy)); |
| 194 } | 191 } |
| 195 if (this.useSameProxy || !proxy.Manual.SOCKS) { | 192 if (this.useSameProxy_ || !proxy.Manual.SOCKS) { |
| 196 proxy.Manual.SOCKS = /** @type {!CrOnc.ProxyLocation} */ ( | 193 proxy.Manual.SOCKS = /** @type {!CrOnc.ProxyLocation} */ ( |
| 197 Object.assign({}, defaultProxy)); | 194 Object.assign({}, defaultProxy)); |
| 198 } | 195 } |
| 199 this.savedManual_ = Object.assign({}, proxy.Manual); | 196 this.savedManual_ = Object.assign({}, proxy.Manual); |
| 200 this.savedExcludeDomains_ = proxy.ExcludeDomains; | 197 this.savedExcludeDomains_ = proxy.ExcludeDomains; |
| 201 this.proxy = proxy; | 198 this.proxy = proxy; |
| 202 } else if (this.proxy.Type == CrOnc.ProxySettingsType.PAC) { | 199 } else if (this.proxy.Type == CrOnc.ProxySettingsType.PAC) { |
| 203 if (!this.proxy.PAC) | 200 if (!this.proxy.PAC) |
| 204 return; | 201 return; |
| 205 } | 202 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 /** | 282 /** |
| 286 * @param {string} property The property to test | 283 * @param {string} property The property to test |
| 287 * @param {string} value The value to test against | 284 * @param {string} value The value to test against |
| 288 * @return {boolean} True if property == value | 285 * @return {boolean} True if property == value |
| 289 * @private | 286 * @private |
| 290 */ | 287 */ |
| 291 matches_: function(property, value) { | 288 matches_: function(property, value) { |
| 292 return property == value; | 289 return property == value; |
| 293 } | 290 } |
| 294 }); | 291 }); |
| OLD | NEW |