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

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

Issue 2624573002: MD Settings: Internet: UI For global policy (Closed)
Patch Set: Rebase + Wrap 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 Polymer element for displaying a summary of network states 6 * @fileoverview Polymer element for displaying a summary of network states
7 * by type: Ethernet, WiFi, Cellular, WiMAX, and VPN. 7 * by type: Ethernet, WiFi, Cellular, WiMAX, and VPN.
8 */ 8 */
9 9
10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ 10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */
(...skipping 17 matching lines...) Expand all
28 * Cellular: (Array<CrOnc.NetworkStateProperties>|undefined), 28 * Cellular: (Array<CrOnc.NetworkStateProperties>|undefined),
29 * WiMAX: (Array<CrOnc.NetworkStateProperties>|undefined), 29 * WiMAX: (Array<CrOnc.NetworkStateProperties>|undefined),
30 * VPN: (Array<CrOnc.NetworkStateProperties>|undefined) 30 * VPN: (Array<CrOnc.NetworkStateProperties>|undefined)
31 * }} 31 * }}
32 */ 32 */
33 var NetworkStateListObject; 33 var NetworkStateListObject;
34 34
35 Polymer({ 35 Polymer({
36 is: 'network-summary', 36 is: 'network-summary',
37 37
38 behaviors: [CrPolicyNetworkBehavior],
39
38 properties: { 40 properties: {
39 /** 41 /**
40 * Highest priority connected network or null. 42 * Highest priority connected network or null.
41 * @type {?CrOnc.NetworkStateProperties} 43 * @type {?CrOnc.NetworkStateProperties}
42 */ 44 */
43 defaultNetwork: { 45 defaultNetwork: {
44 type: Object, 46 type: Object,
45 value: null, 47 value: null,
46 notify: true, 48 notify: true,
47 }, 49 },
48 50
51 /** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */
52 globalPolicy: Object,
53
49 /** 54 /**
50 * Interface for networkingPrivate calls, passed from internet_page. 55 * Interface for networkingPrivate calls, passed from internet_page.
51 * @type {NetworkingPrivate} 56 * @type {NetworkingPrivate}
52 */ 57 */
53 networkingPrivate: Object, 58 networkingPrivate: Object,
54 59
55 /** 60 /**
56 * The device state for each network device type. 61 * The device state for each network device type.
57 * @private {DeviceStateObject} 62 * @private {DeviceStateObject}
58 */ 63 */
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 this.networkingPrivate.requestNetworkScan(); 165 this.networkingPrivate.requestNetworkScan();
161 }, 166 },
162 167
163 /** 168 /**
164 * Event triggered when a network-summary-item is selected. 169 * Event triggered when a network-summary-item is selected.
165 * @param {!{detail: !CrOnc.NetworkStateProperties}} event 170 * @param {!{detail: !CrOnc.NetworkStateProperties}} event
166 * @private 171 * @private
167 */ 172 */
168 onSelected_: function(event) { 173 onSelected_: function(event) {
169 var state = event.detail; 174 var state = event.detail;
170 if (this.canConnect_(state)) { 175 if (this.canConnect_(state, this.globalPolicy)) {
171 this.connectToNetwork_(state); 176 this.connectToNetwork_(state);
172 return; 177 return;
173 } 178 }
174 this.fire('show-detail', state); 179 this.fire('show-detail', state);
175 }, 180 },
176 181
177 /** 182 /**
178 * Event triggered when the enabled state of a network-summary-item is 183 * Event triggered when the enabled state of a network-summary-item is
179 * toggled. 184 * toggled.
180 * @param {!{detail: {enabled: boolean, 185 * @param {!{detail: {enabled: boolean,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if (this.activeNetworkIds_.has(id)) { 221 if (this.activeNetworkIds_.has(id)) {
217 this.networkingPrivate.getState( 222 this.networkingPrivate.getState(
218 id, this.getActiveStateCallback_.bind(this, id)); 223 id, this.getActiveStateCallback_.bind(this, id));
219 } 224 }
220 }, this); 225 }, this);
221 }, 226 },
222 227
223 /** 228 /**
224 * Determines whether or not a network state can be connected to. 229 * Determines whether or not a network state can be connected to.
225 * @param {!CrOnc.NetworkStateProperties} state The network state. 230 * @param {!CrOnc.NetworkStateProperties} state The network state.
231 * @param {!chrome.networkingPrivate.GlobalPolicy|undefined} globalPolicy
226 * @private 232 * @private
227 */ 233 */
228 canConnect_: function(state) { 234 canConnect_: function(state, globalPolicy) {
229 if (state.Type == CrOnc.Type.ETHERNET || 235 if (state.Type == CrOnc.Type.ETHERNET ||
230 state.Type == CrOnc.Type.VPN && !this.defaultNetwork) { 236 state.Type == CrOnc.Type.VPN && !this.defaultNetwork) {
231 return false; 237 return false;
232 } 238 }
239 if (state.Type == CrOnc.Type.WI_FI && !!globalPolicy &&
240 globalPolicy.AllowOnlyPolicyNetworksToConnect &&
241 !this.isPolicySource(state.Source)) {
242 return false;
243 }
233 return state.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED; 244 return state.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED;
234 }, 245 },
235 246
236 /** 247 /**
237 * networkingPrivate.getState event callback for an active state. 248 * networkingPrivate.getState event callback for an active state.
238 * @param {string} id The id of the requested state. 249 * @param {string} id The id of the requested state.
239 * @param {!chrome.networkingPrivate.NetworkStateProperties} state 250 * @param {!chrome.networkingPrivate.NetworkStateProperties} state
240 * @private 251 * @private
241 */ 252 */
242 getActiveStateCallback_: function(id, state) { 253 getActiveStateCallback_: function(id, state) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 newActiveNetworkStates.push(state); 406 newActiveNetworkStates.push(state);
396 this.activeNetworkIds_.add(state.GUID); 407 this.activeNetworkIds_.add(state.GUID);
397 } 408 }
398 409
399 this.deviceStates_ = newDeviceStates; 410 this.deviceStates_ = newDeviceStates;
400 this.networkStateLists_ = newNetworkStateLists; 411 this.networkStateLists_ = newNetworkStateLists;
401 // Set activeNetworkStates last to rebuild the dom-repeat. 412 // Set activeNetworkStates last to rebuild the dom-repeat.
402 this.activeNetworkStates_ = newActiveNetworkStates; 413 this.activeNetworkStates_ = newActiveNetworkStates;
403 }, 414 },
404 }); 415 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698