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

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

Issue 2300783002: MD Settings: Internet: Cleanup JS (Closed)
Patch Set: Feedback Created 4 years, 3 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 11 matching lines...) Expand all
22 22
23 /** 23 /**
24 * The maximum height in pixels for the list of networks. 24 * The maximum height in pixels for the list of networks.
25 */ 25 */
26 maxHeight: { 26 maxHeight: {
27 type: Number, 27 type: Number,
28 value: 500, 28 value: 500,
29 }, 29 },
30 30
31 /** 31 /**
32 * List of all network state data for the network type.
33 * @type {!Array<!CrOnc.NetworkStateProperties>}
34 */
35 networkStateList: {
36 type: Array,
37 value: function() {
38 return [];
39 }
40 },
41
42 /**
43 * Interface for networkingPrivate calls, passed from internet_page. 32 * Interface for networkingPrivate calls, passed from internet_page.
44 * @type {NetworkingPrivate} 33 * @type {NetworkingPrivate}
45 */ 34 */
46 networkingPrivate: { 35 networkingPrivate: Object,
47 type: Object, 36
37 /**
38 * List of all network state data for the network type.
39 * @private {!Array<!CrOnc.NetworkStateProperties>}
40 */
41 networkStateList_: {
42 type: Array,
43 value: function() {
44 return [];
45 }
48 }, 46 },
49 }, 47 },
50 48
51 /** 49 /**
52 * Listener function for chrome.networkingPrivate.onNetworksChanged event. 50 * Listener function for chrome.networkingPrivate.onNetworksChanged event.
53 * @type {function(!Array<string>)} 51 * @type {function(!Array<string>)}
54 * @private 52 * @private
55 */ 53 */
56 networksChangedListener_: function() {}, 54 networksChangedListener_: function() {},
57 55
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 */ 87 */
90 refreshNetworks_: function() { 88 refreshNetworks_: function() {
91 if (!this.networkType) 89 if (!this.networkType)
92 return; 90 return;
93 var filter = { 91 var filter = {
94 networkType: this.networkType, 92 networkType: this.networkType,
95 visible: false, 93 visible: false,
96 configured: true 94 configured: true
97 }; 95 };
98 this.networkingPrivate.getNetworks(filter, function(states) { 96 this.networkingPrivate.getNetworks(filter, function(states) {
99 this.networkStateList = states; 97 this.networkStateList_ = states;
100 }.bind(this)); 98 }.bind(this));
101 }, 99 },
102 100
103 /** 101 /**
104 * @param {!CrOnc.NetworkStateProperties} state 102 * @param {!CrOnc.NetworkStateProperties} state
105 * @return {boolean} 103 * @return {boolean}
106 * @private 104 * @private
107 */ 105 */
108 networkIsPreferred_: function(state) { 106 networkIsPreferred_: function(state) {
109 // Currently we treat NetworkStateProperties.Priority as a boolean. 107 // Currently we treat NetworkStateProperties.Priority as a boolean.
110 return state.Priority > 0; 108 return state.Priority > 0;
111 }, 109 },
112 110
113 /** 111 /**
114 * @param {!CrOnc.NetworkStateProperties} networkState 112 * @param {!CrOnc.NetworkStateProperties} networkState
115 * @return {boolean} 113 * @return {boolean}
116 * @private 114 * @private
117 */ 115 */
118 networkIsNotPreferred_: function(networkState) { 116 networkIsNotPreferred_: function(networkState) {
119 return networkState.Priority == 0; 117 return networkState.Priority == 0;
120 }, 118 },
121 119
122 /** 120 /**
123 * @return {boolean} 121 * @return {boolean}
124 * @private 122 * @private
125 */ 123 */
126 havePreferred_: function() { 124 havePreferred_: function() {
127 return this.networkStateList.find(function(state) { 125 return this.networkStateList_.find(function(state) {
128 return this.networkIsPreferred_(state); 126 return this.networkIsPreferred_(state);
129 }.bind(this)) !== undefined; 127 }.bind(this)) !== undefined;
130 }, 128 },
131 129
132 /** 130 /**
133 * @return {boolean} 131 * @return {boolean}
134 * @private 132 * @private
135 */ 133 */
136 haveNotPreferred_: function() { 134 haveNotPreferred_: function() {
137 return this.networkStateList.find(function(state) { 135 return this.networkStateList_.find(function(state) {
138 return this.networkIsNotPreferred_(state); 136 return this.networkIsNotPreferred_(state);
139 }.bind(this)) !== undefined; 137 }.bind(this)) !== undefined;
140 }, 138 },
141 139
142 /** 140 /**
143 * @param {!{model: !{item: !CrOnc.NetworkStateProperties}}} e 141 * @param {!{model: !{item: !CrOnc.NetworkStateProperties}}} e
144 * @private 142 * @private
145 */ 143 */
146 onRemoveTap_: function(e) { 144 onRemoveTap_: function(e) {
147 var state = e.model.item; 145 var state = e.model.item;
148 this.networkingPrivate.setProperties(state.GUID, {Priority: 0}); 146 this.networkingPrivate.setProperties(state.GUID, {Priority: 0});
149 }, 147 },
150 148
151 /** 149 /**
152 * @param {!{model: !{item: !CrOnc.NetworkStateProperties}}} e 150 * @param {!{model: !{item: !CrOnc.NetworkStateProperties}}} e
153 * @private 151 * @private
154 */ 152 */
155 onAddTap_: function(e) { 153 onAddTap_: function(e) {
156 var state = e.model.item; 154 var state = e.model.item;
157 this.networkingPrivate.setProperties(state.GUID, {Priority: 1}); 155 this.networkingPrivate.setProperties(state.GUID, {Priority: 1});
158 }, 156 },
159 }); 157 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698