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

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

Issue 2913323003: Settings: Network: Merge Tether networks into Mobile subpage (Closed)
Patch Set: Rebase Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 information about WiFi, 6 * @fileoverview Polymer element for displaying information about WiFi,
7 * WiMAX, or virtual networks. 7 * WiMAX, or virtual networks.
8 */ 8 */
9 9
10 Polymer({ 10 Polymer({
(...skipping 12 matching lines...) Expand all
23 * @type {?CrOnc.NetworkStateProperties|undefined} 23 * @type {?CrOnc.NetworkStateProperties|undefined}
24 */ 24 */
25 defaultNetwork: Object, 25 defaultNetwork: Object,
26 26
27 /** 27 /**
28 * Device state for the network type. 28 * Device state for the network type.
29 * @type {!CrOnc.DeviceStateProperties|undefined} 29 * @type {!CrOnc.DeviceStateProperties|undefined}
30 */ 30 */
31 deviceState: Object, 31 deviceState: Object,
32 32
33 /**
34 * If both Cellular and Tether technologies exist, we combine the subpages
35 * and set this to the device state for Tether.
36 * @type {!CrOnc.DeviceStateProperties|undefined}
37 */
38 tetherDeviceState: Object,
39
33 /** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */ 40 /** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */
34 globalPolicy: Object, 41 globalPolicy: Object,
35 42
36 /** 43 /**
37 * List of third party VPN providers. 44 * List of third party VPN providers.
38 * @type 45 * @type
39 * {!Array<!chrome.networkingPrivate.ThirdPartyVPNProperties>|undefined} 46 * {!Array<!chrome.networkingPrivate.ThirdPartyVPNProperties>|undefined}
40 */ 47 */
41 thirdPartyVpnProviders: Array, 48 thirdPartyVpnProviders: Array,
42 49
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 171
165 /** @private */ 172 /** @private */
166 getNetworkStateList_: function() { 173 getNetworkStateList_: function() {
167 if (!this.deviceState) 174 if (!this.deviceState)
168 return; 175 return;
169 var filter = { 176 var filter = {
170 networkType: this.deviceState.Type, 177 networkType: this.deviceState.Type,
171 visible: true, 178 visible: true,
172 configured: false 179 configured: false
173 }; 180 };
174 this.networkingPrivate.getNetworks(filter, function(networkStates) { 181 this.networkingPrivate.getNetworks(filter, this.onGetNetworks_.bind(this));
175 if (!this.deviceState) 182 },
176 return; 183
177 if (this.deviceState.Type != CrOnc.Type.VPN) { 184 /**
178 this.networkStateList_ = networkStates; 185 * @param {!Array<!CrOnc.NetworkStateProperties>} networkStates
179 return; 186 * @private
180 } 187 */
181 // For VPNs, separate out third party VPNs. 188 onGetNetworks_: function(networkStates) {
182 var networkStateList = []; 189 if (!this.deviceState)
190 return; // Edge case when device states change before this callback.
191
192 // For the Cellular/Mobile subpage, request Tether networks if available.
193 if (this.deviceState.Type == CrOnc.Type.CELLULAR &&
Kyle Horimoto 2017/06/01 20:15:21 What about the opposite case when type == TETHER?
stevenjb 2017/06/01 21:55:03 Ah, good catch. Rather than complicate this code,
194 this.tetherDeviceState) {
195 var filter = {
196 networkType: CrOnc.Type.TETHER,
197 visible: true,
198 configured: false
199 };
200 this.networkingPrivate.getNetworks(filter, function(tetherNetworkStates) {
201 this.networkStateList_ = networkStates.concat(tetherNetworkStates);
202 }.bind(this));
203 return;
204 }
205
206 // For VPNs, separate out third party VPNs.
207 if (this.deviceState.Type == CrOnc.Type.VPN) {
208 var builtinNetworkStates = [];
183 var thirdPartyVpns = {}; 209 var thirdPartyVpns = {};
184 for (var i = 0; i < networkStates.length; ++i) { 210 for (var i = 0; i < networkStates.length; ++i) {
185 var state = networkStates[i]; 211 var state = networkStates[i];
186 var providerType = state.VPN && state.VPN.ThirdPartyVPN && 212 var providerType = state.VPN && state.VPN.ThirdPartyVPN &&
187 state.VPN.ThirdPartyVPN.ProviderName; 213 state.VPN.ThirdPartyVPN.ProviderName;
188 if (providerType) { 214 if (providerType) {
189 thirdPartyVpns[providerType] = thirdPartyVpns[providerType] || []; 215 thirdPartyVpns[providerType] = thirdPartyVpns[providerType] || [];
190 thirdPartyVpns[providerType].push(state); 216 thirdPartyVpns[providerType].push(state);
191 } else { 217 } else {
192 networkStateList.push(state); 218 builtinNetworkStates.push(state);
193 } 219 }
220 networkStates = builtinNetworkStates;
221 this.thirdPartyVpns_ = thirdPartyVpns;
194 } 222 }
195 this.networkStateList_ = networkStateList; 223 }
196 this.thirdPartyVpns_ = thirdPartyVpns; 224
197 }.bind(this)); 225 this.networkStateList_ = networkStates;
198 }, 226 },
199 227
200 /** 228 /**
201 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState 229 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
202 * @return {boolean} Whether or not the device state is enabled. 230 * @return {boolean} Whether or not the device state is enabled.
203 * @private 231 * @private
204 */ 232 */
205 deviceIsEnabled_: function(deviceState) { 233 deviceIsEnabled_: function(deviceState) {
206 return !!deviceState && deviceState.State == CrOnc.DeviceState.ENABLED; 234 return !!deviceState && deviceState.State == CrOnc.DeviceState.ENABLED;
207 }, 235 },
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 /** 267 /**
240 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState 268 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
241 * @return {string} 269 * @return {string}
242 * @private 270 * @private
243 */ 271 */
244 getToggleA11yString_: function(deviceState) { 272 getToggleA11yString_: function(deviceState) {
245 if (!this.enableToggleIsVisible_(deviceState)) 273 if (!this.enableToggleIsVisible_(deviceState))
246 return ''; 274 return '';
247 switch (deviceState.Type) { 275 switch (deviceState.Type) {
248 case CrOnc.Type.TETHER: 276 case CrOnc.Type.TETHER:
249 return this.i18n('internetToggleTetherA11yLabel');
250 case CrOnc.Type.CELLULAR: 277 case CrOnc.Type.CELLULAR:
251 return this.i18n('internetToggleMobileA11yLabel'); 278 return this.i18n('internetToggleMobileA11yLabel');
252 case CrOnc.Type.WI_FI: 279 case CrOnc.Type.WI_FI:
253 return this.i18n('internetToggleWiFiA11yLabel'); 280 return this.i18n('internetToggleWiFiA11yLabel');
254 case CrOnc.Type.WI_MAX: 281 case CrOnc.Type.WI_MAX:
255 return this.i18n('internetToggleWiMAXA11yLabel'); 282 return this.i18n('internetToggleWiMAXA11yLabel');
256 } 283 }
257 assertNotReached(); 284 assertNotReached();
258 return ''; 285 return '';
259 }, 286 },
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 425 }
399 if (state.Type == CrOnc.Type.VPN && 426 if (state.Type == CrOnc.Type.VPN &&
400 (!defaultNetwork || 427 (!defaultNetwork ||
401 defaultNetwork.ConnectionState != CrOnc.ConnectionState.CONNECTED)) { 428 defaultNetwork.ConnectionState != CrOnc.ConnectionState.CONNECTED)) {
402 return false; 429 return false;
403 } 430 }
404 return true; 431 return true;
405 }, 432 },
406 433
407 /** 434 /**
435 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
436 * @param {!CrOnc.DeviceStateProperties|undefined} tetherDeviceState
437 * @return {boolean}
438 * @private
439 */
440 tetherToggleIsVisible_: function(deviceState, tetherDeviceState) {
Kyle Horimoto 2017/06/01 20:15:21 Edge case I thought of: What if cellular is not pr
stevenjb 2017/06/01 21:55:03 Correct. I believe we still need access to both to
441 return !!deviceState && deviceState.Type == CrOnc.Type.CELLULAR &&
442 !!tetherDeviceState &&
443 tetherDeviceState.State != CrOnc.DeviceState.UNINITIALIZED;
Ryan Hansberry 2017/06/01 18:13:00 [Apologies in advance for being a noob here] Doe
stevenjb 2017/06/01 21:55:03 OK. That is not made clear in the UX design doc I
Kyle Horimoto 2017/06/01 22:21:46 Did you make this change? I don't think I see it,
stevenjb 2017/06/01 22:37:02 I did... this function no longer tests 'etherDevic
444 },
445
446 /**
447 * @param {!Event} event
448 * @private
449 */
450 onTetherEnabledTap_: function(event) {
451 this.fire('device-enabled-toggled', {
452 enabled: !this.deviceIsEnabled_(this.tetherDeviceState),
453 type: CrOnc.Type.TETHER,
454 });
455 event.stopPropagation();
456 },
457
458 /**
408 * @param {*} lhs 459 * @param {*} lhs
409 * @param {*} rhs 460 * @param {*} rhs
410 * @return {boolean} 461 * @return {boolean}
411 */ 462 */
412 isEqual_: function(lhs, rhs) { 463 isEqual_: function(lhs, rhs) {
413 return lhs === rhs; 464 return lhs === rhs;
414 }, 465 },
415 }); 466 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698