Chromium Code Reviews| 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', |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 */ | 95 */ |
| 96 savedManual_: undefined, | 96 savedManual_: undefined, |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * 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 |
| 100 * not loose any set exclusions while the UI is open. | 100 * not loose any set exclusions while the UI is open. |
| 101 * @private {!Array<string>|undefined} | 101 * @private {!Array<string>|undefined} |
| 102 */ | 102 */ |
| 103 savedExcludeDomains_: undefined, | 103 savedExcludeDomains_: undefined, |
| 104 | 104 |
| 105 /** | 105 /** @private */ |
| 106 * Polymer networkProperties changed method. | |
| 107 */ | |
| 108 networkPropertiesChanged_: function() { | 106 networkPropertiesChanged_: function() { |
| 109 if (!this.networkProperties) | 107 if (!this.networkProperties) |
| 110 return; | 108 return; |
| 111 | 109 |
| 112 /** @type {!CrOnc.ProxySettings} */ | 110 /** @type {!CrOnc.ProxySettings} */ |
| 113 var proxy = this.createDefaultProxySettings_(); | 111 var proxy = this.createDefaultProxySettings_(); |
| 114 /** @type {!chrome.networkingPrivate.ManagedProxySettings|undefined} */ | 112 /** @type {!chrome.networkingPrivate.ManagedProxySettings|undefined} */ |
| 115 var proxySettings = this.networkProperties.ProxySettings; | 113 var proxySettings = this.networkProperties.ProxySettings; |
| 116 if (proxySettings) { | 114 if (proxySettings) { |
| 117 proxy.Type = /** @type {!CrOnc.ProxySettingsType} */ ( | 115 proxy.Type = /** @type {!CrOnc.ProxySettingsType} */ ( |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 132 proxy.ExcludeDomains = /** @type {!Array<string>|undefined} */ ( | 130 proxy.ExcludeDomains = /** @type {!Array<string>|undefined} */ ( |
| 133 CrOnc.getActiveValue(proxySettings.ExcludeDomains)); | 131 CrOnc.getActiveValue(proxySettings.ExcludeDomains)); |
| 134 } | 132 } |
| 135 proxy.PAC = /** @type {string|undefined} */ ( | 133 proxy.PAC = /** @type {string|undefined} */ ( |
| 136 CrOnc.getActiveValue(proxySettings.PAC)); | 134 CrOnc.getActiveValue(proxySettings.PAC)); |
| 137 } | 135 } |
| 138 // Use saved ExcludeDomanains and Manual if not defined. | 136 // Use saved ExcludeDomanains and Manual if not defined. |
| 139 proxy.ExcludeDomains = proxy.ExcludeDomains || this.savedExcludeDomains_; | 137 proxy.ExcludeDomains = proxy.ExcludeDomains || this.savedExcludeDomains_; |
| 140 proxy.Manual = proxy.Manual || this.savedManual_; | 138 proxy.Manual = proxy.Manual || this.savedManual_; |
| 141 | 139 |
| 142 this.proxy = proxy; | 140 // Set this.proxy after dom-repeat has been stamped. |
| 141 this.async(function() { | |
| 142 this.proxy = proxy; | |
| 143 }.bind(this)); | |
| 143 | 144 |
| 144 // Set the Web Proxy Auto Discovery URL. | 145 // Set the Web Proxy Auto Discovery URL. |
| 145 var ipv4 = | 146 var ipv4 = |
| 146 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); | 147 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); |
| 147 this.WPAD = (ipv4 && ipv4.WebProxyAutoDiscoveryUrl) || ''; | 148 this.WPAD = (ipv4 && ipv4.WebProxyAutoDiscoveryUrl) || ''; |
| 148 }, | 149 }, |
| 149 | 150 |
| 151 /** @private */ | |
| 152 useSameProxyChanged_: function() { | |
|
dpapad
2016/10/18 00:09:51
Nit: This seems to have been moved, no modificatio
stevenjb
2016/10/18 00:32:57
I've been fixing ordering and comments to be consi
| |
| 153 this.sendProxyChange_(); | |
| 154 }, | |
| 155 | |
| 150 /** | 156 /** |
| 151 * @return {CrOnc.ProxySettings} An empty/default proxy settings object. | 157 * @return {CrOnc.ProxySettings} An empty/default proxy settings object. |
| 158 * @private | |
| 152 */ | 159 */ |
| 153 createDefaultProxySettings_: function() { | 160 createDefaultProxySettings_: function() { |
| 154 return { | 161 return { |
| 155 Type: CrOnc.ProxySettingsType.DIRECT, | 162 Type: CrOnc.ProxySettingsType.DIRECT, |
| 156 ExcludeDomains: [], | 163 ExcludeDomains: [], |
| 157 Manual: { | 164 Manual: { |
| 158 HTTPProxy: {Host: '', Port: 80}, | 165 HTTPProxy: {Host: '', Port: 80}, |
| 159 SecureHTTPProxy: {Host: '', Port: 80}, | 166 SecureHTTPProxy: {Host: '', Port: 80}, |
| 160 FTPProxy: {Host: '', Port: 80}, | 167 FTPProxy: {Host: '', Port: 80}, |
| 161 SOCKS: {Host: '', Port: 1080} | 168 SOCKS: {Host: '', Port: 1080} |
| 162 }, | 169 }, |
| 163 PAC: '' | 170 PAC: '' |
| 164 }; | 171 }; |
| 165 }, | 172 }, |
| 166 | 173 |
| 167 /** | 174 /** |
| 168 * Polymer useSameProxy changed method. | |
| 169 */ | |
| 170 useSameProxyChanged_: function() { | |
| 171 this.sendProxyChange_(); | |
| 172 }, | |
| 173 | |
| 174 /** | |
| 175 * Called when the proxy changes in the UI. | 175 * Called when the proxy changes in the UI. |
| 176 * @private | |
| 176 */ | 177 */ |
| 177 sendProxyChange_: function() { | 178 sendProxyChange_: function() { |
| 178 if (this.proxy.Type == CrOnc.ProxySettingsType.MANUAL) { | 179 if (this.proxy.Type == CrOnc.ProxySettingsType.MANUAL) { |
| 179 var proxy = | 180 var proxy = |
| 180 /** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy)); | 181 /** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy)); |
| 181 var defaultProxy = proxy.Manual.HTTPProxy; | 182 var defaultProxy = proxy.Manual.HTTPProxy; |
| 182 if (!defaultProxy || !defaultProxy.Host) | 183 if (!defaultProxy || !defaultProxy.Host) |
| 183 return; | 184 return; |
| 184 if (this.useSameProxy_ || !proxy.Manual.SecureHTTPProxy) { | 185 if (this.useSameProxy_ || !proxy.Manual.SecureHTTPProxy) { |
| 185 proxy.Manual.SecureHTTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( | 186 proxy.Manual.SecureHTTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 198 this.proxy = proxy; | 199 this.proxy = proxy; |
| 199 } else if (this.proxy.Type == CrOnc.ProxySettingsType.PAC) { | 200 } else if (this.proxy.Type == CrOnc.ProxySettingsType.PAC) { |
| 200 if (!this.proxy.PAC) | 201 if (!this.proxy.PAC) |
| 201 return; | 202 return; |
| 202 } | 203 } |
| 203 this.fire('proxy-change', {field: 'ProxySettings', value: this.proxy}); | 204 this.fire('proxy-change', {field: 'ProxySettings', value: this.proxy}); |
| 204 }, | 205 }, |
| 205 | 206 |
| 206 /** | 207 /** |
| 207 * Event triggered when the selected proxy type changes. | 208 * Event triggered when the selected proxy type changes. |
| 208 * @param {!{detail: !{selected: string}}} e | 209 * @param {!Event} event |
| 209 * @private | 210 * @private |
| 210 */ | 211 */ |
| 211 onTypeChange_: function(e) { | 212 onTypeChange_: function(event) { |
| 213 let target = /** @type {!HTMLSelectElement} */ (event.target); | |
| 212 var type = /** @type {chrome.networkingPrivate.ProxySettingsType} */ ( | 214 var type = /** @type {chrome.networkingPrivate.ProxySettingsType} */ ( |
| 213 e.detail.selected); | 215 target.value); |
| 214 this.set('proxy.Type', type); | 216 this.set('proxy.Type', type); |
| 215 this.sendProxyChange_(); | 217 this.sendProxyChange_(); |
| 216 }, | 218 }, |
| 217 | 219 |
| 218 /** | 220 /** |
| 219 * Event triggered when a proxy value changes. | 221 * Event triggered when a proxy value changes. |
| 220 * @param {Event} event The proxy value change event. | 222 * @param {Event} event The proxy value change event. |
| 221 * @private | 223 * @private |
| 222 */ | 224 */ |
| 223 onProxyInputChange_: function(event) { | 225 onProxyInputChange_: function(event) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 /** | 284 /** |
| 283 * @param {string} property The property to test | 285 * @param {string} property The property to test |
| 284 * @param {string} value The value to test against | 286 * @param {string} value The value to test against |
| 285 * @return {boolean} True if property == value | 287 * @return {boolean} True if property == value |
| 286 * @private | 288 * @private |
| 287 */ | 289 */ |
| 288 matches_: function(property, value) { | 290 matches_: function(property, value) { |
| 289 return property == value; | 291 return property == value; |
| 290 } | 292 } |
| 291 }); | 293 }); |
| OLD | NEW |