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

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

Issue 2879533004: MD Settings: Network: Check managed properties for known networks menu (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « chrome/browser/resources/settings/internet_page/internet_known_networks_page.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-known-networks' is the settings subpage listing the 7 * 'settings-internet-known-networks' is the settings subpage listing the
8 * known networks for a type (currently always WiFi). 8 * known networks for a type (currently always WiFi).
9 */ 9 */
10 Polymer({ 10 Polymer({
11 is: 'settings-internet-known-networks-page', 11 is: 'settings-internet-known-networks-page',
12 12
13 behaviors: [CrPolicyNetworkBehavior],
14
13 properties: { 15 properties: {
14 /** 16 /**
15 * The type of networks to list. 17 * The type of networks to list.
16 * @type {chrome.networkingPrivate.NetworkType} 18 * @type {chrome.networkingPrivate.NetworkType}
17 */ 19 */
18 networkType: { 20 networkType: {
19 type: String, 21 type: String,
20 observer: 'networkTypeChanged_', 22 observer: 'networkTypeChanged_',
21 }, 23 },
22 24
23 /** 25 /**
24 * Interface for networkingPrivate calls, passed from internet_page. 26 * Interface for networkingPrivate calls, passed from internet_page.
25 * @type {NetworkingPrivate} 27 * @type {NetworkingPrivate}
26 */ 28 */
27 networkingPrivate: Object, 29 networkingPrivate: Object,
28 30
29 /** 31 /**
30 * List of all network state data for the network type. 32 * List of all network state data for the network type.
31 * @private {!Array<!CrOnc.NetworkStateProperties>} 33 * @private {!Array<!CrOnc.NetworkStateProperties>}
32 */ 34 */
33 networkStateList_: { 35 networkStateList_: {
34 type: Array, 36 type: Array,
35 value: function() { 37 value: function() {
36 return []; 38 return [];
37 } 39 }
38 }, 40 },
41
42 /** @private */
43 showAddPreferred_: Boolean,
44
45 /** @private */
46 showRemovePreferred_: Boolean,
39 }, 47 },
40 48
41 /** @private {string} */ 49 /** @private {string} */
42 selectedGuid_: '', 50 selectedGuid_: '',
43 51
44 /** @private {boolean} */
45 selectedIsPreferred_: false,
46
47 /** 52 /**
48 * Listener function for chrome.networkingPrivate.onNetworksChanged event. 53 * Listener function for chrome.networkingPrivate.onNetworksChanged event.
49 * @type {function(!Array<string>)} 54 * @type {function(!Array<string>)}
50 * @private 55 * @private
51 */ 56 */
52 networksChangedListener_: function() {}, 57 networksChangedListener_: function() {},
53 58
54 /** @override */ 59 /** @override */
55 attached: function() { 60 attached: function() {
56 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this); 61 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 142
138 /** 143 /**
139 * @param {!Event} event 144 * @param {!Event} event
140 * @private 145 * @private
141 */ 146 */
142 onMenuButtonTap_: function(event) { 147 onMenuButtonTap_: function(event) {
143 var button = /** @type {!HTMLElement} */ (event.target); 148 var button = /** @type {!HTMLElement} */ (event.target);
144 this.selectedGuid_ = 149 this.selectedGuid_ =
145 /** @type {!{model: !{item: !CrOnc.NetworkStateProperties}}} */ (event) 150 /** @type {!{model: !{item: !CrOnc.NetworkStateProperties}}} */ (event)
146 .model.item.GUID; 151 .model.item.GUID;
147 this.selectedIsPreferred_ = button.hasAttribute('preferred'); 152 // We need to make a round trip to Chrome in order to retrieve the managed
148 /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).showAt(button); 153 // properties for the network. The delay is not noticeable (~5ms) and is
154 // preferable to initiating a query for every known network at load time.
155 this.networkingPrivate.getManagedProperties(
156 this.selectedGuid_, function(properties) {
157 var preferred = button.hasAttribute('preferred');
158 if (this.isNetworkPolicyEnforced(properties.Priority)) {
159 this.showAddPreferred_ = false;
160 this.showRemovePreferred_ = false;
161 } else {
162 this.showAddPreferred_ = !preferred;
163 this.showRemovePreferred_ = preferred;
164 }
165 /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).showAt(button);
166 }.bind(this));
149 event.stopPropagation(); 167 event.stopPropagation();
150 }, 168 },
151 169
152 /** @private */ 170 /** @private */
153 onRemovePreferredTap_: function() { 171 onRemovePreferredTap_: function() {
154 this.networkingPrivate.setProperties(this.selectedGuid_, {Priority: 0}); 172 this.networkingPrivate.setProperties(this.selectedGuid_, {Priority: 0});
155 /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).close(); 173 /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).close();
156 }, 174 },
157 175
158 /** @private */ 176 /** @private */
(...skipping 15 matching lines...) Expand all
174 * @private 192 * @private
175 */ 193 */
176 fireShowDetails_: function(event) { 194 fireShowDetails_: function(event) {
177 var state = 195 var state =
178 /** @type {!{model: !{item: !CrOnc.NetworkStateProperties}}} */ (event) 196 /** @type {!{model: !{item: !CrOnc.NetworkStateProperties}}} */ (event)
179 .model.item; 197 .model.item;
180 this.fire('show-detail', state); 198 this.fire('show-detail', state);
181 event.stopPropagation(); 199 event.stopPropagation();
182 }, 200 },
183 }); 201 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/internet_page/internet_known_networks_page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698