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 @@
<div class="property-box indented"
hidden$="[[!matches_(proxy_.Type, ProxySettingsType_.PAC)]]">
<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,
useSharedProxies)]]"
on-change="onPACChange_">
useSharedProxies)]]">
</paper-input>
</div>
......@@ -144,7 +144,7 @@
<paper-button id="saveManualProxy"
on-tap="onSaveProxyTap_" class="action-button"
disabled="[[!isSaveManualProxyEnabled_(networkProperties,
proxyModified_, proxy_.*)]]">
proxyIsUserModified_, proxy_.*)]]">
[[i18n('save')]]
</paper-button>
</div>
......
......@@ -120,7 +120,7 @@ Polymer({
* override the edited values.
* @private {boolean}
*/
proxyModified_: false,
proxyIsUserModified_: false,
/** @override */
attached: function() {
......@@ -132,14 +132,14 @@ Polymer({
* is updated correctly.
*/
reset: function() {
this.proxyModified_ = false;
this.proxyIsUserModified_ = false;
this.proxy_ = this.createDefaultProxySettings_();
this.updateProxy_();
},
/** @private */
networkPropertiesChanged_: function() {
if (this.proxyModified_)
if (this.proxyIsUserModified_)
return; // Ignore update.
this.updateProxy_();
},
......@@ -222,13 +222,13 @@ Polymer({
// Set this.proxy_ after dom-repeat has been stamped.
this.async(() => {
this.proxy_ = proxy;
this.proxyModified_ = false;
this.proxyIsUserModified_ = false;
});
},
/** @private */
useSameProxyChanged_: function() {
this.proxyModified_ = true;
this.proxyIsUserModified_ = true;
},
/**
......@@ -284,7 +284,7 @@ Polymer({
return;
}
this.fire('proxy-change', {field: 'ProxySettings', value: proxy});
this.proxyModified_ = false;
this.proxyIsUserModified_ = false;
},
/**
......@@ -297,10 +297,41 @@ Polymer({
var type = /** @type {chrome.networkingPrivate.ProxySettingsType} */ (
target.value);
this.set('proxy_.Type', type);
if (type == CrOnc.ProxySettingsType.MANUAL)
this.proxyModified_ = true;
else
var proxyTypeChangeIsReady;
var elementToFocus;
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_();
else
this.proxyIsUserModified_ = true;
if (elementToFocus) {
this.async(() => {
elementToFocus.focus();
});
}
},
/** @private */
......@@ -310,7 +341,7 @@ Polymer({
/** @private */
onProxyInputChange_: function() {
this.proxyModified_ = true;
this.proxyIsUserModified_ = true;
},
/**
......@@ -325,7 +356,7 @@ Polymer({
this.push('proxy_.ExcludeDomains', value);
// Clear input.
this.$.proxyExclusion.value = '';
this.proxyModified_ = true;
this.proxyIsUserModified_ = true;
},
/**
......@@ -334,7 +365,7 @@ Polymer({
* @private
*/
onProxyExclusionsChange_: function(event) {
this.proxyModified_ = true;
this.proxyIsUserModified_ = true;
},
/** @private */
......@@ -407,7 +438,7 @@ Polymer({
* @private
*/
isSaveManualProxyEnabled_: function() {
if (!this.proxyModified_)
if (!this.proxyIsUserModified_)
return false;
var manual = this.proxy_.Manual;
var httpHost = this.get('HTTPProxy.Host', manual);
......
......@@ -43,6 +43,10 @@ Polymer({
},
},
focus: function() {
this.$$('input').focus();
},
/**
* Event triggered when an input value changes.
* @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