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

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

Issue 2651483002: MD Settings: Eliminate use of ES6 for Chrome OS (Closed)
Patch Set: . Created 3 years, 11 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
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 updateProxy_: function() { 146 updateProxy_: function() {
147 if (!this.networkProperties) 147 if (!this.networkProperties)
148 return; 148 return;
149 149
150 /** @type {!CrOnc.ProxySettings} */ 150 /** @type {!CrOnc.ProxySettings} */
151 var proxy = this.createDefaultProxySettings_(); 151 var proxy = this.createDefaultProxySettings_();
152 152
153 // For shared networks with unmanaged proxy settings, ignore any saved 153 // For shared networks with unmanaged proxy settings, ignore any saved
154 // proxy settings (use the default values). 154 // proxy settings (use the default values).
155 if (this.isShared_()) { 155 if (this.isShared_()) {
156 let property = this.getProxySettingsTypeProperty_(); 156 var property = this.getProxySettingsTypeProperty_();
157 if (!this.isControlled(property) && !this.useSharedProxies_) { 157 if (!this.isControlled(property) && !this.useSharedProxies_) {
158 this.setProxyAsync_(proxy); 158 this.setProxyAsync_(proxy);
159 return; // Proxy settings will be ignored. 159 return; // Proxy settings will be ignored.
160 } 160 }
161 } 161 }
162 162
163 /** @type {!chrome.networkingPrivate.ManagedProxySettings|undefined} */ 163 /** @type {!chrome.networkingPrivate.ManagedProxySettings|undefined} */
164 var proxySettings = this.networkProperties.ProxySettings; 164 var proxySettings = this.networkProperties.ProxySettings;
165 if (proxySettings) { 165 if (proxySettings) {
166 proxy.Type = /** @type {!CrOnc.ProxySettingsType} */ ( 166 proxy.Type = /** @type {!CrOnc.ProxySettingsType} */ (
(...skipping 10 matching lines...) Expand all
177 proxy.Manual.HTTPProxy; 177 proxy.Manual.HTTPProxy;
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 proxy.Manual.HTTPProxy;
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 proxy.Manual.HTTPProxy;
187 let json_http = JSON.stringify(proxy.Manual.HTTPProxy); 187 var jsonHttp = JSON.stringify(proxy.Manual.HTTPProxy);
188 this.useSameProxy_ = 188 this.useSameProxy_ =
189 json_http == JSON.stringify(proxy.Manual.SecureHTTPProxy) && 189 jsonHttp == JSON.stringify(proxy.Manual.SecureHTTPProxy) &&
dpapad 2017/01/23 19:12:54 FWIW: There are no guarantees that JSON.stringify(
stevenjb 2017/01/24 02:02:04 I'm pretty sure that in this context JSON.stringif
190 json_http == JSON.stringify(proxy.Manual.FTPProxy) && 190 jsonHttp == JSON.stringify(proxy.Manual.FTPProxy) &&
191 json_http == JSON.stringify(proxy.Manual.SOCKS); 191 jsonHttp == JSON.stringify(proxy.Manual.SOCKS);
192 } 192 }
193 if (proxySettings.ExcludeDomains) { 193 if (proxySettings.ExcludeDomains) {
194 proxy.ExcludeDomains = /** @type {!Array<string>|undefined} */ ( 194 proxy.ExcludeDomains = /** @type {!Array<string>|undefined} */ (
195 CrOnc.getActiveValue(proxySettings.ExcludeDomains)); 195 CrOnc.getActiveValue(proxySettings.ExcludeDomains));
196 } 196 }
197 proxy.PAC = /** @type {string|undefined} */ ( 197 proxy.PAC = /** @type {string|undefined} */ (
198 CrOnc.getActiveValue(proxySettings.PAC)); 198 CrOnc.getActiveValue(proxySettings.PAC));
199 } 199 }
200 // Use saved ExcludeDomanains and Manual if not defined. 200 // Use saved ExcludeDomanains and Manual if not defined.
201 proxy.ExcludeDomains = proxy.ExcludeDomains || this.savedExcludeDomains_; 201 proxy.ExcludeDomains = proxy.ExcludeDomains || this.savedExcludeDomains_;
(...skipping 19 matching lines...) Expand all
221 }.bind(this)); 221 }.bind(this));
222 }, 222 },
223 223
224 /** @private */ 224 /** @private */
225 useSameProxyChanged_: function() { 225 useSameProxyChanged_: function() {
226 this.proxyModified_ = true; 226 this.proxyModified_ = true;
227 }, 227 },
228 228
229 /** @private */ 229 /** @private */
230 useSharedProxiesChanged_: function() { 230 useSharedProxiesChanged_: function() {
231 let pref = this.getPref('settings.use_shared_proxies'); 231 var pref = this.getPref('settings.use_shared_proxies');
232 this.useSharedProxies_ = !!pref && !!pref.value; 232 this.useSharedProxies_ = !!pref && !!pref.value;
233 this.updateProxy_(); 233 this.updateProxy_();
234 }, 234 },
235 235
236 /** 236 /**
237 * @return {CrOnc.ProxySettings} An empty/default proxy settings object. 237 * @return {CrOnc.ProxySettings} An empty/default proxy settings object.
238 * @private 238 * @private
239 */ 239 */
240 createDefaultProxySettings_: function() { 240 createDefaultProxySettings_: function() {
241 return { 241 return {
242 Type: CrOnc.ProxySettingsType.DIRECT, 242 Type: CrOnc.ProxySettingsType.DIRECT,
243 ExcludeDomains: [], 243 ExcludeDomains: [],
244 Manual: { 244 Manual: {
245 HTTPProxy: {Host: '', Port: 80}, 245 HTTPProxy: {Host: '', Port: 80},
246 SecureHTTPProxy: {Host: '', Port: 80}, 246 SecureHTTPProxy: {Host: '', Port: 80},
247 FTPProxy: {Host: '', Port: 80}, 247 FTPProxy: {Host: '', Port: 80},
248 SOCKS: {Host: '', Port: 1080} 248 SOCKS: {Host: '', Port: 1080}
249 }, 249 },
250 PAC: '' 250 PAC: ''
251 }; 251 };
252 }, 252 },
253 253
254 /** 254 /**
255 * Called when the proxy changes in the UI. 255 * Called when the proxy changes in the UI.
256 * @private 256 * @private
257 */ 257 */
258 sendProxyChange_: function() { 258 sendProxyChange_: function() {
259 if (this.proxy_.Type == CrOnc.ProxySettingsType.MANUAL) { 259 if (this.proxy_.Type == CrOnc.ProxySettingsType.MANUAL) {
260 let proxy = 260 var proxy =
261 /** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy_)); 261 /** @type {!CrOnc.ProxySettings} */ (Object.assign({}, this.proxy_));
262 let manual = proxy.Manual; 262 var manual = proxy.Manual;
263 let defaultProxy = manual.HTTPProxy; 263 var defaultProxy = manual.HTTPProxy;
264 if (!defaultProxy || !defaultProxy.Host) 264 if (!defaultProxy || !defaultProxy.Host)
265 return; 265 return;
266 if (this.useSameProxy_ || !this.get('SecureHTTPProxy.Host', manual)) { 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 } 269 }
270 if (this.useSameProxy_ || !this.get('FTPProxy.Host', manual)) { 270 if (this.useSameProxy_ || !this.get('FTPProxy.Host', manual)) {
271 proxy.Manual.FTPProxy = /** @type {!CrOnc.ProxyLocation} */ ( 271 proxy.Manual.FTPProxy = /** @type {!CrOnc.ProxyLocation} */ (
272 Object.assign({}, defaultProxy)); 272 Object.assign({}, defaultProxy));
273 } 273 }
(...skipping 11 matching lines...) Expand all
285 this.fire('proxy-change', {field: 'ProxySettings', value: this.proxy_}); 285 this.fire('proxy-change', {field: 'ProxySettings', value: this.proxy_});
286 this.proxyModified_ = false; 286 this.proxyModified_ = false;
287 }, 287 },
288 288
289 /** 289 /**
290 * Event triggered when the selected proxy type changes. 290 * Event triggered when the selected proxy type changes.
291 * @param {!Event} event 291 * @param {!Event} event
292 * @private 292 * @private
293 */ 293 */
294 onTypeChange_: function(event) { 294 onTypeChange_: function(event) {
295 let target = /** @type {!HTMLSelectElement} */ (event.target); 295 var target = /** @type {!HTMLSelectElement} */ (event.target);
296 var type = /** @type {chrome.networkingPrivate.ProxySettingsType} */ ( 296 var type = /** @type {chrome.networkingPrivate.ProxySettingsType} */ (
297 target.value); 297 target.value);
298 this.set('proxy_.Type', type); 298 this.set('proxy_.Type', type);
299 if (type == CrOnc.ProxySettingsType.MANUAL) 299 if (type == CrOnc.ProxySettingsType.MANUAL)
300 this.proxyModified_ = true; 300 this.proxyModified_ = true;
301 else 301 else
302 this.sendProxyChange_(); 302 this.sendProxyChange_();
303 }, 303 },
304 304
305 /** @private */ 305 /** @private */
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 getProxySettingsTypeProperty_: function() { 363 getProxySettingsTypeProperty_: function() {
364 return /** @type {!CrOnc.ManagedProperty|undefined} */ ( 364 return /** @type {!CrOnc.ManagedProperty|undefined} */ (
365 this.get('ProxySettings.Type', this.networkProperties)); 365 this.get('ProxySettings.Type', this.networkProperties));
366 }, 366 },
367 367
368 /** 368 /**
369 * @return {boolean} 369 * @return {boolean}
370 * @private 370 * @private
371 */ 371 */
372 shouldShowNetworkPolicyIndicator_: function() { 372 shouldShowNetworkPolicyIndicator_: function() {
373 let property = this.getProxySettingsTypeProperty_(); 373 var property = this.getProxySettingsTypeProperty_();
374 return !!property && !this.isExtensionControlled(property) && 374 return !!property && !this.isExtensionControlled(property) &&
375 this.isNetworkPolicyEnforced(property); 375 this.isNetworkPolicyEnforced(property);
376 }, 376 },
377 377
378 /** 378 /**
379 * @return {boolean} 379 * @return {boolean}
380 * @private 380 * @private
381 */ 381 */
382 shouldShowExtensionIndicator_: function() { 382 shouldShowExtensionIndicator_: function() {
383 let property = this.getProxySettingsTypeProperty_(); 383 var property = this.getProxySettingsTypeProperty_();
384 return !!property && this.isExtensionControlled(property); 384 return !!property && this.isExtensionControlled(property);
385 }, 385 },
386 386
387 /** 387 /**
388 * @param {!CrOnc.ManagedProperty} property 388 * @param {!CrOnc.ManagedProperty} property
389 * @return {boolean} 389 * @return {boolean}
390 * @private 390 * @private
391 */ 391 */
392 shouldShowAllowShared_: function(property) { 392 shouldShowAllowShared_: function(property) {
393 return !this.isControlled(property) && this.isShared_(); 393 return !this.isControlled(property) && this.isShared_();
394 }, 394 },
395 395
396 /** 396 /**
397 * @param {string} propertyName 397 * @param {string} propertyName
398 * @return {boolean} Whether the named property setting is editable. 398 * @return {boolean} Whether the named property setting is editable.
399 * @private 399 * @private
400 */ 400 */
401 isEditable_: function(propertyName) { 401 isEditable_: function(propertyName) {
402 if (!this.editable || (this.isShared_() && !this.useSharedProxies_)) 402 if (!this.editable || (this.isShared_() && !this.useSharedProxies_))
403 return false; 403 return false;
404 if (!this.networkProperties.hasOwnProperty('ProxySettings')) 404 if (!this.networkProperties.hasOwnProperty('ProxySettings'))
405 return true; // No proxy settings defined, so not enforced. 405 return true; // No proxy settings defined, so not enforced.
406 let property = /** @type {!CrOnc.ManagedProperty|undefined} */ ( 406 var property = /** @type {!CrOnc.ManagedProperty|undefined} */ (
407 this.get('ProxySettings.' + propertyName, this.networkProperties)); 407 this.get('ProxySettings.' + propertyName, this.networkProperties));
408 if (!property) 408 if (!property)
409 return true; 409 return true;
410 return this.isPropertyEditable_(property); 410 return this.isPropertyEditable_(property);
411 }, 411 },
412 412
413 /** 413 /**
414 * @param {!CrOnc.ManagedProperty|undefined} property 414 * @param {!CrOnc.ManagedProperty|undefined} property
415 * @return {boolean} Whether |property| is editable. 415 * @return {boolean} Whether |property| is editable.
416 * @private 416 * @private
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 * Handles the shared proxy confirmation dialog 'Cancel' button or a cancel 473 * Handles the shared proxy confirmation dialog 'Cancel' button or a cancel
474 * event. 474 * event.
475 * @private 475 * @private
476 */ 476 */
477 onAllowSharedDialogCancel_: function() { 477 onAllowSharedDialogCancel_: function() {
478 /** @type {!SettingsCheckboxElement} */ (this.$.allowShared) 478 /** @type {!SettingsCheckboxElement} */ (this.$.allowShared)
479 .resetToPrefValue(); 479 .resetToPrefValue();
480 this.$.confirmAllowSharedDialog.close(); 480 this.$.confirmAllowSharedDialog.close();
481 }, 481 },
482 }); 482 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698