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

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

Issue 2300783002: MD Settings: Internet: Cleanup JS (Closed)
Patch Set: 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-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 14 matching lines...) Expand all
25 /** 25 /**
26 * The current properties for the network matching |guid|. 26 * The current properties for the network matching |guid|.
27 * @type {!CrOnc.NetworkProperties|undefined} 27 * @type {!CrOnc.NetworkProperties|undefined}
28 */ 28 */
29 networkProperties: { 29 networkProperties: {
30 type: Object, 30 type: Object,
31 observer: 'networkPropertiesChanged_', 31 observer: 'networkPropertiesChanged_',
32 }, 32 },
33 33
34 /** 34 /**
35 * The network AutoConnect state.
36 */
37 autoConnect: {
38 type: Boolean,
39 value: false,
40 observer: 'autoConnectChanged_',
41 },
42
43 /**
44 * The network preferred state.
45 */
46 preferNetwork: {
47 type: Boolean,
48 value: false,
49 observer: 'preferNetworkChanged_',
50 },
51
52 /**
53 * The network IP Address.
54 */
55 IPAddress: {
56 type: String,
57 value: '',
58 },
59
60 /**
61 * Highest priority connected network or null. 35 * Highest priority connected network or null.
62 * @type {?CrOnc.NetworkStateProperties} 36 * @type {?CrOnc.NetworkStateProperties}
63 */ 37 */
64 defaultNetwork: { 38 defaultNetwork: {
65 type: Object, 39 type: Object,
66 value: null, 40 value: null,
67 }, 41 },
68 42
69 advancedExpanded: {type: Boolean}, 43 /**
44 * Interface for networkingPrivate calls, passed from internet_page.
45 * @type {NetworkingPrivate}
46 */
47 networkingPrivate: Object,
48
49 /** The network AutoConnect state. */
dschuyler 2016/08/31 20:52:05 Should each of these be @private now that they hav
stevenjb 2016/08/31 21:33:44 Huh. I didn't think that was valid for properties,
50 autoConnect_: {
51 type: Boolean,
52 value: false,
53 observer: 'autoConnectChanged_',
54 },
55
56 /** The network preferred state. */
57 preferNetwork_: {
58 type: Boolean,
59 value: false,
60 observer: 'preferNetworkChanged_',
61 },
62
63 /** The network IP Address. */
64 IPAddress_: {
65 type: String,
66 value: '',
67 },
68
69 advancedExpanded_: {type: Boolean},
70 70
71 /** 71 /**
72 * Object providing network type values for data binding. 72 * Object providing network type values for data binding.
73 * @const 73 * @const
74 */ 74 */
75 NetworkType: { 75 NetworkType_: {
76 type: Object, 76 type: Object,
77 value: { 77 value: {
78 CELLULAR: CrOnc.Type.CELLULAR, 78 CELLULAR: CrOnc.Type.CELLULAR,
79 ETHERNET: CrOnc.Type.ETHERNET, 79 ETHERNET: CrOnc.Type.ETHERNET,
80 VPN: CrOnc.Type.VPN, 80 VPN: CrOnc.Type.VPN,
81 WIFI: CrOnc.Type.WI_FI, 81 WIFI: CrOnc.Type.WI_FI,
82 WIMAX: CrOnc.Type.WI_MAX, 82 WIMAX: CrOnc.Type.WI_MAX,
83 }, 83 },
84 readOnly: true 84 readOnly: true
85 }, 85 },
86
87 /**
88 * Interface for networkingPrivate calls, passed from internet_page.
89 * @type {NetworkingPrivate}
90 */
91 networkingPrivate: {type: Object},
92 }, 86 },
93 87
94 /** 88 /**
95 * Listener function for chrome.networkingPrivate.onNetworksChanged event. 89 * Listener function for chrome.networkingPrivate.onNetworksChanged event.
96 * @type {?function(!Array<string>)} 90 * @type {?function(!Array<string>)}
97 * @private 91 * @private
98 */ 92 */
99 networksChangedListener_: null, 93 networksChangedListener_: null,
100 94
101 /** 95 /**
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 }); 129 });
136 }, 130 },
137 131
138 /** @private */ 132 /** @private */
139 networkPropertiesChanged_: function() { 133 networkPropertiesChanged_: function() {
140 if (!this.networkProperties) 134 if (!this.networkProperties)
141 return; 135 return;
142 136
143 // Update autoConnect if it has changed. Default value is false. 137 // Update autoConnect if it has changed. Default value is false.
144 var autoConnect = CrOnc.getAutoConnect(this.networkProperties); 138 var autoConnect = CrOnc.getAutoConnect(this.networkProperties);
145 if (autoConnect != this.autoConnect) 139 if (autoConnect != this.autoConnect_)
146 this.autoConnect = autoConnect; 140 this.autoConnect_ = autoConnect;
147 141
148 // Update preferNetwork if it has changed. Default value is false. 142 // Update preferNetwork if it has changed. Default value is false.
149 var priority = /** @type {number} */ ( 143 var priority = /** @type {number} */ (
150 CrOnc.getActiveValue(this.networkProperties.Priority) || 0); 144 CrOnc.getActiveValue(this.networkProperties.Priority) || 0);
151 var preferNetwork = priority > 0; 145 var preferNetwork = priority > 0;
152 if (preferNetwork != this.preferNetwork) 146 if (preferNetwork != this.preferNetwork_)
153 this.preferNetwork = preferNetwork; 147 this.preferNetwork_ = preferNetwork;
154 148
155 // Set the IPAddress property to the IPV4 Address. 149 // Set the IPAddress property to the IPV4 Address.
156 var ipv4 = 150 var ipv4 =
157 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); 151 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4);
158 this.IPAddress = (ipv4 && ipv4.IPAddress) || ''; 152 this.IPAddress_ = (ipv4 && ipv4.IPAddress) || '';
159 }, 153 },
160 154
161 /** @private */ 155 /** @private */
162 autoConnectChanged_: function() { 156 autoConnectChanged_: function() {
163 if (!this.networkProperties || !this.guid) 157 if (!this.networkProperties || !this.guid)
164 return; 158 return;
165 var onc = this.getEmptyNetworkProperties_(); 159 var onc = this.getEmptyNetworkProperties_();
166 CrOnc.setTypeProperty(onc, 'AutoConnect', this.autoConnect); 160 CrOnc.setTypeProperty(onc, 'AutoConnect', this.autoConnect_);
167 this.setNetworkProperties_(onc); 161 this.setNetworkProperties_(onc);
168 }, 162 },
169 163
170 /** @private */ 164 /** @private */
171 preferNetworkChanged_: function() { 165 preferNetworkChanged_: function() {
172 if (!this.networkProperties || !this.guid) 166 if (!this.networkProperties || !this.guid)
173 return; 167 return;
174 var onc = this.getEmptyNetworkProperties_(); 168 var onc = this.getEmptyNetworkProperties_();
175 onc.Priority = this.preferNetwork ? 1 : 0; 169 onc.Priority = this.preferNetwork_ ? 1 : 0;
176 this.setNetworkProperties_(onc); 170 this.setNetworkProperties_(onc);
177 }, 171 },
178 172
179 /** 173 /**
180 * networkingPrivate.onNetworksChanged event callback. 174 * networkingPrivate.onNetworksChanged event callback.
181 * @param {!Array<string>} networkIds The list of changed network GUIDs. 175 * @param {!Array<string>} networkIds The list of changed network GUIDs.
182 * @private 176 * @private
183 */ 177 */
184 onNetworksChangedEvent_: function(networkIds) { 178 onNetworksChangedEvent_: function(networkIds) {
185 if (networkIds.indexOf(this.guid) != -1) 179 if (networkIds.indexOf(this.guid) != -1)
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 this.networkingPrivate.startActivate(this.guid); 416 this.networkingPrivate.startActivate(this.guid);
423 }, 417 },
424 418
425 /** 419 /**
426 * @param {Event} event 420 * @param {Event} event
427 * @private 421 * @private
428 */ 422 */
429 toggleAdvancedExpanded_: function(event) { 423 toggleAdvancedExpanded_: function(event) {
430 if (event.target.id == 'expandButton') 424 if (event.target.id == 'expandButton')
431 return; // Already handled. 425 return; // Already handled.
432 this.advancedExpanded = !this.advancedExpanded; 426 this.advancedExpanded_ = !this.advancedExpanded_;
433 }, 427 },
434 428
435 /** 429 /**
436 * Event triggered for elements associated with network properties. 430 * Event triggered for elements associated with network properties.
437 * @param {!{detail: !{field: string, value: (string|!Object)}}} event 431 * @param {!{detail: !{field: string, value: (string|!Object)}}} event
438 * @private 432 * @private
439 */ 433 */
440 onNetworkPropertyChange_: function(event) { 434 onNetworkPropertyChange_: function(event) {
441 if (!this.networkProperties) 435 if (!this.networkProperties)
442 return; 436 return;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 */ 736 */
743 allPropertiesMatch_: function(curValue, newValue) { 737 allPropertiesMatch_: function(curValue, newValue) {
744 for (let key in newValue) { 738 for (let key in newValue) {
745 if (newValue[key] != curValue[key]) 739 if (newValue[key] != curValue[key])
746 return false; 740 return false;
747 } 741 }
748 return true; 742 return true;
749 } 743 }
750 }); 744 });
751 })(); 745 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698