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

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

Issue 2984843003: MD Settings: Convert all usages of .bind(this) to use ES6 arrow function. (Closed)
Patch Set: Resolve conflicts. Created 3 years, 4 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-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({
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 * @private 89 * @private
90 */ 90 */
91 refreshNetworks_: function() { 91 refreshNetworks_: function() {
92 if (!this.networkType) 92 if (!this.networkType)
93 return; 93 return;
94 var filter = { 94 var filter = {
95 networkType: this.networkType, 95 networkType: this.networkType,
96 visible: false, 96 visible: false,
97 configured: true 97 configured: true
98 }; 98 };
99 this.networkingPrivate.getNetworks(filter, function(states) { 99 this.networkingPrivate.getNetworks(filter, states => {
100 this.networkStateList_ = states; 100 this.networkStateList_ = states;
101 }.bind(this)); 101 });
102 }, 102 },
103 103
104 /** 104 /**
105 * @param {!CrOnc.NetworkStateProperties} state 105 * @param {!CrOnc.NetworkStateProperties} state
106 * @return {boolean} 106 * @return {boolean}
107 * @private 107 * @private
108 */ 108 */
109 networkIsPreferred_: function(state) { 109 networkIsPreferred_: function(state) {
110 // Currently we treat NetworkStateProperties.Priority as a boolean. 110 // Currently we treat NetworkStateProperties.Priority as a boolean.
111 return state.Priority > 0; 111 return state.Priority > 0;
112 }, 112 },
113 113
114 /** 114 /**
115 * @param {!CrOnc.NetworkStateProperties} networkState 115 * @param {!CrOnc.NetworkStateProperties} networkState
116 * @return {boolean} 116 * @return {boolean}
117 * @private 117 * @private
118 */ 118 */
119 networkIsNotPreferred_: function(networkState) { 119 networkIsNotPreferred_: function(networkState) {
120 return networkState.Priority == 0; 120 return networkState.Priority == 0;
121 }, 121 },
122 122
123 /** 123 /**
124 * @return {boolean} 124 * @return {boolean}
125 * @private 125 * @private
126 */ 126 */
127 havePreferred_: function() { 127 havePreferred_: function() {
128 return this.networkStateList_.find(function(state) { 128 return this.networkStateList_.find(
129 return this.networkIsPreferred_(state); 129 state => this.networkIsPreferred_(state)) !== undefined;
130 }.bind(this)) !== undefined;
131 }, 130 },
132 131
133 /** 132 /**
134 * @return {boolean} 133 * @return {boolean}
135 * @private 134 * @private
136 */ 135 */
137 haveNotPreferred_: function() { 136 haveNotPreferred_: function() {
138 return this.networkStateList_.find(function(state) { 137 return this.networkStateList_.find(
139 return this.networkIsNotPreferred_(state); 138 state => this.networkIsNotPreferred_(state)) !== undefined;
140 }.bind(this)) !== undefined;
141 }, 139 },
142 140
143 /** 141 /**
144 * @param {!Event} event 142 * @param {!Event} event
145 * @private 143 * @private
146 */ 144 */
147 onMenuButtonTap_: function(event) { 145 onMenuButtonTap_: function(event) {
148 var button = /** @type {!HTMLElement} */ (event.target); 146 var button = /** @type {!HTMLElement} */ (event.target);
149 this.selectedGuid_ = 147 this.selectedGuid_ =
150 /** @type {!{model: !{item: !CrOnc.NetworkStateProperties}}} */ (event) 148 /** @type {!{model: !{item: !CrOnc.NetworkStateProperties}}} */ (event)
151 .model.item.GUID; 149 .model.item.GUID;
152 // We need to make a round trip to Chrome in order to retrieve the managed 150 // We need to make a round trip to Chrome in order to retrieve the managed
153 // properties for the network. The delay is not noticeable (~5ms) and is 151 // 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. 152 // preferable to initiating a query for every known network at load time.
155 this.networkingPrivate.getManagedProperties( 153 this.networkingPrivate.getManagedProperties(
156 this.selectedGuid_, function(properties) { 154 this.selectedGuid_, properties => {
157 if (chrome.runtime.lastError || !properties) { 155 if (chrome.runtime.lastError || !properties) {
158 this.showAddPreferred_ = false; 156 this.showAddPreferred_ = false;
159 this.showRemovePreferred_ = false; 157 this.showRemovePreferred_ = false;
160 return; 158 return;
161 } 159 }
162 var preferred = button.hasAttribute('preferred'); 160 var preferred = button.hasAttribute('preferred');
163 if (this.isNetworkPolicyEnforced(properties.Priority)) { 161 if (this.isNetworkPolicyEnforced(properties.Priority)) {
164 this.showAddPreferred_ = false; 162 this.showAddPreferred_ = false;
165 this.showRemovePreferred_ = false; 163 this.showRemovePreferred_ = false;
166 } else { 164 } else {
167 this.showAddPreferred_ = !preferred; 165 this.showAddPreferred_ = !preferred;
168 this.showRemovePreferred_ = preferred; 166 this.showRemovePreferred_ = preferred;
169 } 167 }
170 /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).showAt(button); 168 /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).showAt(button);
171 }.bind(this)); 169 });
172 event.stopPropagation(); 170 event.stopPropagation();
173 }, 171 },
174 172
175 /** @private */ 173 /** @private */
176 onRemovePreferredTap_: function() { 174 onRemovePreferredTap_: function() {
177 this.networkingPrivate.setProperties(this.selectedGuid_, {Priority: 0}); 175 this.networkingPrivate.setProperties(this.selectedGuid_, {Priority: 0});
178 /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).close(); 176 /** @type {!CrActionMenuElement} */ (this.$.dotsMenu).close();
179 }, 177 },
180 178
181 /** @private */ 179 /** @private */
(...skipping 15 matching lines...) Expand all
197 * @private 195 * @private
198 */ 196 */
199 fireShowDetails_: function(event) { 197 fireShowDetails_: function(event) {
200 var state = 198 var state =
201 /** @type {!{model: !{item: !CrOnc.NetworkStateProperties}}} */ (event) 199 /** @type {!{model: !{item: !CrOnc.NetworkStateProperties}}} */ (event)
202 .model.item; 200 .model.item;
203 this.fire('show-detail', state); 201 this.fire('show-detail', state);
204 event.stopPropagation(); 202 event.stopPropagation();
205 }, 203 },
206 }); 204 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698