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

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

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge 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 6 * @fileoverview
7 * 'settings-internet-detail' is the settings subpage containing details 7 * 'settings-internet-detail' is the settings subpage containing details
8 * for a network. 8 * for a network.
9 */ 9 */
10 (function() { 10 (function() {
11 'use strict'; 11 'use strict';
12 12
13 /** @const */ var CARRIER_VERIZON = 'Verizon Wireless'; 13 /** @const */ var CARRIER_VERIZON = 'Verizon Wireless';
14 14
15 Polymer({ 15 Polymer({
16 is: 'settings-internet-detail-page', 16 is: 'settings-internet-detail-page',
17 17
18 behaviors: 18 behaviors:
19 [CrPolicyNetworkBehavior, settings.RouteObserverBehavior, I18nBehavior], 19 [CrPolicyNetworkBehavior, settings.RouteObserverBehavior, I18nBehavior],
20 20
21 properties: { 21 properties: {
22 /** The network GUID to display details for. */ 22 /** The network GUID to display details for. */
23 guid: String, 23 guid: String,
24 24
25 /** 25 /**
26 * The current properties for the network matching |guid|. 26 * The current properties for the network matching |guid|.
27 * @type {!CrOnc.NetworkProperties|undefined} 27 * @type {!CrOnc.NetworkProperties|undefined}
28 */ 28 */
29 networkProperties: { 29 networkProperties: {
30 type: Object, 30 type: Object,
31 observer: 'networkPropertiesChanged_', 31 observer: 'networkPropertiesChanged_',
32 },
33
34 /** Preferences state. */
35 prefs: {
36 type: Object,
37 notify: true,
38 },
39
40 /**
41 * Whether the user is a secondary user.
42 * @private
43 */
44 isSecondaryUser_: {
45 type: Boolean,
46 value: function() {
47 return loadTimeData.getBoolean('isSecondaryUser');
48 }, 32 },
49 readOnly: true, 33
50 }, 34 /** Preferences state. */
51 35 prefs: {
52 /** 36 type: Object,
53 * Email address for the primary user. 37 notify: true,
54 * @private
55 */
56 primaryUserEmail_: {
57 type: String,
58 value: function() {
59 return loadTimeData.getBoolean('isSecondaryUser') ?
60 loadTimeData.getString('primaryUserEmail') : '';
61 }, 38 },
62 readOnly: true, 39
63 }, 40 /**
64 41 * Whether the user is a secondary user.
65 /** 42 * @private
66 * Highest priority connected network or null. 43 */
67 * @type {?CrOnc.NetworkStateProperties} 44 isSecondaryUser_: {
68 */ 45 type: Boolean,
69 defaultNetwork: { 46 value: function() {
70 type: Object, 47 return loadTimeData.getBoolean('isSecondaryUser');
71 value: null, 48 },
72 }, 49 readOnly: true,
73
74 /**
75 * Interface for networkingPrivate calls, passed from internet_page.
76 * @type {NetworkingPrivate}
77 */
78 networkingPrivate: Object,
79
80 /**
81 * The network AutoConnect state.
82 * @private
83 */
84 autoConnect_: {
85 type: Boolean,
86 value: false,
87 observer: 'autoConnectChanged_',
88 },
89
90 /**
91 * The network preferred state.
92 * @private
93 */
94 preferNetwork_: {
95 type: Boolean,
96 value: false,
97 observer: 'preferNetworkChanged_',
98 },
99
100 /**
101 * The network IP Address.
102 * @private
103 */
104 IPAddress_: {
105 type: String,
106 value: '',
107 },
108
109 /** @private */
110 advancedExpanded_: Boolean,
111
112 /**
113 * Object providing network type values for data binding.
114 * @const
115 * @private
116 */
117 NetworkType_: {
118 type: Object,
119 value: {
120 CELLULAR: CrOnc.Type.CELLULAR,
121 ETHERNET: CrOnc.Type.ETHERNET,
122 VPN: CrOnc.Type.VPN,
123 WIFI: CrOnc.Type.WI_FI,
124 WIMAX: CrOnc.Type.WI_MAX,
125 }, 50 },
126 readOnly: true 51
127 }, 52 /**
128 }, 53 * Email address for the primary user.
129 54 * @private
130 /** 55 */
131 * Listener function for chrome.networkingPrivate.onNetworksChanged event. 56 primaryUserEmail_: {
132 * @type {?function(!Array<string>)} 57 type: String,
133 * @private 58 value: function() {
134 */ 59 return loadTimeData.getBoolean('isSecondaryUser') ?
135 networksChangedListener_: null, 60 loadTimeData.getString('primaryUserEmail') :
136 61 '';
137 /** 62 },
138 * settings.RouteObserverBehavior 63 readOnly: true,
139 * @param {!settings.Route} route 64 },
140 * @protected 65
141 */ 66 /**
142 currentRouteChanged: function(route) { 67 * Highest priority connected network or null.
143 if (route != settings.Route.NETWORK_DETAIL) { 68 * @type {?CrOnc.NetworkStateProperties}
144 if (this.networksChangedListener_) { 69 */
145 this.networkingPrivate.onNetworksChanged.removeListener( 70 defaultNetwork: {
71 type: Object,
72 value: null,
73 },
74
75 /**
76 * Interface for networkingPrivate calls, passed from internet_page.
77 * @type {NetworkingPrivate}
78 */
79 networkingPrivate: Object,
80
81 /**
82 * The network AutoConnect state.
83 * @private
84 */
85 autoConnect_: {
86 type: Boolean,
87 value: false,
88 observer: 'autoConnectChanged_',
89 },
90
91 /**
92 * The network preferred state.
93 * @private
94 */
95 preferNetwork_: {
96 type: Boolean,
97 value: false,
98 observer: 'preferNetworkChanged_',
99 },
100
101 /**
102 * The network IP Address.
103 * @private
104 */
105 IPAddress_: {
106 type: String,
107 value: '',
108 },
109
110 /** @private */
111 advancedExpanded_: Boolean,
112
113 /**
114 * Object providing network type values for data binding.
115 * @const
116 * @private
117 */
118 NetworkType_: {
119 type: Object,
120 value: {
121 CELLULAR: CrOnc.Type.CELLULAR,
122 ETHERNET: CrOnc.Type.ETHERNET,
123 VPN: CrOnc.Type.VPN,
124 WIFI: CrOnc.Type.WI_FI,
125 WIMAX: CrOnc.Type.WI_MAX,
126 },
127 readOnly: true
128 },
129 },
130
131 /**
132 * Listener function for chrome.networkingPrivate.onNetworksChanged event.
133 * @type {?function(!Array<string>)}
134 * @private
135 */
136 networksChangedListener_: null,
137
138 /**
139 * settings.RouteObserverBehavior
140 * @param {!settings.Route} route
141 * @protected
142 */
143 currentRouteChanged: function(route) {
144 if (route != settings.Route.NETWORK_DETAIL) {
145 if (this.networksChangedListener_) {
146 this.networkingPrivate.onNetworksChanged.removeListener(
147 this.networksChangedListener_);
148 this.networksChangedListener_ = null;
149 }
150 return;
151 }
152 if (!this.networksChangedListener_) {
153 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this);
154 this.networkingPrivate.onNetworksChanged.addListener(
146 this.networksChangedListener_); 155 this.networksChangedListener_);
147 this.networksChangedListener_ = null; 156 }
148 } 157 let queryParams = settings.getQueryParameters();
149 return; 158 this.guid = queryParams.get('guid') || '';
150 } 159 if (!this.guid) {
151 if (!this.networksChangedListener_) { 160 console.error('No guid specified for page:' + route);
152 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this); 161 this.close_();
153 this.networkingPrivate.onNetworksChanged.addListener( 162 }
154 this.networksChangedListener_);
155 }
156 let queryParams = settings.getQueryParameters();
157 this.guid = queryParams.get('guid') || '';
158 if (!this.guid) {
159 console.error('No guid specified for page:' + route);
160 this.close_();
161 }
162 this.getNetworkDetails_();
163 },
164
165 /** @private */
166 close_: function() {
167 // Delay navigating until the next render frame to allow other subpages to
168 // load first.
169 setTimeout(function() {
170 settings.navigateTo(settings.Route.INTERNET);
171 });
172 },
173
174 /** @private */
175 networkPropertiesChanged_: function() {
176 if (!this.networkProperties)
177 return;
178
179 // Update autoConnect if it has changed. Default value is false.
180 var autoConnect = CrOnc.getAutoConnect(this.networkProperties);
181 if (autoConnect != this.autoConnect_)
182 this.autoConnect_ = autoConnect;
183
184 // Update preferNetwork if it has changed. Default value is false.
185 var priority = /** @type {number} */ (
186 CrOnc.getActiveValue(this.networkProperties.Priority) || 0);
187 var preferNetwork = priority > 0;
188 if (preferNetwork != this.preferNetwork_)
189 this.preferNetwork_ = preferNetwork;
190
191 // Set the IPAddress property to the IPV4 Address.
192 var ipv4 =
193 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4);
194 this.IPAddress_ = (ipv4 && ipv4.IPAddress) || '';
195
196 // Update the detail page title.
197 this.parentNode.pageTitle =
198 CrOnc.getNetworkName(this.networkProperties, this);
199 },
200
201 /** @private */
202 autoConnectChanged_: function() {
203 if (!this.networkProperties || !this.guid)
204 return;
205 var onc = this.getEmptyNetworkProperties_();
206 CrOnc.setTypeProperty(onc, 'AutoConnect', this.autoConnect_);
207 this.setNetworkProperties_(onc);
208 },
209
210 /** @private */
211 preferNetworkChanged_: function() {
212 if (!this.networkProperties || !this.guid)
213 return;
214 var onc = this.getEmptyNetworkProperties_();
215 onc.Priority = this.preferNetwork_ ? 1 : 0;
216 this.setNetworkProperties_(onc);
217 },
218
219 /**
220 * networkingPrivate.onNetworksChanged event callback.
221 * @param {!Array<string>} networkIds The list of changed network GUIDs.
222 * @private
223 */
224 onNetworksChangedEvent_: function(networkIds) {
225 if (networkIds.indexOf(this.guid) != -1)
226 this.getNetworkDetails_(); 163 this.getNetworkDetails_();
227 }, 164 },
228 165
229 /** 166 /** @private */
230 * Calls networkingPrivate.getProperties for this.guid. 167 close_: function() {
231 * @private 168 // Delay navigating until the next render frame to allow other subpages to
232 */ 169 // load first.
233 getNetworkDetails_: function() { 170 setTimeout(function() {
234 assert(!!this.guid); 171 settings.navigateTo(settings.Route.INTERNET);
235 if (this.isSecondaryUser_) { 172 });
236 this.networkingPrivate.getState( 173 },
237 this.guid, this.getStateCallback_.bind(this)); 174
238 } else { 175 /** @private */
239 this.networkingPrivate.getManagedProperties( 176 networkPropertiesChanged_: function() {
240 this.guid, this.getPropertiesCallback_.bind(this)); 177 if (!this.networkProperties)
241 } 178 return;
242 }, 179
243 180 // Update autoConnect if it has changed. Default value is false.
244 /** 181 var autoConnect = CrOnc.getAutoConnect(this.networkProperties);
245 * networkingPrivate.getProperties callback. 182 if (autoConnect != this.autoConnect_)
246 * @param {CrOnc.NetworkProperties} properties The network properties. 183 this.autoConnect_ = autoConnect;
247 * @private 184
248 */ 185 // Update preferNetwork if it has changed. Default value is false.
249 getPropertiesCallback_: function(properties) { 186 var priority = /** @type {number} */ (
250 this.networkProperties = properties; 187 CrOnc.getActiveValue(this.networkProperties.Priority) || 0);
251 if (!properties) { 188 var preferNetwork = priority > 0;
252 // If |properties| is null, the network is no longer visible, close this. 189 if (preferNetwork != this.preferNetwork_)
253 console.error('Network no longer exists: ' + this.guid); 190 this.preferNetwork_ = preferNetwork;
254 this.close_(); 191
255 } 192 // Set the IPAddress property to the IPV4 Address.
256 }, 193 var ipv4 =
257 194 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4);
258 /** 195 this.IPAddress_ = (ipv4 && ipv4.IPAddress) || '';
259 * networkingPrivate.getState callback. 196
260 * @param {CrOnc.NetworkStateProperties} state The network state properties. 197 // Update the detail page title.
261 * @private 198 this.parentNode.pageTitle =
262 */ 199 CrOnc.getNetworkName(this.networkProperties, this);
263 getStateCallback_: function(state) { 200 },
264 if (!state) { 201
265 // If |state| is null, the network is no longer visible, close this. 202 /** @private */
266 console.error('Network no longer exists: ' + this.guid); 203 autoConnectChanged_: function() {
267 this.networkProperties = undefined; 204 if (!this.networkProperties || !this.guid)
268 this.close_(); 205 return;
269 } 206 var onc = this.getEmptyNetworkProperties_();
270 this.networkProperties = { 207 CrOnc.setTypeProperty(onc, 'AutoConnect', this.autoConnect_);
271 GUID: state.GUID, 208 this.setNetworkProperties_(onc);
272 Type: state.Type, 209 },
273 Connectable: state.Connectable, 210
274 ConnectionState: state.ConnectionState, 211 /** @private */
275 }; 212 preferNetworkChanged_: function() {
276 }, 213 if (!this.networkProperties || !this.guid)
277 214 return;
278 /** 215 var onc = this.getEmptyNetworkProperties_();
279 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC 216 onc.Priority = this.preferNetwork_ ? 1 : 0;
280 * network properties. 217 this.setNetworkProperties_(onc);
281 * @private 218 },
282 */ 219
283 setNetworkProperties_: function(onc) { 220 /**
284 assert(!!this.guid); 221 * networkingPrivate.onNetworksChanged event callback.
285 this.networkingPrivate.setProperties(this.guid, onc, function() { 222 * @param {!Array<string>} networkIds The list of changed network GUIDs.
286 if (chrome.runtime.lastError) { 223 * @private
287 // An error typically indicates invalid input; request the properties 224 */
288 // to update any invalid fields. 225 onNetworksChangedEvent_: function(networkIds) {
226 if (networkIds.indexOf(this.guid) != -1)
289 this.getNetworkDetails_(); 227 this.getNetworkDetails_();
290 } 228 },
291 }.bind(this)); 229
292 }, 230 /**
293 231 * Calls networkingPrivate.getProperties for this.guid.
294 /** 232 * @private
233 */
234 getNetworkDetails_: function() {
235 assert(!!this.guid);
236 if (this.isSecondaryUser_) {
237 this.networkingPrivate.getState(
238 this.guid, this.getStateCallback_.bind(this));
239 } else {
240 this.networkingPrivate.getManagedProperties(
241 this.guid, this.getPropertiesCallback_.bind(this));
242 }
243 },
244
245 /**
246 * networkingPrivate.getProperties callback.
247 * @param {CrOnc.NetworkProperties} properties The network properties.
248 * @private
249 */
250 getPropertiesCallback_: function(properties) {
251 this.networkProperties = properties;
252 if (!properties) {
253 // If |properties| is null, the network is no longer visible, close
254 // this.
255 console.error('Network no longer exists: ' + this.guid);
256 this.close_();
257 }
258 },
259
260 /**
261 * networkingPrivate.getState callback.
262 * @param {CrOnc.NetworkStateProperties} state The network state properties.
263 * @private
264 */
265 getStateCallback_: function(state) {
266 if (!state) {
267 // If |state| is null, the network is no longer visible, close this.
268 console.error('Network no longer exists: ' + this.guid);
269 this.networkProperties = undefined;
270 this.close_();
271 }
272 this.networkProperties = {
273 GUID: state.GUID,
274 Type: state.Type,
275 Connectable: state.Connectable,
276 ConnectionState: state.ConnectionState,
277 };
278 },
279
280 /**
281 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC
282 * network properties.
283 * @private
284 */
285 setNetworkProperties_: function(onc) {
286 assert(!!this.guid);
287 this.networkingPrivate.setProperties(this.guid, onc, function() {
288 if (chrome.runtime.lastError) {
289 // An error typically indicates invalid input; request the properties
290 // to update any invalid fields.
291 this.getNetworkDetails_();
292 }
293 }.bind(this));
294 },
295
296 /**
295 * @return {!chrome.networkingPrivate.NetworkConfigProperties} An ONC 297 * @return {!chrome.networkingPrivate.NetworkConfigProperties} An ONC
296 * dictionary with just the Type property set. Used for passing properties 298 * dictionary with just the Type property set. Used for passing properties
297 * to setNetworkProperties_. 299 * to setNetworkProperties_.
298 * @private 300 * @private
299 */ 301 */
300 getEmptyNetworkProperties_: function() { 302 getEmptyNetworkProperties_: function() {
301 return {Type: this.networkProperties.Type}; 303 return {Type: this.networkProperties.Type};
302 }, 304 },
303 305
304 /** 306 /**
305 * @return {string} The text to display for the network connection state. 307 * @return {string} The text to display for the network connection state.
306 * @private 308 * @private
307 */ 309 */
308 getStateText_: function() { 310 getStateText_: function() {
309 return this.i18n('Onc' + this.networkProperties.ConnectionState); 311 return this.i18n('Onc' + this.networkProperties.ConnectionState);
310 }, 312 },
311 313
312 /** 314 /**
313 * @return {boolean} True if the network is connected. 315 * @return {boolean} True if the network is connected.
314 * @private 316 * @private
315 */ 317 */
316 isConnectedState_: function() { 318 isConnectedState_: function() {
317 return this.networkProperties.ConnectionState == 319 return this.networkProperties.ConnectionState ==
318 CrOnc.ConnectionState.CONNECTED; 320 CrOnc.ConnectionState.CONNECTED;
319 }, 321 },
320 322
321 /** 323 /**
322 * @return {boolean} 324 * @return {boolean}
323 * @private 325 * @private
324 */ 326 */
325 isRemembered_: function() { 327 isRemembered_: function() {
326 var source = this.networkProperties.Source; 328 var source = this.networkProperties.Source;
327 return !!source && source != CrOnc.Source.NONE; 329 return !!source && source != CrOnc.Source.NONE;
328 }, 330 },
329 331
330 /** 332 /**
331 * @return {boolean} 333 * @return {boolean}
332 * @private 334 * @private
333 */ 335 */
334 isRememberedOrConnected_: function() { 336 isRememberedOrConnected_: function() {
335 return this.isRemembered_() || this.isConnectedState_(); 337 return this.isRemembered_() || this.isConnectedState_();
336 }, 338 },
337 339
338 /** 340 /**
339 * @return {boolean} 341 * @return {boolean}
340 * @private 342 * @private
341 */ 343 */
342 showConnect_: function() { 344 showConnect_: function() {
343 return this.networkProperties.Type != CrOnc.Type.ETHERNET && 345 return this.networkProperties.Type != CrOnc.Type.ETHERNET &&
344 this.networkProperties.ConnectionState == 346 this.networkProperties.ConnectionState ==
345 CrOnc.ConnectionState.NOT_CONNECTED; 347 CrOnc.ConnectionState.NOT_CONNECTED;
346 }, 348 },
347 349
348 /** 350 /**
349 * @return {boolean} 351 * @return {boolean}
350 * @private 352 * @private
351 */ 353 */
352 showDisconnect_: function() { 354 showDisconnect_: function() {
353 return this.networkProperties.Type != CrOnc.Type.ETHERNET && 355 return this.networkProperties.Type != CrOnc.Type.ETHERNET &&
354 this.networkProperties.ConnectionState != 356 this.networkProperties.ConnectionState !=
355 CrOnc.ConnectionState.NOT_CONNECTED; 357 CrOnc.ConnectionState.NOT_CONNECTED;
356 }, 358 },
357 359
358 /** 360 /**
359 * @return {boolean} 361 * @return {boolean}
360 * @private 362 * @private
361 */ 363 */
362 showForget_: function() { 364 showForget_: function() {
363 var type = this.networkProperties.Type; 365 var type = this.networkProperties.Type;
364 if (type != CrOnc.Type.WI_FI && type != CrOnc.Type.VPN) 366 if (type != CrOnc.Type.WI_FI && type != CrOnc.Type.VPN)
365 return false; 367 return false;
366 return this.isRemembered_(); 368 return this.isRemembered_();
367 }, 369 },
368 370
369 /** 371 /**
370 * @return {boolean} 372 * @return {boolean}
371 * @private 373 * @private
372 */ 374 */
373 showActivate_: function() { 375 showActivate_: function() {
374 if (this.networkProperties.Type != CrOnc.Type.CELLULAR) 376 if (this.networkProperties.Type != CrOnc.Type.CELLULAR)
375 return false; 377 return false;
376 var activation = this.networkProperties.Cellular.ActivationState; 378 var activation = this.networkProperties.Cellular.ActivationState;
377 return activation == CrOnc.ActivationState.NOT_ACTIVATED || 379 return activation == CrOnc.ActivationState.NOT_ACTIVATED ||
378 activation == CrOnc.ActivationState.PARTIALLY_ACTIVATED; 380 activation == CrOnc.ActivationState.PARTIALLY_ACTIVATED;
379 }, 381 },
380 382
381 /** 383 /**
382 * @return {boolean} 384 * @return {boolean}
383 * @private 385 * @private
384 */ 386 */
385 showConfigure_: function() { 387 showConfigure_: function() {
386 var type = this.networkProperties.Type; 388 var type = this.networkProperties.Type;
387 if (type == CrOnc.Type.CELLULAR || type == CrOnc.Type.WI_MAX) 389 if (type == CrOnc.Type.CELLULAR || type == CrOnc.Type.WI_MAX)
388 return false; 390 return false;
389 if (type == CrOnc.Type.WI_FI && 391 if (type == CrOnc.Type.WI_FI &&
390 this.networkProperties.ConnectionState != 392 this.networkProperties.ConnectionState !=
391 CrOnc.ConnectionState.NOT_CONNECTED) { 393 CrOnc.ConnectionState.NOT_CONNECTED) {
392 return false; 394 return false;
393 } 395 }
394 return this.isRemembered_(); 396 return this.isRemembered_();
395 }, 397 },
396 398
397 /** 399 /**
398 * @return {boolean} 400 * @return {boolean}
399 * @private 401 * @private
400 */ 402 */
401 showViewAccount_: function() { 403 showViewAccount_: function() {
402 // Show either the 'Activate' or the 'View Account' button. 404 // Show either the 'Activate' or the 'View Account' button.
403 if (this.showActivate_()) 405 if (this.showActivate_())
404 return false; 406 return false;
405 407
406 if (this.networkProperties.Type != CrOnc.Type.CELLULAR || 408 if (this.networkProperties.Type != CrOnc.Type.CELLULAR ||
407 !this.networkProperties.Cellular) { 409 !this.networkProperties.Cellular) {
408 return false; 410 return false;
409 } 411 }
410 412
411 // Only show if online payment URL is provided or the carrier is Verizon. 413 // Only show if online payment URL is provided or the carrier is Verizon.
412 var carrier = CrOnc.getActiveValue(this.networkProperties.Cellular.Carrier); 414 var carrier =
413 if (carrier != CARRIER_VERIZON) { 415 CrOnc.getActiveValue(this.networkProperties.Cellular.Carrier);
414 var paymentPortal = this.networkProperties.Cellular.PaymentPortal; 416 if (carrier != CARRIER_VERIZON) {
415 if (!paymentPortal || !paymentPortal.Url) 417 var paymentPortal = this.networkProperties.Cellular.PaymentPortal;
416 return false; 418 if (!paymentPortal || !paymentPortal.Url)
417 } 419 return false;
418 420 }
419 // Only show for connected networks or LTE networks with a valid MDN. 421
420 if (!this.isConnectedState_()) { 422 // Only show for connected networks or LTE networks with a valid MDN.
421 var technology = this.networkProperties.Cellular.NetworkTechnology; 423 if (!this.isConnectedState_()) {
422 if (technology != CrOnc.NetworkTechnology.LTE && 424 var technology = this.networkProperties.Cellular.NetworkTechnology;
423 technology != CrOnc.NetworkTechnology.LTE_ADVANCED) { 425 if (technology != CrOnc.NetworkTechnology.LTE &&
424 return false; 426 technology != CrOnc.NetworkTechnology.LTE_ADVANCED) {
425 } 427 return false;
426 if (!this.networkProperties.Cellular.MDN) 428 }
427 return false; 429 if (!this.networkProperties.Cellular.MDN)
428 } 430 return false;
429 431 }
430 return true; 432
431 }, 433 return true;
432 434 },
433 /** 435
436 /**
434 * @return {boolean} Whether or not to enable the network connect button. 437 * @return {boolean} Whether or not to enable the network connect button.
435 * @private 438 * @private
436 */ 439 */
437 enableConnect_: function() { 440 enableConnect_: function() {
438 if (!this.showConnect_()) 441 if (!this.showConnect_())
439 return false; 442 return false;
440 if (this.networkProperties.Type == CrOnc.Type.CELLULAR && 443 if (this.networkProperties.Type == CrOnc.Type.CELLULAR &&
441 CrOnc.isSimLocked(this.networkProperties)) { 444 CrOnc.isSimLocked(this.networkProperties)) {
442 return false; 445 return false;
443 } 446 }
444 if (this.networkProperties.Type == CrOnc.Type.VPN && !this.defaultNetwork) 447 if (this.networkProperties.Type == CrOnc.Type.VPN && !this.defaultNetwork)
445 return false; 448 return false;
446 return true; 449 return true;
447 }, 450 },
448 451
449 /** @private */ 452 /** @private */
450 onConnectTap_: function() { 453 onConnectTap_: function() {
451 this.networkingPrivate.startConnect(this.guid); 454 this.networkingPrivate.startConnect(this.guid);
452 }, 455 },
453 456
454 /** @private */ 457 /** @private */
455 onDisconnectTap_: function() { 458 onDisconnectTap_: function() {
456 this.networkingPrivate.startDisconnect(this.guid); 459 this.networkingPrivate.startDisconnect(this.guid);
457 }, 460 },
458 461
459 /** @private */ 462 /** @private */
460 onForgetTap_: function() { 463 onForgetTap_: function() {
461 this.networkingPrivate.forgetNetwork(this.guid); 464 this.networkingPrivate.forgetNetwork(this.guid);
462 // A forgotten network no longer has a valid GUID, close the subpage. 465 // A forgotten network no longer has a valid GUID, close the subpage.
463 this.close_(); 466 this.close_();
464 }, 467 },
465 468
466 /** @private */ 469 /** @private */
467 onActivateTap_: function() { 470 onActivateTap_: function() {
468 this.networkingPrivate.startActivate(this.guid); 471 this.networkingPrivate.startActivate(this.guid);
469 }, 472 },
470 473
471 /** @private */ 474 /** @private */
472 onConfigureTap_: function() { 475 onConfigureTap_: function() {
473 chrome.send('configureNetwork', [this.guid]); 476 chrome.send('configureNetwork', [this.guid]);
474 }, 477 },
475 478
476 /** @private */ 479 /** @private */
477 onViewAccountTap_: function() { 480 onViewAccountTap_: function() {
478 // startActivate() will show the account page for activated networks. 481 // startActivate() will show the account page for activated networks.
479 this.networkingPrivate.startActivate(this.guid); 482 this.networkingPrivate.startActivate(this.guid);
480 }, 483 },
481 484
482 /** 485 /**
483 * @param {Event} event 486 * @param {Event} event
484 * @private 487 * @private
485 */ 488 */
486 toggleAdvancedExpanded_: function(event) { 489 toggleAdvancedExpanded_: function(event) {
487 if (event.target.id == 'expandButton') 490 if (event.target.id == 'expandButton')
488 return; // Already handled. 491 return; // Already handled.
489 this.advancedExpanded_ = !this.advancedExpanded_; 492 this.advancedExpanded_ = !this.advancedExpanded_;
490 }, 493 },
491 494
492 /** 495 /**
493 * Event triggered for elements associated with network properties. 496 * Event triggered for elements associated with network properties.
494 * @param {!{detail: !{field: string, value: (string|!Object)}}} event 497 * @param {!{detail: !{field: string, value: (string|!Object)}}} event
495 * @private 498 * @private
496 */ 499 */
497 onNetworkPropertyChange_: function(event) { 500 onNetworkPropertyChange_: function(event) {
498 if (!this.networkProperties) 501 if (!this.networkProperties)
499 return; 502 return;
500 var field = event.detail.field; 503 var field = event.detail.field;
501 var value = event.detail.value; 504 var value = event.detail.value;
502 var onc = this.getEmptyNetworkProperties_(); 505 var onc = this.getEmptyNetworkProperties_();
503 if (field == 'APN') { 506 if (field == 'APN') {
504 CrOnc.setTypeProperty(onc, 'APN', value); 507 CrOnc.setTypeProperty(onc, 'APN', value);
505 } else if (field == 'SIMLockStatus') { 508 } else if (field == 'SIMLockStatus') {
506 CrOnc.setTypeProperty(onc, 'SIMLockStatus', value); 509 CrOnc.setTypeProperty(onc, 'SIMLockStatus', value);
507 } else { 510 } else {
508 console.error('Unexpected property change event: ' + field); 511 console.error('Unexpected property change event: ' + field);
509 return; 512 return;
510 } 513 }
511 this.setNetworkProperties_(onc); 514 this.setNetworkProperties_(onc);
512 }, 515 },
513 516
514 /** 517 /**
515 * Event triggered when the IP Config or NameServers element changes. 518 * Event triggered when the IP Config or NameServers element changes.
516 * @param {!{detail: !{field: string, 519 * @param {!{detail: !{field: string,
517 * value: (string|!CrOnc.IPConfigProperties| 520 * value: (string|!CrOnc.IPConfigProperties|
518 * !Array<string>)}}} event 521 * !Array<string>)}}} event
519 * The network-ip-config or network-nameservers change event. 522 * The network-ip-config or network-nameservers change event.
520 * @private 523 * @private
521 */ 524 */
522 onIPConfigChange_: function(event) { 525 onIPConfigChange_: function(event) {
523 if (!this.networkProperties) 526 if (!this.networkProperties)
524 return; 527 return;
525 var field = event.detail.field; 528 var field = event.detail.field;
526 var value = event.detail.value; 529 var value = event.detail.value;
527 // Get an empty ONC dictionary and set just the IP Config properties that 530 // Get an empty ONC dictionary and set just the IP Config properties that
528 // need to change. 531 // need to change.
529 var onc = this.getEmptyNetworkProperties_(); 532 var onc = this.getEmptyNetworkProperties_();
530 var ipConfigType = 533 var ipConfigType =
531 /** @type {chrome.networkingPrivate.IPConfigType|undefined} */ (
532 CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType));
533 if (field == 'IPAddressConfigType') {
534 var newIpConfigType =
535 /** @type {chrome.networkingPrivate.IPConfigType} */ (value);
536 if (newIpConfigType == ipConfigType)
537 return;
538 onc.IPAddressConfigType = newIpConfigType;
539 } else if (field == 'NameServersConfigType') {
540 var nsConfigType =
541 /** @type {chrome.networkingPrivate.IPConfigType|undefined} */ ( 534 /** @type {chrome.networkingPrivate.IPConfigType|undefined} */ (
542 CrOnc.getActiveValue( 535 CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType));
543 this.networkProperties.NameServersConfigType)); 536 if (field == 'IPAddressConfigType') {
544 var newNsConfigType = 537 var newIpConfigType =
545 /** @type {chrome.networkingPrivate.IPConfigType} */ (value); 538 /** @type {chrome.networkingPrivate.IPConfigType} */ (value);
546 if (newNsConfigType == nsConfigType) 539 if (newIpConfigType == ipConfigType)
547 return; 540 return;
548 onc.NameServersConfigType = newNsConfigType; 541 onc.IPAddressConfigType = newIpConfigType;
549 } else if (field == 'StaticIPConfig') { 542 } else if (field == 'NameServersConfigType') {
550 if (ipConfigType == CrOnc.IPConfigType.STATIC) { 543 var nsConfigType =
551 let staticIpConfig = this.networkProperties.StaticIPConfig; 544 /** @type {chrome.networkingPrivate.IPConfigType|undefined} */ (
552 let ipConfigValue = /** @type {!Object} */ (value); 545 CrOnc.getActiveValue(
553 if (staticIpConfig && 546 this.networkProperties.NameServersConfigType));
554 this.allPropertiesMatch_(staticIpConfig, ipConfigValue)) { 547 var newNsConfigType =
548 /** @type {chrome.networkingPrivate.IPConfigType} */ (value);
549 if (newNsConfigType == nsConfigType)
550 return;
551 onc.NameServersConfigType = newNsConfigType;
552 } else if (field == 'StaticIPConfig') {
553 if (ipConfigType == CrOnc.IPConfigType.STATIC) {
554 let staticIpConfig = this.networkProperties.StaticIPConfig;
555 let ipConfigValue = /** @type {!Object} */ (value);
556 if (staticIpConfig &&
557 this.allPropertiesMatch_(staticIpConfig, ipConfigValue)) {
558 return;
559 }
560 }
561 onc.IPAddressConfigType = CrOnc.IPConfigType.STATIC;
562 if (!onc.StaticIPConfig) {
563 onc.StaticIPConfig =
564 /** @type {!chrome.networkingPrivate.IPConfigProperties} */ ({});
565 }
566 for (let key in value)
567 onc.StaticIPConfig[key] = value[key];
568 } else if (field == 'NameServers') {
569 // If a StaticIPConfig property is specified and its NameServers value
570 // matches the new value, no need to set anything.
571 let nameServers = /** @type {!Array<string>} */ (value);
572 if (onc.NameServersConfigType == CrOnc.IPConfigType.STATIC &&
573 onc.StaticIPConfig &&
574 onc.StaticIPConfig.NameServers == nameServers) {
555 return; 575 return;
556 } 576 }
557 } 577 onc.NameServersConfigType = CrOnc.IPConfigType.STATIC;
558 onc.IPAddressConfigType = CrOnc.IPConfigType.STATIC; 578 if (!onc.StaticIPConfig) {
559 if (!onc.StaticIPConfig) { 579 onc.StaticIPConfig =
560 onc.StaticIPConfig = 580 /** @type {!chrome.networkingPrivate.IPConfigProperties} */ ({});
561 /** @type {!chrome.networkingPrivate.IPConfigProperties} */ ({}); 581 }
562 } 582 onc.StaticIPConfig.NameServers = nameServers;
563 for (let key in value) 583 } else {
564 onc.StaticIPConfig[key] = value[key]; 584 console.error('Unexpected change field: ' + field);
565 } else if (field == 'NameServers') { 585 return;
566 // If a StaticIPConfig property is specified and its NameServers value 586 }
567 // matches the new value, no need to set anything. 587 // setValidStaticIPConfig will fill in any other properties from
568 let nameServers = /** @type {!Array<string>} */ (value); 588 // networkProperties. This is necessary since we update IP Address and
569 if (onc.NameServersConfigType == CrOnc.IPConfigType.STATIC && 589 // NameServers independently.
570 onc.StaticIPConfig && onc.StaticIPConfig.NameServers == nameServers) { 590 CrOnc.setValidStaticIPConfig(onc, this.networkProperties);
571 return; 591 this.setNetworkProperties_(onc);
572 } 592 },
573 onc.NameServersConfigType = CrOnc.IPConfigType.STATIC; 593
574 if (!onc.StaticIPConfig) { 594 /**
575 onc.StaticIPConfig = 595 * Event triggered when the Proxy configuration element changes.
576 /** @type {!chrome.networkingPrivate.IPConfigProperties} */ ({}); 596 * @param {!{detail: {field: string, value: !CrOnc.ProxySettings}}} event
577 } 597 * The network-proxy change event.
578 onc.StaticIPConfig.NameServers = nameServers; 598 * @private
579 } else { 599 */
580 console.error('Unexpected change field: ' + field); 600 onProxyChange_: function(event) {
581 return; 601 if (!this.networkProperties)
582 } 602 return;
583 // setValidStaticIPConfig will fill in any other properties from 603 var field = event.detail.field;
584 // networkProperties. This is necessary since we update IP Address and 604 var value = event.detail.value;
585 // NameServers independently. 605 if (field != 'ProxySettings')
586 CrOnc.setValidStaticIPConfig(onc, this.networkProperties); 606 return;
587 this.setNetworkProperties_(onc); 607 var onc = this.getEmptyNetworkProperties_();
588 }, 608 CrOnc.setProperty(onc, 'ProxySettings', /** @type {!Object} */ (value));
589 609 this.setNetworkProperties_(onc);
590 /** 610 },
591 * Event triggered when the Proxy configuration element changes. 611
592 * @param {!{detail: {field: string, value: !CrOnc.ProxySettings}}} event 612 /**
593 * The network-proxy change event.
594 * @private
595 */
596 onProxyChange_: function(event) {
597 if (!this.networkProperties)
598 return;
599 var field = event.detail.field;
600 var value = event.detail.value;
601 if (field != 'ProxySettings')
602 return;
603 var onc = this.getEmptyNetworkProperties_();
604 CrOnc.setProperty(onc, 'ProxySettings', /** @type {!Object} */ (value));
605 this.setNetworkProperties_(onc);
606 },
607
608 /**
609 * @return {boolean} True if the shared message should be shown. 613 * @return {boolean} True if the shared message should be shown.
610 * @private 614 * @private
611 */ 615 */
612 showShared_: function() { 616 showShared_: function() {
613 return this.networkProperties.Source == 'Device' || 617 return this.networkProperties.Source == 'Device' ||
614 this.networkProperties.Source == 'DevicePolicy'; 618 this.networkProperties.Source == 'DevicePolicy';
615 }, 619 },
616 620
617 /** 621 /**
618 * @return {boolean} True if the AutoConnect checkbox should be shown. 622 * @return {boolean} True if the AutoConnect checkbox should be shown.
619 * @private 623 * @private
620 */ 624 */
621 showAutoConnect_: function() { 625 showAutoConnect_: function() {
622 return this.networkProperties.Type != CrOnc.Type.ETHERNET && 626 return this.networkProperties.Type != CrOnc.Type.ETHERNET &&
623 this.isRemembered_(); 627 this.isRemembered_();
624 }, 628 },
625 629
626 /** 630 /**
627 * @return {!CrOnc.ManagedProperty|undefined} Managed AutoConnect property. 631 * @return {!CrOnc.ManagedProperty|undefined} Managed AutoConnect property.
628 * @private 632 * @private
629 */ 633 */
630 getManagedAutoConnect_: function() { 634 getManagedAutoConnect_: function() {
631 return CrOnc.getManagedAutoConnect(this.networkProperties); 635 return CrOnc.getManagedAutoConnect(this.networkProperties);
632 }, 636 },
633 637
634 /** 638 /**
635 * @return {boolean} True if the prefer network checkbox should be shown. 639 * @return {boolean} True if the prefer network checkbox should be shown.
636 * @private 640 * @private
637 */ 641 */
638 showPreferNetwork_: function() { 642 showPreferNetwork_: function() {
639 // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for 643 // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for
640 // networkProperties.Type == CrOnc.Type.ETHERNET. 644 // networkProperties.Type == CrOnc.Type.ETHERNET.
641 return this.isRemembered_(); 645 return this.isRemembered_();
642 }, 646 },
643 647
644 /** 648 /**
645 * @param {!Array<string>} fields 649 * @param {!Array<string>} fields
646 * @return {boolean} 650 * @return {boolean}
647 * @private 651 * @private
648 */ 652 */
649 hasVisibleFields_: function(fields) { 653 hasVisibleFields_: function(fields) {
650 for (let key of fields) { 654 for (let key of fields) {
651 let value = this.get(key, this.networkProperties); 655 let value = this.get(key, this.networkProperties);
652 if (value !== undefined && value !== '') 656 if (value !== undefined && value !== '')
657 return true;
658 }
659 return false;
660 },
661
662 /**
663 * @return {boolean}
664 * @private
665 */
666 hasInfoFields_: function() {
667 return this.hasVisibleFields_(this.getInfoFields_());
668 },
669
670 /**
671 * @return {!Array<string>} The fields to display in the info section.
672 * @private
673 */
674 getInfoFields_: function() {
675 /** @type {!Array<string>} */ var fields = [];
676 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) {
677 fields.push(
678 'Cellular.ActivationState', 'Cellular.RoamingState',
679 'RestrictedConnectivity', 'Cellular.ServingOperator.Name');
680 }
681 if (this.networkProperties.Type == CrOnc.Type.VPN) {
682 let vpnType = CrOnc.getActiveValue(this.networkProperties.VPN.Type);
683 if (vpnType == 'ThirdPartyVPN') {
684 fields.push('VPN.ThirdPartyVPN.ProviderName');
685 } else {
686 fields.push('VPN.Host', 'VPN.Type');
687 if (vpnType == 'OpenVPN')
688 fields.push('VPN.OpenVPN.Username');
689 else if (vpnType == 'L2TP-IPsec')
690 fields.push('VPN.L2TP.Username');
691 }
692 }
693 if (this.networkProperties.Type == CrOnc.Type.WI_FI)
694 fields.push('RestrictedConnectivity');
695 if (this.networkProperties.Type == CrOnc.Type.WI_MAX) {
696 fields.push('RestrictedConnectivity', 'WiMAX.EAP.Identity');
697 }
698 return fields;
699 },
700
701 /**
702 * @return {!Array<string>} The fields to display in the Advanced section.
703 * @private
704 */
705 getAdvancedFields_: function() {
706 /** @type {!Array<string>} */ var fields = [];
707 fields.push('MacAddress');
708 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) {
709 fields.push(
710 'Cellular.Carrier', 'Cellular.Family', 'Cellular.NetworkTechnology',
711 'Cellular.ServingOperator.Code');
712 }
713 if (this.networkProperties.Type == CrOnc.Type.WI_FI) {
714 fields.push(
715 'WiFi.SSID', 'WiFi.BSSID', 'WiFi.Security', 'WiFi.SignalStrength',
716 'WiFi.Frequency');
717 }
718 if (this.networkProperties.Type == CrOnc.Type.WI_MAX)
719 fields.push('WiFi.SignalStrength');
720 return fields;
721 },
722
723 /**
724 * @return {!Array<string>} The fields to display in the device section.
725 * @private
726 */
727 getDeviceFields_: function() {
728 /** @type {!Array<string>} */ var fields = [];
729 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) {
730 fields.push(
731 'Cellular.HomeProvider.Name', 'Cellular.HomeProvider.Country',
732 'Cellular.HomeProvider.Code', 'Cellular.Manufacturer',
733 'Cellular.ModelID', 'Cellular.FirmwareRevision',
734 'Cellular.HardwareRevision', 'Cellular.ESN', 'Cellular.ICCID',
735 'Cellular.IMEI', 'Cellular.IMSI', 'Cellular.MDN', 'Cellular.MEID',
736 'Cellular.MIN', 'Cellular.PRLVersion');
737 }
738 return fields;
739 },
740
741 /**
742 * @return {boolean}
743 * @private
744 */
745 showAdvanced_: function() {
746 return this.hasAdvancedFields_() || this.hasDeviceFields_() ||
747 this.isRememberedOrConnected_();
748 },
749
750 /**
751 * @return {boolean}
752 * @private
753 */
754 hasAdvancedFields_: function() {
755 return this.hasVisibleFields_(this.getAdvancedFields_());
756 },
757
758 /**
759 * @return {boolean}
760 * @private
761 */
762 hasDeviceFields_: function() {
763 return this.hasVisibleFields_(this.getDeviceFields_());
764 },
765
766 /**
767 * @return {boolean}
768 * @private
769 */
770 hasAdvancedOrDeviceFields_: function() {
771 return this.hasAdvancedFields_() || this.hasDeviceFields_();
772 },
773
774 /**
775 * @return {boolean} True if the network section should be shown.
776 * @private
777 */
778 hasNetworkSection_: function() {
779 if (this.networkProperties.Type == CrOnc.Type.VPN)
780 return false;
781 if (this.networkProperties.Type == CrOnc.Type.CELLULAR)
653 return true; 782 return true;
654 } 783 return this.isRememberedOrConnected_();
655 return false; 784 },
656 }, 785
657 786 /**
658 /**
659 * @return {boolean}
660 * @private
661 */
662 hasInfoFields_: function() {
663 return this.hasVisibleFields_(this.getInfoFields_());
664 },
665
666 /**
667 * @return {!Array<string>} The fields to display in the info section.
668 * @private
669 */
670 getInfoFields_: function() {
671 /** @type {!Array<string>} */ var fields = [];
672 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) {
673 fields.push(
674 'Cellular.ActivationState', 'Cellular.RoamingState',
675 'RestrictedConnectivity', 'Cellular.ServingOperator.Name');
676 }
677 if (this.networkProperties.Type == CrOnc.Type.VPN) {
678 let vpnType = CrOnc.getActiveValue(this.networkProperties.VPN.Type);
679 if (vpnType == 'ThirdPartyVPN') {
680 fields.push('VPN.ThirdPartyVPN.ProviderName');
681 } else {
682 fields.push('VPN.Host', 'VPN.Type');
683 if (vpnType == 'OpenVPN')
684 fields.push('VPN.OpenVPN.Username');
685 else if (vpnType == 'L2TP-IPsec')
686 fields.push('VPN.L2TP.Username');
687 }
688 }
689 if (this.networkProperties.Type == CrOnc.Type.WI_FI)
690 fields.push('RestrictedConnectivity');
691 if (this.networkProperties.Type == CrOnc.Type.WI_MAX) {
692 fields.push('RestrictedConnectivity', 'WiMAX.EAP.Identity');
693 }
694 return fields;
695 },
696
697 /**
698 * @return {!Array<string>} The fields to display in the Advanced section.
699 * @private
700 */
701 getAdvancedFields_: function() {
702 /** @type {!Array<string>} */ var fields = [];
703 fields.push('MacAddress');
704 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) {
705 fields.push(
706 'Cellular.Carrier', 'Cellular.Family', 'Cellular.NetworkTechnology',
707 'Cellular.ServingOperator.Code');
708 }
709 if (this.networkProperties.Type == CrOnc.Type.WI_FI) {
710 fields.push(
711 'WiFi.SSID', 'WiFi.BSSID', 'WiFi.Security', 'WiFi.SignalStrength',
712 'WiFi.Frequency');
713 }
714 if (this.networkProperties.Type == CrOnc.Type.WI_MAX)
715 fields.push('WiFi.SignalStrength');
716 return fields;
717 },
718
719 /**
720 * @return {!Array<string>} The fields to display in the device section.
721 * @private
722 */
723 getDeviceFields_: function() {
724 /** @type {!Array<string>} */ var fields = [];
725 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) {
726 fields.push(
727 'Cellular.HomeProvider.Name', 'Cellular.HomeProvider.Country',
728 'Cellular.HomeProvider.Code', 'Cellular.Manufacturer',
729 'Cellular.ModelID', 'Cellular.FirmwareRevision',
730 'Cellular.HardwareRevision', 'Cellular.ESN', 'Cellular.ICCID',
731 'Cellular.IMEI', 'Cellular.IMSI', 'Cellular.MDN', 'Cellular.MEID',
732 'Cellular.MIN', 'Cellular.PRLVersion');
733 }
734 return fields;
735 },
736
737 /**
738 * @return {boolean}
739 * @private
740 */
741 showAdvanced_: function() {
742 return this.hasAdvancedFields_() || this.hasDeviceFields_() ||
743 this.isRememberedOrConnected_();
744 },
745
746 /**
747 * @return {boolean}
748 * @private
749 */
750 hasAdvancedFields_: function() {
751 return this.hasVisibleFields_(this.getAdvancedFields_());
752 },
753
754 /**
755 * @return {boolean}
756 * @private
757 */
758 hasDeviceFields_: function() {
759 return this.hasVisibleFields_(this.getDeviceFields_());
760 },
761
762 /**
763 * @return {boolean}
764 * @private
765 */
766 hasAdvancedOrDeviceFields_: function() {
767 return this.hasAdvancedFields_() || this.hasDeviceFields_();
768 },
769
770 /**
771 * @return {boolean} True if the network section should be shown.
772 * @private
773 */
774 hasNetworkSection_: function() {
775 if (this.networkProperties.Type == CrOnc.Type.VPN)
776 return false;
777 if (this.networkProperties.Type == CrOnc.Type.CELLULAR)
778 return true;
779 return this.isRememberedOrConnected_();
780 },
781
782 /**
783 * @param {string} type The network type. 787 * @param {string} type The network type.
784 * @return {boolean} True if the network type matches 'type'. 788 * @return {boolean} True if the network type matches 'type'.
785 * @private 789 * @private
786 */ 790 */
787 isType_: function(type) { 791 isType_: function(type) {
788 return this.networkProperties.Type == type; 792 return this.networkProperties.Type == type;
789 }, 793 },
790 794
791 /** 795 /**
792 * @return {boolean} True if the Cellular SIM section should be shown. 796 * @return {boolean} True if the Cellular SIM section should be shown.
793 * @private 797 * @private
794 */ 798 */
795 showCellularSim_: function() { 799 showCellularSim_: function() {
796 if (this.networkProperties.Type != 'Cellular' || 800 if (this.networkProperties.Type != 'Cellular' ||
797 !this.networkProperties.Cellular) { 801 !this.networkProperties.Cellular) {
798 return false; 802 return false;
799 } 803 }
800 return this.networkProperties.Cellular.Family == 'GSM'; 804 return this.networkProperties.Cellular.Family == 'GSM';
801 }, 805 },
802 806
803 /** 807 /**
804 * @param {!Object} curValue 808 * @param {!Object} curValue
805 * @param {!Object} newValue 809 * @param {!Object} newValue
806 * @return {boolean} True if all properties set in |newValue| are equal to 810 * @return {boolean} True if all properties set in |newValue| are equal to
807 * the corresponding properties in |curValue|. Note: Not all properties 811 * the corresponding properties in |curValue|. Note: Not all properties
808 * of |curValue| need to be specified in |newValue| for this to return 812 * of |curValue| need to be specified in |newValue| for this to return
809 * true. 813 * true.
810 * @private 814 * @private
811 */ 815 */
812 allPropertiesMatch_: function(curValue, newValue) { 816 allPropertiesMatch_: function(curValue, newValue) {
813 for (let key in newValue) { 817 for (let key in newValue) {
814 if (newValue[key] != curValue[key]) 818 if (newValue[key] != curValue[key])
815 return false; 819 return false;
820 }
821 return true;
816 } 822 }
817 return true; 823 });
818 }
819 });
820 })(); 824 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698