OLD | NEW |
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 }, | 137 }, |
138 }, | 138 }, |
139 | 139 |
140 /** | 140 /** |
141 * Listener function for chrome.networkingPrivate.onNetworksChanged event. | 141 * Listener function for chrome.networkingPrivate.onNetworksChanged event. |
142 * @type {?function(!Array<string>)} | 142 * @type {?function(!Array<string>)} |
143 * @private | 143 * @private |
144 */ | 144 */ |
145 networksChangedListener_: null, | 145 networksChangedListener_: null, |
146 | 146 |
| 147 /** @private {boolean} */ |
| 148 didSetFocus_: false, |
| 149 |
147 /** | 150 /** |
148 * settings.RouteObserverBehavior | 151 * settings.RouteObserverBehavior |
149 * @param {!settings.Route} route | 152 * @param {!settings.Route} route |
150 * @protected | 153 * @protected |
151 */ | 154 */ |
152 currentRouteChanged: function(route) { | 155 currentRouteChanged: function(route) { |
153 if (route != settings.Route.NETWORK_DETAIL) { | 156 if (route != settings.Route.NETWORK_DETAIL) { |
154 if (this.networksChangedListener_) { | 157 if (this.networksChangedListener_) { |
155 this.networkingPrivate.onNetworksChanged.removeListener( | 158 this.networkingPrivate.onNetworksChanged.removeListener( |
156 this.networksChangedListener_); | 159 this.networksChangedListener_); |
(...skipping 16 matching lines...) Expand all Loading... |
173 var type = /** @type {!chrome.networkingPrivate.NetworkType} */ ( | 176 var type = /** @type {!chrome.networkingPrivate.NetworkType} */ ( |
174 queryParams.get('type')) || | 177 queryParams.get('type')) || |
175 CrOnc.Type.WI_FI; | 178 CrOnc.Type.WI_FI; |
176 var name = queryParams.get('name') || type; | 179 var name = queryParams.get('name') || type; |
177 this.networkProperties = { | 180 this.networkProperties = { |
178 GUID: this.guid, | 181 GUID: this.guid, |
179 Type: type, | 182 Type: type, |
180 ConnectionState: CrOnc.ConnectionState.NOT_CONNECTED, | 183 ConnectionState: CrOnc.ConnectionState.NOT_CONNECTED, |
181 Name: {Active: name}, | 184 Name: {Active: name}, |
182 }; | 185 }; |
| 186 this.didSetFocus_ = false; |
183 this.getNetworkDetails_(); | 187 this.getNetworkDetails_(); |
184 }, | 188 }, |
185 | 189 |
186 /** @private */ | 190 /** @private */ |
| 191 maybeSetFocus_: function() { |
| 192 if (this.didSetFocus_) |
| 193 return; |
| 194 this.didSetFocus_ = true; |
| 195 var button = this.$$('#buttonDiv .primary-button:not([hidden])'); |
| 196 if (!button) |
| 197 button = this.$$('#buttonDiv .secondary-button:not([hidden])'); |
| 198 button.focus(); |
| 199 }, |
| 200 |
| 201 /** @private */ |
187 close_: function() { | 202 close_: function() { |
188 // Delay navigating until the next render frame to allow other subpages to | 203 // Delay navigating until the next render frame to allow other subpages to |
189 // load first. | 204 // load first. |
190 setTimeout(function() { | 205 setTimeout(function() { |
191 settings.navigateTo(settings.Route.INTERNET); | 206 settings.navigateTo(settings.Route.INTERNET); |
192 }); | 207 }); |
193 }, | 208 }, |
194 | 209 |
195 /** @private */ | 210 /** @private */ |
196 networkPropertiesChanged_: function() { | 211 networkPropertiesChanged_: function() { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 293 } |
279 this.close_(); | 294 this.close_(); |
280 return; | 295 return; |
281 } | 296 } |
282 if (!properties) { | 297 if (!properties) { |
283 console.error('No properties for: ' + this.guid); | 298 console.error('No properties for: ' + this.guid); |
284 this.close_(); | 299 this.close_(); |
285 return; | 300 return; |
286 } | 301 } |
287 this.networkProperties = properties; | 302 this.networkProperties = properties; |
| 303 this.maybeSetFocus_(); |
288 }, | 304 }, |
289 | 305 |
290 /** | 306 /** |
291 * networkingPrivate.getState callback. | 307 * networkingPrivate.getState callback. |
292 * @param {CrOnc.NetworkStateProperties} state The network state properties. | 308 * @param {CrOnc.NetworkStateProperties} state The network state properties. |
293 * @private | 309 * @private |
294 */ | 310 */ |
295 getStateCallback_: function(state) { | 311 getStateCallback_: function(state) { |
296 if (!state) { | 312 if (!state) { |
297 // If |state| is null, the network is no longer visible, close this. | 313 // If |state| is null, the network is no longer visible, close this. |
298 console.error('Network no longer exists: ' + this.guid); | 314 console.error('Network no longer exists: ' + this.guid); |
299 this.networkProperties = undefined; | 315 this.networkProperties = undefined; |
300 this.close_(); | 316 this.close_(); |
301 } | 317 } |
302 this.networkProperties = { | 318 this.networkProperties = { |
303 GUID: state.GUID, | 319 GUID: state.GUID, |
304 Type: state.Type, | 320 Type: state.Type, |
305 Connectable: state.Connectable, | 321 Connectable: state.Connectable, |
306 ConnectionState: state.ConnectionState, | 322 ConnectionState: state.ConnectionState, |
307 }; | 323 }; |
| 324 this.maybeSetFocus_(); |
308 }, | 325 }, |
309 | 326 |
310 /** | 327 /** |
311 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC | 328 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC |
312 * network properties. | 329 * network properties. |
313 * @private | 330 * @private |
314 */ | 331 */ |
315 setNetworkProperties_: function(onc) { | 332 setNetworkProperties_: function(onc) { |
316 assert(!!this.guid); | 333 assert(!!this.guid); |
317 this.networkingPrivate.setProperties(this.guid, onc, function() { | 334 this.networkingPrivate.setProperties(this.guid, onc, function() { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 onConfigureTap_: function() { | 559 onConfigureTap_: function() { |
543 chrome.send('configureNetwork', [this.guid]); | 560 chrome.send('configureNetwork', [this.guid]); |
544 }, | 561 }, |
545 | 562 |
546 /** @private */ | 563 /** @private */ |
547 onViewAccountTap_: function() { | 564 onViewAccountTap_: function() { |
548 // startActivate() will show the account page for activated networks. | 565 // startActivate() will show the account page for activated networks. |
549 this.networkingPrivate.startActivate(this.guid); | 566 this.networkingPrivate.startActivate(this.guid); |
550 }, | 567 }, |
551 | 568 |
552 /** @const {string} */ CR_EXPAND_BUTTON_TAG: 'CR-EXPAND-BUTTON', | 569 /** @const {string} */ |
| 570 CR_EXPAND_BUTTON_TAG: 'CR-EXPAND-BUTTON', |
553 | 571 |
554 /** | 572 /** |
555 * @param {Event} event | 573 * @param {Event} event |
556 * @private | 574 * @private |
557 */ | 575 */ |
558 toggleAdvancedExpanded_: function(event) { | 576 toggleAdvancedExpanded_: function(event) { |
559 if (event.target.tagName == this.CR_EXPAND_BUTTON_TAG) | 577 if (event.target.tagName == this.CR_EXPAND_BUTTON_TAG) |
560 return; // Already handled. | 578 return; // Already handled. |
561 this.advancedExpanded_ = !this.advancedExpanded_; | 579 this.advancedExpanded_ = !this.advancedExpanded_; |
562 }, | 580 }, |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 */ | 955 */ |
938 allPropertiesMatch_: function(curValue, newValue) { | 956 allPropertiesMatch_: function(curValue, newValue) { |
939 for (var key in newValue) { | 957 for (var key in newValue) { |
940 if (newValue[key] != curValue[key]) | 958 if (newValue[key] != curValue[key]) |
941 return false; | 959 return false; |
942 } | 960 } |
943 return true; | 961 return true; |
944 } | 962 } |
945 }); | 963 }); |
946 })(); | 964 })(); |
OLD | NEW |