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

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

Issue 2720503006: MD Settings: Internet: Move network lists to a subpage (Closed)
Patch Set: Rebase Created 3 years, 9 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 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 the network state for a specific 6 * @fileoverview Polymer element for displaying informaiton about WiFi,
michaelpg 2017/03/01 23:27:59 information
stevenjb 2017/03/02 00:25:17 Done.
7 * type and a list of networks for that type. 7 * WiMAX, or virtual networks.
8 */ 8 */
9 9
10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ 10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */
11 var DeviceStateProperties; 11 var DeviceStateProperties;
12 12
13 Polymer({ 13 Polymer({
14 is: 'network-summary-item', 14 is: 'settings-internet-subpage',
15 15
16 behaviors: [Polymer.IronA11yKeysBehavior, I18nBehavior], 16 behaviors: [
17 CrPolicyNetworkBehavior,
18 settings.RouteObserverBehavior,
19 I18nBehavior,
20 ],
17 21
18 properties: { 22 properties: {
19 /** 23 /**
20 * Device state for the network type. 24 * Highest priority connected network or null. Set by network-summary.
michaelpg 2017/03/01 23:27:59 I think "Set by network-summary." can be misleadin
stevenjb 2017/03/02 00:25:17 While that is true, I think it is a useful detail
michaelpg 2017/03/02 01:25:00 Great, thanks for making it clearer.
21 * @type {!DeviceStateProperties|undefined} 25 * @type {?CrOnc.NetworkStateProperties|undefined}
22 */ 26 */
23 deviceState: { 27 defaultNetwork: Object,
24 type: Object,
25 observer: 'deviceStateChanged_',
26 },
27 28
28 /** 29 /**
29 * Network state for the active network. 30 * Device state for the network type.
30 * @type {!CrOnc.NetworkStateProperties|undefined} 31 * @type {?DeviceStateProperties|undefined}
31 */ 32 */
32 activeNetworkState: Object, 33 deviceState: Object,
34
35 /** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */
36 globalPolicy: Object,
33 37
34 /** 38 /**
35 * List of all network state data for the network type. 39 * List of third party VPN providers.
36 * @type {!Array<!CrOnc.NetworkStateProperties>} 40 * @type
41 * {!Array<!chrome.networkingPrivate.ThirdPartyVPNProperties>|undefined}
michaelpg 2017/03/01 23:27:59 nit: 4-space indent?
stevenjb 2017/03/02 00:25:17 Wasn't sure here. Done.
michaelpg 2017/03/02 01:25:00 There are almost no examples in the codebase. I fo
37 */ 42 */
38 networkStateList: { 43 thirdPartyVpnProviders: Array,
39 type: Array,
40 value: function() {
41 return [];
42 },
43 },
44
45 /**
46 * Type of networks in networkStateList. Used to initialte scanning.
47 * @type {CrOnc.Type}
48 */
49 networkType: String,
50 44
51 /** 45 /**
52 * Interface for networkingPrivate calls, passed from internet_page. 46 * Interface for networkingPrivate calls, passed from internet_page.
53 * @type {!NetworkingPrivate} 47 * @type {!NetworkingPrivate}
54 */ 48 */
55 networkingPrivate: Object, 49 networkingPrivate: Object,
56 50
57 /** 51 showSpinner: {
58 * The expanded state of the list of networks.
59 * @private
60 */
61 expanded_: {
62 type: Boolean, 52 type: Boolean,
53 notify: true,
63 value: false, 54 value: false,
64 observer: 'expandedChanged_',
65 }, 55 },
66 56
67 /** 57 /**
68 * Whether the list has been expanded. This is used to ensure the 58 * List of all network state data for the network type.
69 * iron-collapse section animates correctly. 59 * @private {!Array<!CrOnc.NetworkStateProperties>}
70 * @private
71 */ 60 */
72 wasExpanded_: { 61 networkStateList_: {
73 type: Boolean, 62 type: Array,
74 value: false, 63 value: function() {
64 return [];
65 },
66 },
67
68 /**
69 * Dictionary of lists of network states for third party VPNs.
70 * @private {!Object<!Array<!CrOnc.NetworkStateProperties>>}
71 */
72 thirdPartyVpns_: {
73 type: Object,
74 value: function() {
75 return {};
76 },
75 }, 77 },
76 }, 78 },
77 79
78 observers: ['updateScanning_(networkingPrivate, networkType, expanded_)'], 80 observers: ['updateScanning_(networkingPrivate, deviceState)'],
79 81
80 /** @private {number|null} */ 82 /** @private {number|null} */
81 scanIntervalId_: null, 83 scanIntervalId_: null,
82 84
85 /**
86 * Listener function for chrome.networkingPrivate.onNetworkListChanged event.
87 * @type {?function(!Array<string>)}
88 * @private
89 */
90 networkListChangedListener_: null,
91
92 /**
93 * settings.RouteObserverBehavior
94 * @param {!settings.Route} route
95 * @protected
96 */
97 currentRouteChanged: function(route) {
michaelpg 2017/03/01 23:27:59 nit: per the style guide, should be ordered after
stevenjb 2017/03/02 00:25:17 Done.
98 if (route != settings.Route.INTERNET_NETWORKS) {
99 this.stopScanning_();
100 return;
101 }
102 // Clear any stale data.
103 this.networkStateList_ = [];
104 this.thirdPartyVpns_ = {};
105 // Request the list of networks and start scanning of necessary.
michaelpg 2017/03/01 23:27:59 of necessary => if necessary
stevenjb 2017/03/02 00:25:17 Done.
106 this.getNetworkStateList_();
107 this.updateScanning_();
108 },
109
110 /** override */
111 attached: function() {
112 this.scanIntervalId_ = null;
113
114 this.networkListChangedListener_ = this.networkListChangedListener_ ||
115 this.onNetworkListChangedEvent_.bind(this);
116 this.networkingPrivate.onNetworkListChanged.addListener(
117 this.networkListChangedListener_);
118 },
119
83 /** override */ 120 /** override */
84 detached: function() { 121 detached: function() {
85 if (this.scanIntervalId_ !== null) { 122 this.stopScanning_();
86 window.clearInterval(this.scanIntervalId_); 123 this.networkingPrivate.onNetworkListChanged.removeListener(
87 this.scanIntervalId_ = null; 124 assert(this.networkListChangedListener_));
88 }
89 },
90
91 /** @private */
92 expandedChanged_: function() {
93 var type = this.deviceState ? this.deviceState.Type : '';
94 this.fire('expanded', {expanded: this.expanded_, type: type});
95 },
96
97 /** @private */
98 deviceStateChanged_: function() {
99 if (this.expanded_ && !this.deviceIsEnabled_(this.deviceState))
100 this.expanded_ = false;
101 }, 125 },
102 126
103 /** @private */ 127 /** @private */
104 updateScanning_: function() { 128 updateScanning_: function() {
105 if (this.scanIntervalId_ != null) { 129 if (!this.deviceState)
106 if (!this.expanded_) { 130 return;
107 window.clearInterval(this.scanIntervalId_); 131 if (this.deviceState.Type != CrOnc.Type.WI_FI) {
108 this.scanIntervalId_ = null; 132 // deviceState probably changed, re-request networks.
109 } 133 this.getNetworkStateList_();
110 return; 134 return;
111 } 135 }
112 if (!this.expanded_ || 136 this.showSpinner = !!this.deviceState.Scanning;
113 (this.networkType != CrOnc.Type.ALL && 137 this.startScanning_();
114 this.networkType != CrOnc.Type.WI_FI)) { 138 },
139
140 /** @private */
141 startScanning_: function() {
142 if (this.scanIntervalId_ != null)
115 return; 143 return;
116 }
117 /** @const */ var INTERVAL_MS = 10 * 1000; 144 /** @const */ var INTERVAL_MS = 10 * 1000;
118 this.networkingPrivate.requestNetworkScan(); 145 this.networkingPrivate.requestNetworkScan();
119 this.scanIntervalId_ = window.setInterval(function() { 146 this.scanIntervalId_ = window.setInterval(function() {
120 this.networkingPrivate.requestNetworkScan(); 147 this.networkingPrivate.requestNetworkScan();
121 }.bind(this), INTERVAL_MS); 148 }.bind(this), INTERVAL_MS);
122 }, 149 },
123 150
124 /** 151 /** @private */
125 * @return {boolean} Whether or not the scanning spinner should be visible. 152 stopScanning_: function() {
126 * @private 153 if (this.scanIntervalId_ == null)
127 */ 154 return;
128 scanningIsVisible_: function() { 155 window.clearInterval(this.scanIntervalId_);
129 return this.deviceState.Type == CrOnc.Type.WI_FI; 156 this.scanIntervalId_ = null;
130 }, 157 },
131 158
132 /** 159 /**
133 * @return {boolean} Whether or not the scanning spinner should be active. 160 * networkingPrivate.onNetworkListChanged event callback.
134 * @private 161 * @private
135 */ 162 */
136 scanningIsActive_: function() { 163 onNetworkListChangedEvent_: function() {
137 return !!this.expanded_ && !!this.deviceState.Scanning; 164 this.getNetworkStateList_();
165 },
166
167 /** @private */
168 getNetworkStateList_: function() {
169 if (!this.deviceState)
170 return;
171 var filter = {
172 networkType: this.deviceState.Type,
173 visible: true,
174 configured: false
175 };
176 this.networkingPrivate.getNetworks(filter, function(networkStates) {
177 if (this.deviceState.Type != CrOnc.Type.VPN) {
178 this.networkStateList_ = networkStates;
179 return;
180 }
181 // For VPNs, separate out third party VPNs.
182 var networkStateList = [];
183 var thirdPartyVpns = {};
184 for (var i = 0; i < networkStates.length; ++i) {
185 var state = networkStates[i];
186 var providerType = state.VPN && state.VPN.ThirdPartyVPN &&
187 state.VPN.ThirdPartyVPN.ProviderName;
188 if (providerType) {
189 thirdPartyVpns[providerType] = thirdPartyVpns[providerType] || [];
190 thirdPartyVpns[providerType].push(state);
191 } else {
192 networkStateList.push(state);
193 }
194 }
195 this.networkStateList_ = networkStateList;
196 this.thirdPartyVpns_ = thirdPartyVpns;
197 }.bind(this));
138 }, 198 },
139 199
140 /** 200 /**
141 * Show the <network-siminfo> element if this is a disabled and locked
142 * cellular device.
143 * @return {boolean}
144 * @private
145 */
146 showSimInfo_: function() {
147 var device = this.deviceState;
148 if (device.Type != CrOnc.Type.CELLULAR ||
149 this.deviceIsEnabled_(this.deviceState)) {
150 return false;
151 }
152 return device.SimPresent === false ||
153 device.SimLockType == CrOnc.LockType.PIN ||
154 device.SimLockType == CrOnc.LockType.PUK;
155 },
156
157 /**
158 * Returns a NetworkProperties object for <network-siminfo> built from
159 * the device properties (since there will be no active network).
160 * @param {!DeviceStateProperties} deviceState
161 * @return {!CrOnc.NetworkProperties}
162 * @private
163 */
164 getCellularState_: function(deviceState) {
165 return {
166 GUID: '',
167 Type: CrOnc.Type.CELLULAR,
168 Cellular: {
169 SIMLockStatus: {
170 LockType: deviceState.SimLockType || '',
171 LockEnabled: deviceState.SimLockType != CrOnc.LockType.NONE,
172 },
173 SIMPresent: deviceState.SimPresent,
174 },
175 };
176 },
177
178 /**
179 * @param {!DeviceStateProperties|undefined} deviceState 201 * @param {!DeviceStateProperties|undefined} deviceState
180 * @return {boolean} Whether or not the device state is enabled. 202 * @return {boolean} Whether or not the device state is enabled.
181 * @private 203 * @private
182 */ 204 */
183 deviceIsEnabled_: function(deviceState) { 205 deviceIsEnabled_: function(deviceState) {
184 return !!deviceState && 206 return !!deviceState &&
185 deviceState.State == chrome.networkingPrivate.DeviceStateType.ENABLED; 207 deviceState.State == chrome.networkingPrivate.DeviceStateType.ENABLED;
186 }, 208 },
187 209
188 /** 210 /**
189 * @return {boolean} Whether the dom-if for the network list should be true. 211 * @param {!DeviceStateProperties|undefined} deviceState
190 * The logic here is designed to allow the enclosed content to be stamped 212 * @param {string} onstr
191 * before it is expanded. 213 * @param {string} offstr
214 * @return {string}
192 * @private 215 * @private
193 */ 216 */
194 networksDomIfIsTrue_: function() { 217 getOffOnString_: function(deviceState, onstr, offstr) {
195 if (this.expanded_ == this.wasExpanded_) 218 return this.deviceIsEnabled_(deviceState) ? onstr : offstr;
196 return this.expanded_;
197 if (this.expanded_) {
198 Polymer.RenderStatus.afterNextRender(this, function() {
199 this.wasExpanded_ = true;
200 }.bind(this));
201 return true;
202 }
203 return this.wasExpanded_;
204 }, 219 },
205 220
206 /** 221 /**
207 * @param {boolean} expanded 222 * @param {?DeviceStateProperties} deviceState
208 * @param {boolean} wasExpanded
209 * @return {boolean} Whether the iron-collapse for the network list should
210 * be opened.
211 * @private
212 */
213 networksIronCollapseIsOpened_: function(expanded, wasExpanded) {
214 return expanded && wasExpanded;
215 },
216
217 /**
218 * @param {!DeviceStateProperties} deviceState
219 * @return {boolean} 223 * @return {boolean}
220 * @private 224 * @private
221 */ 225 */
222 enableToggleIsVisible_: function(deviceState) { 226 enableToggleIsVisible_: function(deviceState) {
223 return deviceState.Type != CrOnc.Type.ETHERNET && 227 return !!deviceState && deviceState.Type != CrOnc.Type.ETHERNET &&
224 deviceState.Type != CrOnc.Type.VPN; 228 deviceState.Type != CrOnc.Type.VPN;
225 }, 229 },
226 230
227 /** 231 /**
228 * @param {!DeviceStateProperties} deviceState 232 * @param {?DeviceStateProperties} deviceState
229 * @return {boolean} 233 * @return {boolean}
230 * @private 234 * @private
231 */ 235 */
232 enableToggleIsEnabled_: function(deviceState) { 236 enableToggleIsEnabled_: function(deviceState) {
233 return deviceState.State != 237 return !!deviceState &&
238 deviceState.State !=
234 chrome.networkingPrivate.DeviceStateType.PROHIBITED; 239 chrome.networkingPrivate.DeviceStateType.PROHIBITED;
235 }, 240 },
236 241
237 /** 242 /**
238 * @param {!DeviceStateProperties} deviceState 243 * @param {!DeviceStateProperties} deviceState
239 * @return {string} 244 * @return {string}
240 * @private 245 * @private
241 */ 246 */
242 getToggleA11yString_: function(deviceState) { 247 getToggleA11yString_: function(deviceState) {
243 if (!this.enableToggleIsVisible_(deviceState)) 248 if (!this.enableToggleIsVisible_(deviceState))
244 return ''; 249 return '';
245 switch (deviceState.Type) { 250 switch (deviceState.Type) {
246 case CrOnc.Type.CELLULAR: 251 case CrOnc.Type.CELLULAR:
247 return this.i18n('internetToggleMobileA11yLabel'); 252 return this.i18n('internetToggleMobileA11yLabel');
248 case CrOnc.Type.WI_FI: 253 case CrOnc.Type.WI_FI:
249 return this.i18n('internetToggleWiFiA11yLabel'); 254 return this.i18n('internetToggleWiFiA11yLabel');
250 case CrOnc.Type.WI_MAX: 255 case CrOnc.Type.WI_MAX:
251 return this.i18n('internetToggleWiMAXA11yLabel'); 256 return this.i18n('internetToggleWiMAXA11yLabel');
252 } 257 }
253 assertNotReached(); 258 assertNotReached();
254 return ''; 259 return '';
255 }, 260 },
256 261
257 /** 262 /**
258 * @return {boolean} Whether or not to show the UI to expand the list. 263 * @param {!chrome.networkingPrivate.ThirdPartyVPNProperties} vpnState
264 * @return {string}
259 * @private 265 * @private
260 */ 266 */
261 expandIsVisible_: function() { 267 getAddThirdPartyVpnA11yString: function(vpnState) {
michaelpg 2017/03/01 23:27:59 add trailing _ for private method
stevenjb 2017/03/02 00:25:17 Oops, good catch. No headphones here, I haven't te
262 if (!this.deviceIsEnabled_(this.deviceState)) 268 return this.i18n('internetAddThirdPartyVPN', vpnState.ProviderName);
263 return false;
264 var type = this.deviceState.Type;
265 var minLength =
266 (type == CrOnc.Type.WI_FI || type == CrOnc.Type.VPN) ? 1 : 2;
267 return this.networkStateList.length >= minLength;
268 }, 269 },
269 270
270 /** 271 /**
271 * @return {boolean} Whether or not to show the UI to show details. 272 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy
273 * @return {boolean}
272 * @private 274 * @private
273 */ 275 */
274 showDetailsIsVisible_: function() { 276 allowAddConnection_: function(globalPolicy) {
275 if (this.expandIsVisible_()) 277 return globalPolicy && !globalPolicy.AllowOnlyPolicyNetworksToConnect;
276 return false;
277 return this.deviceIsEnabled_(this.deviceState);
278 }, 278 },
279 279
280 /** 280 /**
281 * @param {!CrOnc.NetworkStateProperties} activeNetworkState 281 * @param {!DeviceStateProperties} deviceState
282 * @return {boolean} True if the known networks button should be shown. 282 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy
283 * @return {boolean}
283 * @private 284 * @private
284 */ 285 */
285 knownNetworksIsVisible_: function(activeNetworkState) { 286 showAddButton_: function(deviceState, globalPolicy) {
286 return !!activeNetworkState && activeNetworkState.Type == CrOnc.Type.WI_FI; 287 if (!deviceState || deviceState.Type != CrOnc.Type.WI_FI)
288 return false;
289 return this.allowAddConnection_(globalPolicy);
290 },
291
292 /** @private */
293 onAddButtonTap_: function() {
294 chrome.send('addNetwork', [this.deviceState.Type]);
287 }, 295 },
288 296
289 /** 297 /**
290 * Event triggered when the details div is tapped or Enter is pressed. 298 * @param {!{model:
291 * @param {!Event} event The enable button event. 299 * !{item: !chrome.networkingPrivate.ThirdPartyVPNProperties},
michaelpg 2017/03/01 23:27:59 nit: 4-space indent relative to the nearest openin
stevenjb 2017/03/02 00:25:17 Hm. OK, done. (FWIW that pattern makes this sort o
michaelpg 2017/03/02 01:25:00 indenting only 4 characters (relative to @param) w
300 * }} event
292 * @private 301 * @private
293 */ 302 */
294 onDetailsTap_: function(event) { 303 onAddThirdPartyVpnTap_: function(event) {
295 if ((event.target && event.target.id == 'expandListButton') || 304 var provider = event.model.item;
296 (this.deviceState && !this.deviceIsEnabled_(this.deviceState))) { 305 chrome.send('addNetwork', [CrOnc.Type.VPN, provider.ExtensionID]);
297 // Already handled or disabled, do nothing.
298 return;
299 }
300 if (this.expandIsVisible_()) {
301 // Expandable, toggle expand.
302 this.expanded_ = !this.expanded_;
303 return;
304 }
305 // Not expandable, fire 'selected' with |activeNetworkState|.
306 this.fire('selected', this.activeNetworkState);
307 }, 306 },
308 307
309 /** 308 /**
310 * @param {!Event} event The enable button event. 309 * @param {!DeviceStateProperties} deviceState
310 * @return {boolean}
311 * @private 311 * @private
312 */ 312 */
313 onShowDetailsTap_: function(event) { 313 knownNetworksIsVisible_: function(deviceState) {
314 if (!this.activeNetworkState.GUID) 314 return deviceState && deviceState.Type == CrOnc.Type.WI_FI;
315 return;
316 this.fire('show-detail', this.activeNetworkState);
317 event.stopPropagation();
318 }, 315 },
319 316
320 /** 317 /**
321 * Event triggered when the known networks button is tapped. 318 * Event triggered when the known networks button is tapped.
322 * @private 319 * @private
323 */ 320 */
324 onKnownNetworksTap_: function() { 321 onKnownNetworksTap_: function() {
325 this.fire('show-known-networks', {type: CrOnc.Type.WI_FI}); 322 this.fire('show-known-networks', {type: CrOnc.Type.WI_FI});
326 }, 323 },
327 324
328 /** 325 /**
329 * Event triggered when the enable button is toggled. 326 * Event triggered when the enable button is toggled.
330 * @param {!Event} event 327 * @param {!Event} event
331 * @private 328 * @private
332 */ 329 */
333 onDeviceEnabledTap_: function(event) { 330 onDeviceEnabledTap_: function(event) {
331 assert(this.deviceState);
334 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState); 332 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState);
335 var type = this.deviceState ? this.deviceState.Type : ''; 333 var type = this.deviceState ? this.deviceState.Type : '';
michaelpg 2017/03/01 23:27:59 guaranteed to be true after assert (assuming devic
stevenjb 2017/03/02 00:25:17 Done.
336 this.fire( 334 this.fire(
337 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type}); 335 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type});
338 // Make sure this does not propagate to onDetailsTap_. 336 // Make sure this does not propagate to onDetailsTap_.
339 event.stopPropagation(); 337 event.stopPropagation();
340 }, 338 },
339
340 /**
341 * @param {!Object<!Array<!CrOnc.NetworkStateProperties>>} thirdPartyVpns
342 * @param {!chrome.networkingPrivate.ThirdPartyVPNProperties} vpnState
343 * @return {!Array<!CrOnc.NetworkStateProperties>}
344 * @private
345 */
346 getThirdPartyVpnNetworks_: function(thirdPartyVpns, vpnState) {
347 return thirdPartyVpns[vpnState.ProviderName] || [];
348 },
349
350 /**
351 * @param {!Object<!Array<!CrOnc.NetworkStateProperties>>} thirdPartyVpns
352 * @param {!chrome.networkingPrivate.ThirdPartyVPNProperties} vpnState
353 * @return {boolean}
354 * @private
355 */
356 haveThirdPartyVpnNetwork_: function(thirdPartyVpns, vpnState) {
357 var list = this.getThirdPartyVpnNetworks_(thirdPartyVpns, vpnState);
358 return !!list.length;
359 },
360
361 /**
362 * Event triggered when a network list item is selected.
363 * @param {!{target: HTMLElement, detail: !CrOnc.NetworkStateProperties}} e
364 * @private
365 */
366 onNetworkSelected_: function(e) {
367 assert(this.globalPolicy);
368 assert(this.defaultNetwork !== undefined);
369 var state = e.detail;
370 e.target.blur();
371 if (this.canConnect_(state, this.globalPolicy, this.defaultNetwork)) {
372 this.connectToNetwork_(state);
373 return;
374 }
375 this.fire('show-detail', state);
376 },
377
378 /**
379 * Determines whether or not a network state can be connected to.
380 * @param {!CrOnc.NetworkStateProperties} state The network state.
381 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy
382 * @param {?CrOnc.NetworkStateProperties} defaultNetwork
383 * @private
384 */
385 canConnect_: function(state, globalPolicy, defaultNetwork) {
386 if (state.Type == CrOnc.Type.WI_FI && globalPolicy &&
387 globalPolicy.AllowOnlyPolicyNetworksToConnect &&
388 !this.isPolicySource(state.Source)) {
389 return false;
390 }
391 if (state.Type == CrOnc.Type.VPN &&
392 (!defaultNetwork ||
393 defaultNetwork.ConnectionState != CrOnc.ConnectionState.CONNECTED)) {
394 return false;
395 }
396 return state.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED;
michaelpg 2017/03/01 23:27:59 opt nit: I would make this just another condition,
stevenjb 2017/03/02 00:25:17 Done.
397 },
398
399 /**
400 * Handles UI requests to connect to a network.
401 * TODO(stevenjb): Handle Cellular activation, etc.
402 * @param {!CrOnc.NetworkStateProperties} state The network state.
403 * @private
404 */
405 connectToNetwork_: function(state) {
406 this.networkingPrivate.startConnect(state.GUID, function() {
407 if (chrome.runtime.lastError) {
408 var message = chrome.runtime.lastError.message;
409 if (message != 'connecting') {
410 console.error(
411 'Unexpected networkingPrivate.startConnect error: ' + message +
412 'For: ' + state.GUID);
413 }
414 }
415 });
416 },
417
418 /**
419 * @param {*} lhs
420 * @param {*} rhs
421 * @return {boolean}
422 */
423 isEqual_: function(lhs, rhs) {
424 return lhs === rhs;
425 },
341 }); 426 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698