Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: chrome/browser/resources/settings/internet_page/network_proxy.js

Issue 2815923002: MD Settings: Internet: Proxy: Support partial proxies (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/settings/internet_page/network_proxy_input.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 CrOnc.getActiveValue(proxySettings.Type)); 167 CrOnc.getActiveValue(proxySettings.Type));
168 if (proxySettings.Manual) { 168 if (proxySettings.Manual) {
169 proxy.Manual.HTTPProxy = /** @type {!CrOnc.ProxyLocation|undefined} */ ( 169 proxy.Manual.HTTPProxy = /** @type {!CrOnc.ProxyLocation|undefined} */ (
170 CrOnc.getSimpleActiveProperties( 170 CrOnc.getSimpleActiveProperties(
171 proxySettings.Manual.HTTPProxy)) || 171 proxySettings.Manual.HTTPProxy)) ||
172 {Host: '', Port: 80}; 172 {Host: '', Port: 80};
173 proxy.Manual.SecureHTTPProxy = 173 proxy.Manual.SecureHTTPProxy =
174 /** @type {!CrOnc.ProxyLocation|undefined} */ ( 174 /** @type {!CrOnc.ProxyLocation|undefined} */ (
175 CrOnc.getSimpleActiveProperties( 175 CrOnc.getSimpleActiveProperties(
176 proxySettings.Manual.SecureHTTPProxy)) || 176 proxySettings.Manual.SecureHTTPProxy)) ||
177 proxy.Manual.HTTPProxy; 177 {Host: '', Port: 80};
178 proxy.Manual.FTPProxy = 178 proxy.Manual.FTPProxy =
179 /** @type {!CrOnc.ProxyLocation|undefined} */ ( 179 /** @type {!CrOnc.ProxyLocation|undefined} */ (
180 CrOnc.getSimpleActiveProperties( 180 CrOnc.getSimpleActiveProperties(
181 proxySettings.Manual.FTPProxy)) || 181 proxySettings.Manual.FTPProxy)) ||
182 proxy.Manual.HTTPProxy; 182 {Host: '', Port: 80};
183 proxy.Manual.SOCKS = 183 proxy.Manual.SOCKS =
184 /** @type {!CrOnc.ProxyLocation|undefined} */ ( 184 /** @type {!CrOnc.ProxyLocation|undefined} */ (
185 CrOnc.getSimpleActiveProperties(proxySettings.Manual.SOCKS)) || 185 CrOnc.getSimpleActiveProperties(proxySettings.Manual.SOCKS)) ||
186 proxy.Manual.HTTPProxy; 186 {Host: '', Port: 80};
187 var jsonHttp = proxy.Manual.HTTPProxy; 187 var jsonHttp = proxy.Manual.HTTPProxy;
188 this.useSameProxy_ = 188 this.useSameProxy_ =
189 CrOnc.proxyMatches(jsonHttp, proxy.Manual.SecureHTTPProxy) && 189 (CrOnc.proxyMatches(jsonHttp, proxy.Manual.SecureHTTPProxy) &&
190 CrOnc.proxyMatches(jsonHttp, proxy.Manual.FTPProxy) && 190 CrOnc.proxyMatches(jsonHttp, proxy.Manual.FTPProxy) &&
191 CrOnc.proxyMatches(jsonHttp, proxy.Manual.SOCKS); 191 CrOnc.proxyMatches(jsonHttp, proxy.Manual.SOCKS)) ||
192 (!proxy.Manual.SecureHTTPProxy.Host &&
193 !proxy.Manual.FTPProxy.Host && !proxy.Manual.SOCKS.Host);
192 } 194 }
193 if (proxySettings.ExcludeDomains) { 195 if (proxySettings.ExcludeDomains) {
194 proxy.ExcludeDomains = /** @type {!Array<string>|undefined} */ ( 196 proxy.ExcludeDomains = /** @type {!Array<string>|undefined} */ (
195 CrOnc.getActiveValue(proxySettings.ExcludeDomains)); 197 CrOnc.getActiveValue(proxySettings.ExcludeDomains));
196 } 198 }
197 proxy.PAC = /** @type {string|undefined} */ ( 199 proxy.PAC = /** @type {string|undefined} */ (
198 CrOnc.getActiveValue(proxySettings.PAC)); 200 CrOnc.getActiveValue(proxySettings.PAC));
199 } 201 }
200 // Use saved ExcludeDomanains and Manual if not defined. 202 // Use saved ExcludeDomanains and Manual if not defined.
201 proxy.ExcludeDomains = proxy.ExcludeDomains || this.savedExcludeDomains_; 203 proxy.ExcludeDomains = proxy.ExcludeDomains || this.savedExcludeDomains_;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 }, 251 },
250 PAC: '' 252 PAC: ''
251 }; 253 };
252 }, 254 },
253 255
254 /** 256 /**
255 * Called when the proxy changes in the UI. 257 * Called when the proxy changes in the UI.
256 * @private 258 * @private
257 */ 259 */
258 sendProxyChange_: function() { 260 sendProxyChange_: function() {
259 if (this.proxy_.Type == CrOnc.ProxySettingsType.MANUAL) { 261 var proxy =
260 var proxy = 262 /** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy_));
261 /** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy_)); 263 if (proxy.Type == CrOnc.ProxySettingsType.MANUAL) {
262 var manual = proxy.Manual; 264 var manual = proxy.Manual;
263 var defaultProxy = manual.HTTPProxy; 265 var defaultProxy = manual.HTTPProxy || {Host: '', Port: 80};
264 if (!defaultProxy || !defaultProxy.Host) 266 if (this.useSameProxy_) {
265 return;
266 if (this.useSameProxy_ || !this.get('SecureHTTPProxy.Host', manual)) {
267 proxy.Manual.SecureHTTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( 267 proxy.Manual.SecureHTTPProxy = /** @type {!CrOnc.ProxyLocation} */ (
268 Object.assign({}, defaultProxy)); 268 Object.assign({}, defaultProxy));
269 }
270 if (this.useSameProxy_ || !this.get('FTPProxy.Host', manual)) {
271 proxy.Manual.FTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( 269 proxy.Manual.FTPProxy = /** @type {!CrOnc.ProxyLocation} */ (
272 Object.assign({}, defaultProxy)); 270 Object.assign({}, defaultProxy));
273 }
274 if (this.useSameProxy_ || !this.get('SOCKS.Host', manual)) {
275 proxy.Manual.SOCKS = /** @type {!CrOnc.ProxyLocation} */ ( 271 proxy.Manual.SOCKS = /** @type {!CrOnc.ProxyLocation} */ (
276 Object.assign({}, defaultProxy)); 272 Object.assign({}, defaultProxy));
273 } else {
274 // Remove properties with empty hosts to unset them.
275 if (manual.HTTPProxy && !manual.HTTPProxy.Host)
276 delete manual.HTTPProxy;
277 if (manual.SecureHTTPProxy && !manual.SecureHTTPProxy.Host)
278 delete manual.SecureHTTPProxy;
279 if (manual.FTPProxy && !manual.FTPProxy.Host)
280 delete manual.FTPProxy;
281 if (manual.SOCKS && !manual.SOCKS.Host)
282 delete manual.SOCKS;
277 } 283 }
278 this.savedManual_ = Object.assign({}, proxy.Manual); 284 this.savedManual_ = Object.assign({}, manual);
279 this.savedExcludeDomains_ = proxy.ExcludeDomains; 285 this.savedExcludeDomains_ = proxy.ExcludeDomains;
280 this.proxy_ = proxy; 286 } else if (proxy.Type == CrOnc.ProxySettingsType.PAC) {
281 } else if (this.proxy_.Type == CrOnc.ProxySettingsType.PAC) { 287 if (!proxy.PAC)
282 if (!this.proxy_.PAC)
283 return; 288 return;
284 } 289 }
285 this.fire('proxy-change', {field: 'ProxySettings', value: this.proxy_}); 290 this.fire('proxy-change', {field: 'ProxySettings', value: proxy});
286 this.proxyModified_ = false; 291 this.proxyModified_ = false;
287 }, 292 },
288 293
289 /** 294 /**
290 * Event triggered when the selected proxy type changes. 295 * Event triggered when the selected proxy type changes.
291 * @param {!Event} event 296 * @param {!Event} event
292 * @private 297 * @private
293 */ 298 */
294 onTypeChange_: function(event) { 299 onTypeChange_: function(event) {
295 var target = /** @type {!HTMLSelectElement} */ (event.target); 300 var target = /** @type {!HTMLSelectElement} */ (event.target);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 this.networkProperties.Source == 'DevicePolicy'; 434 this.networkProperties.Source == 'DevicePolicy';
430 }, 435 },
431 436
432 /** 437 /**
433 * @return {boolean} 438 * @return {boolean}
434 * @private 439 * @private
435 */ 440 */
436 isSaveManualProxyEnabled_: function() { 441 isSaveManualProxyEnabled_: function() {
437 if (!this.proxyModified_) 442 if (!this.proxyModified_)
438 return false; 443 return false;
439 return !!this.get('HTTPProxy.Host', this.proxy_.Manual); 444 var manual = this.proxy_.Manual;
445 var httpHost = this.get('HTTPProxy.Host', manual);
446 if (this.useSameProxy_)
447 return !!httpHost;
448 return !!httpHost || !!this.get('SecureHTTPProxy.Host', manual) ||
449 !!this.get('FTPProxy.Host', manual) || !!this.get('SOCKS.Host', manual);
440 }, 450 },
441 451
442 /** 452 /**
443 * @param {string} property The property to test 453 * @param {string} property The property to test
444 * @param {string} value The value to test against 454 * @param {string} value The value to test against
445 * @return {boolean} True if property == value 455 * @return {boolean} True if property == value
446 * @private 456 * @private
447 */ 457 */
448 matches_: function(property, value) { 458 matches_: function(property, value) {
449 return property == value; 459 return property == value;
(...skipping 23 matching lines...) Expand all
473 * Handles the shared proxy confirmation dialog 'Cancel' button or a cancel 483 * Handles the shared proxy confirmation dialog 'Cancel' button or a cancel
474 * event. 484 * event.
475 * @private 485 * @private
476 */ 486 */
477 onAllowSharedDialogCancel_: function() { 487 onAllowSharedDialogCancel_: function() {
478 /** @type {!SettingsCheckboxElement} */ (this.$.allowShared) 488 /** @type {!SettingsCheckboxElement} */ (this.$.allowShared)
479 .resetToPrefValue(); 489 .resetToPrefValue();
480 this.$.confirmAllowSharedDialog.close(); 490 this.$.confirmAllowSharedDialog.close();
481 }, 491 },
482 }); 492 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/settings/internet_page/network_proxy_input.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698