Chromium Code Reviews| Index: chrome/browser/resources/settings/internet_page/network_proxy.js |
| diff --git a/chrome/browser/resources/settings/internet_page/network_proxy.js b/chrome/browser/resources/settings/internet_page/network_proxy.js |
| index 4042b8761c4d0e75815e792e0195b01e6e0a12cd..3199ab65dd2977fa761723a1c67f5a48beb82f82 100644 |
| --- a/chrome/browser/resources/settings/internet_page/network_proxy.js |
| +++ b/chrome/browser/resources/settings/internet_page/network_proxy.js |
| @@ -56,6 +56,12 @@ Polymer({ |
| }, |
| /** |
| + * Reflects prefs.settings.use_shared_proxies for data binding. |
| + * @private |
| + */ |
| + useSharedProxies_: Boolean, |
| + |
| + /** |
| * Array of proxy configuration types. |
| * @private {!Array<string>} |
| * @const |
| @@ -88,6 +94,10 @@ Polymer({ |
| }, |
| }, |
| + observers: [ |
| + 'useSharedProxiesChanged_(prefs.*)', |
|
michaelpg
2016/11/15 22:22:04
use "(prefs.settings.use_shared_proxies.value)", o
stevenjb
2016/11/17 01:43:28
Done.
|
| + ], |
| + |
| /** |
| * Saved Manual properties so that switching to another type does not loose |
| * any set properties while the UI is open. |
| @@ -111,11 +121,27 @@ Polymer({ |
| /** @private */ |
| networkPropertiesChanged_: function() { |
| + this.updateProxy_(); |
| + }, |
| + |
| + /** @private */ |
| + updateProxy_: function() { |
| if (!this.networkProperties) |
| return; |
| /** @type {!CrOnc.ProxySettings} */ |
| var proxy = this.createDefaultProxySettings_(); |
| + |
| + // For shared networks with unmanaged proxy settings, ignore any saved |
| + // proxy settings (use the default values). |
| + if (this.isShared_()) { |
| + let property = this.getProxySettingsTypeProperty_(); |
| + if (!this.isControlled(property) && !this.useSharedProxies_) { |
| + this.setProxyAsync_(proxy); |
| + return; // Proxy settings will be ignored. |
| + } |
| + } |
| + |
| /** @type {!chrome.networkingPrivate.ManagedProxySettings|undefined} */ |
| var proxySettings = this.networkProperties.ProxySettings; |
| if (proxySettings) { |
| @@ -152,15 +178,23 @@ Polymer({ |
| proxy.ExcludeDomains = proxy.ExcludeDomains || this.savedExcludeDomains_; |
| proxy.Manual = proxy.Manual || this.savedManual_; |
| - // Set this.proxy after dom-repeat has been stamped. |
| - this.async(function() { |
| - this.proxy = proxy; |
| - }.bind(this)); |
| - |
| // Set the Web Proxy Auto Discovery URL. |
| var ipv4 = |
| CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); |
| this.WPAD = (ipv4 && ipv4.WebProxyAutoDiscoveryUrl) || ''; |
| + |
| + this.setProxyAsync_(proxy); |
| + }, |
| + |
| + /** |
| + * @param {!CrOnc.ProxySettings} proxy |
| + * @private |
| + */ |
| + setProxyAsync_: function(proxy) { |
| + // Set this.proxy after dom-repeat has been stamped. |
| + this.async(function() { |
| + this.proxy = proxy; |
| + }.bind(this)); |
| }, |
| /** @private */ |
| @@ -170,6 +204,13 @@ Polymer({ |
| this.sendProxyChange_(); |
| }, |
| + /** @private */ |
| + useSharedProxiesChanged_: function() { |
| + let pref = this.getPref('settings.use_shared_proxies'); |
| + this.useSharedProxies_ = !!pref && !!pref.value; |
|
michaelpg
2016/11/15 22:22:04
You can assume pref.value is a (defined) boolean i
stevenjb
2016/11/17 01:43:28
Closure doesn't like that.
michaelpg
2016/11/17 02:00:11
thanks, I always forget about closure (until I run
|
| + this.updateProxy_(); |
| + }, |
| + |
| /** |
| * @return {CrOnc.ProxySettings} An empty/default proxy settings object. |
| * @private |
| @@ -283,12 +324,20 @@ Polymer({ |
| }, |
| /** |
| + * @return {!CrOnc.ManagedProperty|undefined} |
| + * @private |
| + */ |
| + getProxySettingsTypeProperty_: function() { |
| + return /** @type {!CrOnc.ManagedProperty|undefined}*/ ( |
|
michaelpg
2016/11/15 22:22:04
nit: consistent spacing: add space before comment-
stevenjb
2016/11/17 01:43:28
Done.
|
| + this.get('ProxySettings.Type', this.networkProperties)); |
| + }, |
| + |
| + /** |
| * @return {boolean} |
| * @private |
| */ |
| getShowNetworkPolicyIndicator_: function() { |
| - let property = /** @type {!CrOnc.ManagedProperty|undefined}*/ ( |
| - this.get('ProxySettings.Type', this.networkProperties)); |
| + let property = this.getProxySettingsTypeProperty_(); |
| return !!property && !this.isExtensionControlled(property) && |
| this.isNetworkPolicyEnforced(property); |
| }, |
| @@ -298,19 +347,37 @@ Polymer({ |
| * @private |
| */ |
| getShowPrefPolicyIndicator_: function() { |
| - let property = /** @type {!CrOnc.ManagedProperty|undefined}*/ ( |
| - this.get('ProxySettings.Type', this.networkProperties)); |
| + let property = this.getProxySettingsTypeProperty_(); |
| return !!property && this.isExtensionControlled(property); |
| }, |
| /** |
| + * @param {!CrOnc.ManagedProperty} property |
| + * @return {boolean} |
| + * @private |
| + */ |
| + getShowAllowShared_: function(property) { |
| + return !this.isControlled(property) && this.isShared_(); |
| + }, |
| + |
| + /** |
| * @param {!CrOnc.ManagedProperty|undefined} property |
| * @return {boolean} Whether the property setting is enforced. |
| * @private |
| */ |
| isEditable_: function(property) { |
| return this.editable && !this.isNetworkPolicyEnforced(property) && |
| - !this.isExtensionControlled(property); |
| + !this.isExtensionControlled(property) && |
| + (!this.isShared_() || this.useSharedProxies_); |
| + }, |
| + |
| + /** |
| + * @return {boolean} |
| + * @private |
| + */ |
| + isShared_: function() { |
| + return this.networkProperties.Source == 'Device' || |
| + this.networkProperties.Source == 'DevicePolicy'; |
| }, |
| /** |
| @@ -321,8 +388,7 @@ Polymer({ |
| * @private |
| */ |
| isProxyEditable_: function() { |
| - let property = /** @type {!CrOnc.ManagedProperty|undefined}*/ ( |
| - this.get('ProxySettings.Type', this.networkProperties)); |
| + let property = this.getProxySettingsTypeProperty_(); |
| return !!property && this.isEditable_(property); |
| }, |
| @@ -334,5 +400,37 @@ Polymer({ |
| */ |
| matches_: function(property, value) { |
| return property == value; |
| - } |
| + }, |
| + |
| + /** |
| + * Handles the change event for the shared proxy checkbox. Shows a |
| + * confirmation dialog. |
| + * @param {Event} event |
| + * @private |
| + */ |
| + onAllowSharedProxiesChange_: function(event) { |
| + this.$.confirmAllowSharedDialog.showModal(); |
| + }, |
| + |
| + /** |
| + * Handles the shared proxy confirmation dialog 'Confirm' button. |
| + * @private |
| + */ |
| + onAllowSharedDialogConfirm_: function() { |
| + /** @type {!SettingsCheckboxElement} */ (this.$.allowShared) |
| + .sendPrefChange(); |
| + this.$.confirmAllowSharedDialog.close(); |
| + }, |
| + |
| + /** |
| + * Handles the shared proxy confirmation dialog 'Cancel' button or a cancel |
| + * event. |
| + * @private |
| + */ |
| + onAllowSharedDialogCancel_: function() { |
| + /** @type {!SettingsCheckboxElement} */ (this.$.allowShared) |
| + .resetToPrefValue(); |
| + this.$.confirmAllowSharedDialog.close(); |
| + }, |
| + |
|
michaelpg
2016/11/15 22:22:04
nit: rm blank line
stevenjb
2016/11/17 01:43:28
Done.
|
| }); |