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

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

Issue 2568593002: MD Settings: Internet: Only show detailed info for primary user. (Closed)
Patch Set: Rebase Created 4 years 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() {
(...skipping 19 matching lines...) Expand all
30 type: Object, 30 type: Object,
31 observer: 'networkPropertiesChanged_', 31 observer: 'networkPropertiesChanged_',
32 }, 32 },
33 33
34 /** Preferences state. */ 34 /** Preferences state. */
35 prefs: { 35 prefs: {
36 type: Object, 36 type: Object,
37 notify: true, 37 notify: true,
38 }, 38 },
39 39
40 /** Email address for the primary user when user is a secondary user. */
41 primaryUserEmail_: {
42 type: String,
43 value: function() {
44 return loadTimeData.getBoolean('isSecondaryUser') ?
45 loadTimeData.getString('primaryUserEmail') : '';
46 },
47 },
48
40 /** 49 /**
41 * Highest priority connected network or null. 50 * Highest priority connected network or null.
42 * @type {?CrOnc.NetworkStateProperties} 51 * @type {?CrOnc.NetworkStateProperties}
43 */ 52 */
44 defaultNetwork: { 53 defaultNetwork: {
45 type: Object, 54 type: Object,
46 value: null, 55 value: null,
47 }, 56 },
48 57
49 /** 58 /**
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 if (networkIds.indexOf(this.guid) != -1) 209 if (networkIds.indexOf(this.guid) != -1)
201 this.getNetworkDetails_(); 210 this.getNetworkDetails_();
202 }, 211 },
203 212
204 /** 213 /**
205 * Calls networkingPrivate.getProperties for this.guid. 214 * Calls networkingPrivate.getProperties for this.guid.
206 * @private 215 * @private
207 */ 216 */
208 getNetworkDetails_: function() { 217 getNetworkDetails_: function() {
209 assert(!!this.guid); 218 assert(!!this.guid);
210 this.networkingPrivate.getManagedProperties( 219 if (this.isSecondaryUser_()) {
211 this.guid, this.getPropertiesCallback_.bind(this)); 220 this.networkingPrivate.getState(
221 this.guid, this.getStateCallback_.bind(this));
222 } else {
223 this.networkingPrivate.getManagedProperties(
224 this.guid, this.getPropertiesCallback_.bind(this));
225 }
212 }, 226 },
213 227
214 /** 228 /**
215 * networkingPrivate.getProperties callback. 229 * networkingPrivate.getProperties callback.
216 * @param {CrOnc.NetworkProperties} properties The network properties. 230 * @param {CrOnc.NetworkProperties} properties The network properties.
217 * @private 231 * @private
218 */ 232 */
219 getPropertiesCallback_: function(properties) { 233 getPropertiesCallback_: function(properties) {
220 this.networkProperties = properties; 234 this.networkProperties = properties;
221 if (!properties) { 235 if (!properties) {
222 // If |properties| becomes null (i.e. the network is no longer visible), 236 // If |properties| becomes null (i.e. the network is no longer visible),
223 // close the page. 237 // close the page.
224 console.error('Network no longer exists: ' + this.guid); 238 console.error('Network no longer exists: ' + this.guid);
225 this.close_(); 239 this.close_();
226 } 240 }
227 }, 241 },
228 242
229 /** 243 /**
244 * networkingPrivate.getProperties callback.
michaelpg 2016/12/12 23:17:00 getState
stevenjb 2016/12/13 00:57:55 Done.
245 * @param {CrOnc.NetworkStateProperties} state The network state properties.
246 * @private
247 */
248 getStateCallback_: function(state) {
249 if (!state) {
250 // If |properties| becomes null (i.e. the network is no longer visible),
michaelpg 2016/12/12 23:17:00 |state|?
stevenjb 2016/12/13 00:57:55 Done.
251 // close the page.
252 console.error('Network no longer exists: ' + this.guid);
253 this.networkProperties = undefined;
254 this.close_();
255 }
256 this.networkProperties = {
257 GUID: state.GUID,
258 Type: state.Type,
259 Connectable: state.Connectable,
260 ConnectionState: state.ConnectionState,
261 };
262 },
263
264 /**
230 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC 265 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC
231 * network properties. 266 * network properties.
232 * @private 267 * @private
233 */ 268 */
234 setNetworkProperties_: function(onc) { 269 setNetworkProperties_: function(onc) {
235 assert(!!this.guid); 270 assert(!!this.guid);
236 this.networkingPrivate.setProperties(this.guid, onc, function() { 271 this.networkingPrivate.setProperties(this.guid, onc, function() {
237 if (chrome.runtime.lastError) { 272 if (chrome.runtime.lastError) {
238 // An error typically indicates invalid input; request the properties 273 // An error typically indicates invalid input; request the properties
239 // to update any invalid fields. 274 // to update any invalid fields.
(...skipping 23 matching lines...) Expand all
263 /** 298 /**
264 * @return {boolean} True if the network is connected. 299 * @return {boolean} True if the network is connected.
265 * @private 300 * @private
266 */ 301 */
267 isConnectedState_: function() { 302 isConnectedState_: function() {
268 return this.networkProperties.ConnectionState == 303 return this.networkProperties.ConnectionState ==
269 CrOnc.ConnectionState.CONNECTED; 304 CrOnc.ConnectionState.CONNECTED;
270 }, 305 },
271 306
272 /** 307 /**
308 * @return {boolean} True if settings are for a secondary user.
309 * @private
310 */
311 isSecondaryUser_: function() {
312 return !!this.primaryUserEmail_;
michaelpg 2016/12/12 23:17:00 Can we use loadTimeData.getBoolean('isSecondaryUse
stevenjb 2016/12/13 00:57:55 In that case I may as well make this a property, w
313 },
314
315 /**
273 * @return {boolean} 316 * @return {boolean}
274 * @private 317 * @private
275 */ 318 */
276 isRemembered_: function() { 319 isRemembered_: function() {
277 var source = this.networkProperties.Source; 320 var source = this.networkProperties.Source;
278 return !!source && source != CrOnc.Source.NONE; 321 return !!source && source != CrOnc.Source.NONE;
279 }, 322 },
280 323
281 /** 324 /**
282 * @return {boolean} 325 * @return {boolean}
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 */ 806 */
764 allPropertiesMatch_: function(curValue, newValue) { 807 allPropertiesMatch_: function(curValue, newValue) {
765 for (let key in newValue) { 808 for (let key in newValue) {
766 if (newValue[key] != curValue[key]) 809 if (newValue[key] != curValue[key])
767 return false; 810 return false;
768 } 811 }
769 return true; 812 return true;
770 } 813 }
771 }); 814 });
772 })(); 815 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698