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

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: Add @private 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 20 matching lines...) Expand all
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 /** 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 },
49 readOnly: true,
50 },
51
52 /**
53 * Email address for the primary user.
54 * @private
55 */
56 primaryUserEmail_: {
57 type: String,
58 value: function() {
59 return loadTimeData.getBoolean('isSecondaryUser') ?
60 loadTimeData.getString('primaryUserEmail') : '';
61 },
62 readOnly: true,
63 },
64
65 /**
41 * Highest priority connected network or null. 66 * Highest priority connected network or null.
42 * @type {?CrOnc.NetworkStateProperties} 67 * @type {?CrOnc.NetworkStateProperties}
43 */ 68 */
44 defaultNetwork: { 69 defaultNetwork: {
45 type: Object, 70 type: Object,
46 value: null, 71 value: null,
47 }, 72 },
48 73
49 /** 74 /**
50 * Interface for networkingPrivate calls, passed from internet_page. 75 * Interface for networkingPrivate calls, passed from internet_page.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 if (networkIds.indexOf(this.guid) != -1) 225 if (networkIds.indexOf(this.guid) != -1)
201 this.getNetworkDetails_(); 226 this.getNetworkDetails_();
202 }, 227 },
203 228
204 /** 229 /**
205 * Calls networkingPrivate.getProperties for this.guid. 230 * Calls networkingPrivate.getProperties for this.guid.
206 * @private 231 * @private
207 */ 232 */
208 getNetworkDetails_: function() { 233 getNetworkDetails_: function() {
209 assert(!!this.guid); 234 assert(!!this.guid);
210 this.networkingPrivate.getManagedProperties( 235 if (this.isSecondaryUser_) {
211 this.guid, this.getPropertiesCallback_.bind(this)); 236 this.networkingPrivate.getState(
237 this.guid, this.getStateCallback_.bind(this));
238 } else {
239 this.networkingPrivate.getManagedProperties(
240 this.guid, this.getPropertiesCallback_.bind(this));
241 }
212 }, 242 },
213 243
214 /** 244 /**
215 * networkingPrivate.getProperties callback. 245 * networkingPrivate.getProperties callback.
216 * @param {CrOnc.NetworkProperties} properties The network properties. 246 * @param {CrOnc.NetworkProperties} properties The network properties.
217 * @private 247 * @private
218 */ 248 */
219 getPropertiesCallback_: function(properties) { 249 getPropertiesCallback_: function(properties) {
220 this.networkProperties = properties; 250 this.networkProperties = properties;
221 if (!properties) { 251 if (!properties) {
222 // If |properties| becomes null (i.e. the network is no longer visible), 252 // If |properties| is null, the network is no longer visible, close this.
223 // close the page.
224 console.error('Network no longer exists: ' + this.guid); 253 console.error('Network no longer exists: ' + this.guid);
225 this.close_(); 254 this.close_();
226 } 255 }
227 }, 256 },
228 257
229 /** 258 /**
259 * networkingPrivate.getState callback.
260 * @param {CrOnc.NetworkStateProperties} state The network state properties.
261 * @private
262 */
263 getStateCallback_: function(state) {
264 if (!state) {
265 // If |state| is null, the network is no longer visible, close this.
266 console.error('Network no longer exists: ' + this.guid);
267 this.networkProperties = undefined;
268 this.close_();
269 }
270 this.networkProperties = {
271 GUID: state.GUID,
272 Type: state.Type,
273 Connectable: state.Connectable,
274 ConnectionState: state.ConnectionState,
275 };
276 },
277
278 /**
230 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC 279 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC
231 * network properties. 280 * network properties.
232 * @private 281 * @private
233 */ 282 */
234 setNetworkProperties_: function(onc) { 283 setNetworkProperties_: function(onc) {
235 assert(!!this.guid); 284 assert(!!this.guid);
236 this.networkingPrivate.setProperties(this.guid, onc, function() { 285 this.networkingPrivate.setProperties(this.guid, onc, function() {
237 if (chrome.runtime.lastError) { 286 if (chrome.runtime.lastError) {
238 // An error typically indicates invalid input; request the properties 287 // An error typically indicates invalid input; request the properties
239 // to update any invalid fields. 288 // to update any invalid fields.
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 */ 812 */
764 allPropertiesMatch_: function(curValue, newValue) { 813 allPropertiesMatch_: function(curValue, newValue) {
765 for (let key in newValue) { 814 for (let key in newValue) {
766 if (newValue[key] != curValue[key]) 815 if (newValue[key] != curValue[key])
767 return false; 816 return false;
768 } 817 }
769 return true; 818 return true;
770 } 819 }
771 }); 820 });
772 })(); 821 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698