OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 var localStrings = new LocalStrings(); | 5 var localStrings = new LocalStrings(); |
6 | 6 |
7 cr.define('diag', function() { | 7 cr.define('diag', function() { |
8 /** | 8 /** |
9 * Encapsulated handling of the diagnostics page. | 9 * Encapsulated handling of the diagnostics page. |
10 */ | 10 */ |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 /** | 107 /** |
108 * Updates the connectivity status with netif information. | 108 * Updates the connectivity status with netif information. |
109 * @param {Object} netifStatus Dictionary of network adapter status. | 109 * @param {Object} netifStatus Dictionary of network adapter status. |
110 */ | 110 */ |
111 setNetifStatus_: function(netifStatus) { | 111 setNetifStatus_: function(netifStatus) { |
112 // Hide the "loading" message and show the "choose-adapter" message. | 112 // Hide the "loading" message and show the "choose-adapter" message. |
113 $('loading').hidden = true; | 113 $('loading').hidden = true; |
114 $('choose-adapter').hidden = false; | 114 $('choose-adapter').hidden = false; |
115 | 115 |
116 // Update netif state. | 116 // Update netif state. |
117 var found_valid_ip = false; | 117 var foundValidIp = false; |
118 for (var i = 0; i < DiagPage.AdapterType.length; i++) { | 118 for (var i = 0; i < DiagPage.AdapterType.length; i++) { |
119 var adapterType = DiagPage.AdapterType[i]; | 119 var adapterType = DiagPage.AdapterType[i]; |
120 var status = netifStatus[adapterType.adapter]; | 120 var status = netifStatus[adapterType.adapter]; |
121 if (!status) | 121 if (!status) |
122 this.adapterStatus_[i] = DiagPage.AdapterStatus.NOT_FOUND; | 122 this.adapterStatus_[i] = DiagPage.AdapterStatus.NOT_FOUND; |
123 else if (!status.flags || status.flags.indexOf('up') == -1) | 123 else if (!status.flags || status.flags.indexOf('up') == -1) |
124 this.adapterStatus_[i] = DiagPage.AdapterStatus.DISABLED; | 124 this.adapterStatus_[i] = DiagPage.AdapterStatus.DISABLED; |
125 else if (!status.ipv4) | 125 else if (!status.ipv4) |
126 this.adapterStatus_[i] = DiagPage.AdapterStatus.NO_IP; | 126 this.adapterStatus_[i] = DiagPage.AdapterStatus.NO_IP; |
127 else | 127 else |
128 this.adapterStatus_[i] = DiagPage.AdapterStatus.VALID_IP; | 128 this.adapterStatus_[i] = DiagPage.AdapterStatus.VALID_IP; |
129 | 129 |
130 if (this.adapterStatus_[i] == DiagPage.AdapterStatus.VALID_IP) | 130 if (this.adapterStatus_[i] == DiagPage.AdapterStatus.VALID_IP) |
131 found_valid_ip = true; | 131 foundValidIp = true; |
132 } | 132 } |
133 | 133 |
134 // If we have valid IP, start ping test. | 134 // If we have valid IP, start ping test. |
135 if (found_valid_ip && | 135 if (foundValidIp && |
136 this.pingTestStatus_ == DiagPage.PingTestStatus.NOT_STARTED) { | 136 this.pingTestStatus_ == DiagPage.PingTestStatus.NOT_STARTED) { |
137 this.pingTestStatus_ == DiagPage.PingTestStatus.IN_PROGRESS; | 137 this.pingTestStatus_ == DiagPage.PingTestStatus.IN_PROGRESS; |
138 chrome.send('testICMP', [String('8.8.8.8')]); | 138 chrome.send('testICMP', [String('8.8.8.8')]); |
139 } | 139 } |
140 | 140 |
141 // Update UI | 141 // Update UI |
142 this.updateAdapterSelection_(); | 142 this.updateAdapterSelection_(); |
143 this.updateConnectivityStatus_(); | 143 this.updateConnectivityStatus_(); |
144 | 144 |
145 // Clear the getNetifStatusInProgress flag. | 145 // Clear the getNetifStatusInProgress flag. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 DiagPage: DiagPage | 326 DiagPage: DiagPage |
327 }; | 327 }; |
328 }); | 328 }); |
329 | 329 |
330 /** | 330 /** |
331 * Initialize the DiagPage upon DOM content loaded. | 331 * Initialize the DiagPage upon DOM content loaded. |
332 */ | 332 */ |
333 document.addEventListener('DOMContentLoaded', function() { | 333 document.addEventListener('DOMContentLoaded', function() { |
334 diag.DiagPage.getInstance().initialize(); | 334 diag.DiagPage.getInstance().initialize(); |
335 }); | 335 }); |
OLD | NEW |