Commit 1986382b authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Proxy config: Correctly set autoconfiguration URL

This CL:
* Delays setting Proxy.Type to PAC unless a PAC value is set.
* Sets proxyModified_ = true otherwise so that the type is not
  overridden on an update.
* Focus the appropriate input field when the proxy type changes.

Bug: 822670
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I0e9a68fc8982d2286e144e57dfe14dc61fa84b1b
Reviewed-on: https://chromium-review.googlesource.com/974119
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544955}
parent b69bc652
...@@ -53,10 +53,10 @@ ...@@ -53,10 +53,10 @@
<div class="property-box indented" <div class="property-box indented"
hidden$="[[!matches_(proxy_.Type, ProxySettingsType_.PAC)]]"> hidden$="[[!matches_(proxy_.Type, ProxySettingsType_.PAC)]]">
<div>[[i18n('networkProxyAutoConfig')]]</div> <div>[[i18n('networkProxyAutoConfig')]]</div>
<paper-input no-label-float class="middle" value="{{proxy_.PAC}}" <paper-input id="pacInput" no-label-float class="middle"
value="{{proxy_.PAC}}" on-change="onPACChange_"
disabled="[[!isEditable_('PAC', networkProperties, editable, disabled="[[!isEditable_('PAC', networkProperties, editable,
useSharedProxies)]]" useSharedProxies)]]">
on-change="onPACChange_">
</paper-input> </paper-input>
</div> </div>
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
<paper-button id="saveManualProxy" <paper-button id="saveManualProxy"
on-tap="onSaveProxyTap_" class="action-button" on-tap="onSaveProxyTap_" class="action-button"
disabled="[[!isSaveManualProxyEnabled_(networkProperties, disabled="[[!isSaveManualProxyEnabled_(networkProperties,
proxyModified_, proxy_.*)]]"> proxyIsUserModified_, proxy_.*)]]">
[[i18n('save')]] [[i18n('save')]]
</paper-button> </paper-button>
</div> </div>
......
...@@ -120,7 +120,7 @@ Polymer({ ...@@ -120,7 +120,7 @@ Polymer({
* override the edited values. * override the edited values.
* @private {boolean} * @private {boolean}
*/ */
proxyModified_: false, proxyIsUserModified_: false,
/** @override */ /** @override */
attached: function() { attached: function() {
...@@ -132,14 +132,14 @@ Polymer({ ...@@ -132,14 +132,14 @@ Polymer({
* is updated correctly. * is updated correctly.
*/ */
reset: function() { reset: function() {
this.proxyModified_ = false; this.proxyIsUserModified_ = false;
this.proxy_ = this.createDefaultProxySettings_(); this.proxy_ = this.createDefaultProxySettings_();
this.updateProxy_(); this.updateProxy_();
}, },
/** @private */ /** @private */
networkPropertiesChanged_: function() { networkPropertiesChanged_: function() {
if (this.proxyModified_) if (this.proxyIsUserModified_)
return; // Ignore update. return; // Ignore update.
this.updateProxy_(); this.updateProxy_();
}, },
...@@ -222,13 +222,13 @@ Polymer({ ...@@ -222,13 +222,13 @@ Polymer({
// Set this.proxy_ after dom-repeat has been stamped. // Set this.proxy_ after dom-repeat has been stamped.
this.async(() => { this.async(() => {
this.proxy_ = proxy; this.proxy_ = proxy;
this.proxyModified_ = false; this.proxyIsUserModified_ = false;
}); });
}, },
/** @private */ /** @private */
useSameProxyChanged_: function() { useSameProxyChanged_: function() {
this.proxyModified_ = true; this.proxyIsUserModified_ = true;
}, },
/** /**
...@@ -284,7 +284,7 @@ Polymer({ ...@@ -284,7 +284,7 @@ Polymer({
return; return;
} }
this.fire('proxy-change', {field: 'ProxySettings', value: proxy}); this.fire('proxy-change', {field: 'ProxySettings', value: proxy});
this.proxyModified_ = false; this.proxyIsUserModified_ = false;
}, },
/** /**
...@@ -297,10 +297,41 @@ Polymer({ ...@@ -297,10 +297,41 @@ Polymer({
var type = /** @type {chrome.networkingPrivate.ProxySettingsType} */ ( var type = /** @type {chrome.networkingPrivate.ProxySettingsType} */ (
target.value); target.value);
this.set('proxy_.Type', type); this.set('proxy_.Type', type);
if (type == CrOnc.ProxySettingsType.MANUAL) var proxyTypeChangeIsReady;
this.proxyModified_ = true; var elementToFocus;
else switch (type) {
case CrOnc.ProxySettingsType.DIRECT:
case CrOnc.ProxySettingsType.WPAD:
// No addtional values are required, send the type change.
proxyTypeChangeIsReady = true;
break;
case CrOnc.ProxySettingsType.PAC:
elementToFocus = this.$$('#pacInput');
// If a PAC is already defined, send the type change now, otherwise wait
// until the user provides a PAC value.
proxyTypeChangeIsReady = !!this.proxy_.PAC;
break;
case CrOnc.ProxySettingsType.MANUAL:
// Manual proxy configuration includes multiple input fields, so wait
// until the 'send' button is clicked.
proxyTypeChangeIsReady = false;
elementToFocus = this.$$('#manualProxy network-proxy-input');
break;
}
// If the new proxy type is fully configured, send it, otherwise set
// |proxyIsUserModified_| to true so that property updates do not
// overwrite user changes.
if (proxyTypeChangeIsReady)
this.sendProxyChange_(); this.sendProxyChange_();
else
this.proxyIsUserModified_ = true;
if (elementToFocus) {
this.async(() => {
elementToFocus.focus();
});
}
}, },
/** @private */ /** @private */
...@@ -310,7 +341,7 @@ Polymer({ ...@@ -310,7 +341,7 @@ Polymer({
/** @private */ /** @private */
onProxyInputChange_: function() { onProxyInputChange_: function() {
this.proxyModified_ = true; this.proxyIsUserModified_ = true;
}, },
/** /**
...@@ -325,7 +356,7 @@ Polymer({ ...@@ -325,7 +356,7 @@ Polymer({
this.push('proxy_.ExcludeDomains', value); this.push('proxy_.ExcludeDomains', value);
// Clear input. // Clear input.
this.$.proxyExclusion.value = ''; this.$.proxyExclusion.value = '';
this.proxyModified_ = true; this.proxyIsUserModified_ = true;
}, },
/** /**
...@@ -334,7 +365,7 @@ Polymer({ ...@@ -334,7 +365,7 @@ Polymer({
* @private * @private
*/ */
onProxyExclusionsChange_: function(event) { onProxyExclusionsChange_: function(event) {
this.proxyModified_ = true; this.proxyIsUserModified_ = true;
}, },
/** @private */ /** @private */
...@@ -407,7 +438,7 @@ Polymer({ ...@@ -407,7 +438,7 @@ Polymer({
* @private * @private
*/ */
isSaveManualProxyEnabled_: function() { isSaveManualProxyEnabled_: function() {
if (!this.proxyModified_) if (!this.proxyIsUserModified_)
return false; return false;
var manual = this.proxy_.Manual; var manual = this.proxy_.Manual;
var httpHost = this.get('HTTPProxy.Host', manual); var httpHost = this.get('HTTPProxy.Host', manual);
......
...@@ -43,6 +43,10 @@ Polymer({ ...@@ -43,6 +43,10 @@ Polymer({
}, },
}, },
focus: function() {
this.$$('input').focus();
},
/** /**
* Event triggered when an input value changes. * Event triggered when an input value changes.
* @private * @private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment