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

Side by Side Diff: chrome/browser/resources/settings/internet_page/internet_detail_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-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 * Highest priority connected network or null.
36 * @type {?CrOnc.NetworkStateProperties}
37 */
38 defaultNetwork: {
39 type: Object,
40 value: null,
41 },
42
43 /**
44 * Interface for networkingPrivate calls, passed from internet_page.
45 * @type {NetworkingPrivate}
46 */
47 networkingPrivate: Object,
48
49 /**
35 * The network AutoConnect state. 50 * The network AutoConnect state.
51 * @private
36 */ 52 */
37 autoConnect: { 53 autoConnect_: {
38 type: Boolean, 54 type: Boolean,
39 value: false, 55 value: false,
40 observer: 'autoConnectChanged_', 56 observer: 'autoConnectChanged_',
41 }, 57 },
42 58
43 /** 59 /**
44 * The network preferred state. 60 * The network preferred state.
61 * @private
45 */ 62 */
46 preferNetwork: { 63 preferNetwork_: {
47 type: Boolean, 64 type: Boolean,
48 value: false, 65 value: false,
49 observer: 'preferNetworkChanged_', 66 observer: 'preferNetworkChanged_',
50 }, 67 },
51 68
52 /** 69 /**
53 * The network IP Address. 70 * The network IP Address.
71 * @private
54 */ 72 */
55 IPAddress: { 73 IPAddress_: {
56 type: String, 74 type: String,
57 value: '', 75 value: '',
58 }, 76 },
59 77
60 /** 78 /** @private */
61 * Highest priority connected network or null. 79 advancedExpanded_: Boolean,
62 * @type {?CrOnc.NetworkStateProperties}
63 */
64 defaultNetwork: {
65 type: Object,
66 value: null,
67 },
68
69 advancedExpanded: {type: Boolean},
70 80
71 /** 81 /**
72 * Object providing network type values for data binding. 82 * Object providing network type values for data binding.
73 * @const 83 * @const
84 * @private
74 */ 85 */
75 NetworkType: { 86 NetworkType_: {
76 type: Object, 87 type: Object,
77 value: { 88 value: {
78 CELLULAR: CrOnc.Type.CELLULAR, 89 CELLULAR: CrOnc.Type.CELLULAR,
79 ETHERNET: CrOnc.Type.ETHERNET, 90 ETHERNET: CrOnc.Type.ETHERNET,
80 VPN: CrOnc.Type.VPN, 91 VPN: CrOnc.Type.VPN,
81 WIFI: CrOnc.Type.WI_FI, 92 WIFI: CrOnc.Type.WI_FI,
82 WIMAX: CrOnc.Type.WI_MAX, 93 WIMAX: CrOnc.Type.WI_MAX,
83 }, 94 },
84 readOnly: true 95 readOnly: true
85 }, 96 },
86
87 /**
88 * Interface for networkingPrivate calls, passed from internet_page.
89 * @type {NetworkingPrivate}
90 */
91 networkingPrivate: {type: Object},
92 }, 97 },
93 98
94 /** 99 /**
95 * Listener function for chrome.networkingPrivate.onNetworksChanged event. 100 * Listener function for chrome.networkingPrivate.onNetworksChanged event.
96 * @type {?function(!Array<string>)} 101 * @type {?function(!Array<string>)}
97 * @private 102 * @private
98 */ 103 */
99 networksChangedListener_: null, 104 networksChangedListener_: null,
100 105
101 /** 106 /**
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 }); 140 });
136 }, 141 },
137 142
138 /** @private */ 143 /** @private */
139 networkPropertiesChanged_: function() { 144 networkPropertiesChanged_: function() {
140 if (!this.networkProperties) 145 if (!this.networkProperties)
141 return; 146 return;
142 147
143 // Update autoConnect if it has changed. Default value is false. 148 // Update autoConnect if it has changed. Default value is false.
144 var autoConnect = CrOnc.getAutoConnect(this.networkProperties); 149 var autoConnect = CrOnc.getAutoConnect(this.networkProperties);
145 if (autoConnect != this.autoConnect) 150 if (autoConnect != this.autoConnect_)
146 this.autoConnect = autoConnect; 151 this.autoConnect_ = autoConnect;
147 152
148 // Update preferNetwork if it has changed. Default value is false. 153 // Update preferNetwork if it has changed. Default value is false.
149 var priority = /** @type {number} */ ( 154 var priority = /** @type {number} */ (
150 CrOnc.getActiveValue(this.networkProperties.Priority) || 0); 155 CrOnc.getActiveValue(this.networkProperties.Priority) || 0);
151 var preferNetwork = priority > 0; 156 var preferNetwork = priority > 0;
152 if (preferNetwork != this.preferNetwork) 157 if (preferNetwork != this.preferNetwork_)
153 this.preferNetwork = preferNetwork; 158 this.preferNetwork_ = preferNetwork;
154 159
155 // Set the IPAddress property to the IPV4 Address. 160 // Set the IPAddress property to the IPV4 Address.
156 var ipv4 = 161 var ipv4 =
157 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); 162 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4);
158 this.IPAddress = (ipv4 && ipv4.IPAddress) || ''; 163 this.IPAddress_ = (ipv4 && ipv4.IPAddress) || '';
159 164
160 // Update the detail page title. 165 // Update the detail page title.
161 this.parentNode.pageTitle = 166 this.parentNode.pageTitle =
162 CrOnc.getNetworkName(this.networkProperties, this.i18n); 167 CrOnc.getNetworkName(this.networkProperties, this.i18n);
163 }, 168 },
164 169
165 /** @private */ 170 /** @private */
166 autoConnectChanged_: function() { 171 autoConnectChanged_: function() {
167 if (!this.networkProperties || !this.guid) 172 if (!this.networkProperties || !this.guid)
168 return; 173 return;
169 var onc = this.getEmptyNetworkProperties_(); 174 var onc = this.getEmptyNetworkProperties_();
170 CrOnc.setTypeProperty(onc, 'AutoConnect', this.autoConnect); 175 CrOnc.setTypeProperty(onc, 'AutoConnect', this.autoConnect_);
171 this.setNetworkProperties_(onc); 176 this.setNetworkProperties_(onc);
172 }, 177 },
173 178
174 /** @private */ 179 /** @private */
175 preferNetworkChanged_: function() { 180 preferNetworkChanged_: function() {
176 if (!this.networkProperties || !this.guid) 181 if (!this.networkProperties || !this.guid)
177 return; 182 return;
178 var onc = this.getEmptyNetworkProperties_(); 183 var onc = this.getEmptyNetworkProperties_();
179 onc.Priority = this.preferNetwork ? 1 : 0; 184 onc.Priority = this.preferNetwork_ ? 1 : 0;
180 this.setNetworkProperties_(onc); 185 this.setNetworkProperties_(onc);
181 }, 186 },
182 187
183 /** 188 /**
184 * networkingPrivate.onNetworksChanged event callback. 189 * networkingPrivate.onNetworksChanged event callback.
185 * @param {!Array<string>} networkIds The list of changed network GUIDs. 190 * @param {!Array<string>} networkIds The list of changed network GUIDs.
186 * @private 191 * @private
187 */ 192 */
188 onNetworksChangedEvent_: function(networkIds) { 193 onNetworksChangedEvent_: function(networkIds) {
189 if (networkIds.indexOf(this.guid) != -1) 194 if (networkIds.indexOf(this.guid) != -1)
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 this.networkingPrivate.startActivate(this.guid); 422 this.networkingPrivate.startActivate(this.guid);
418 }, 423 },
419 424
420 /** 425 /**
421 * @param {Event} event 426 * @param {Event} event
422 * @private 427 * @private
423 */ 428 */
424 toggleAdvancedExpanded_: function(event) { 429 toggleAdvancedExpanded_: function(event) {
425 if (event.target.id == 'expandButton') 430 if (event.target.id == 'expandButton')
426 return; // Already handled. 431 return; // Already handled.
427 this.advancedExpanded = !this.advancedExpanded; 432 this.advancedExpanded_ = !this.advancedExpanded_;
428 }, 433 },
429 434
430 /** 435 /**
431 * Event triggered for elements associated with network properties. 436 * Event triggered for elements associated with network properties.
432 * @param {!{detail: !{field: string, value: (string|!Object)}}} event 437 * @param {!{detail: !{field: string, value: (string|!Object)}}} event
433 * @private 438 * @private
434 */ 439 */
435 onNetworkPropertyChange_: function(event) { 440 onNetworkPropertyChange_: function(event) {
436 if (!this.networkProperties) 441 if (!this.networkProperties)
437 return; 442 return;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 */ 742 */
738 allPropertiesMatch_: function(curValue, newValue) { 743 allPropertiesMatch_: function(curValue, newValue) {
739 for (let key in newValue) { 744 for (let key in newValue) {
740 if (newValue[key] != curValue[key]) 745 if (newValue[key] != curValue[key])
741 return false; 746 return false;
742 } 747 }
743 return true; 748 return true;
744 } 749 }
745 }); 750 });
746 })(); 751 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698