OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 remoting = chrome.extension.getBackgroundPage().remoting; | 5 var remoting = chrome.extension.getBackgroundPage().remoting; |
6 | 6 |
7 // Chromoting session API version (for this javascript). | 7 // Chromoting session API version (for this javascript). |
8 // This is compared with the plugin API version to verify that they are | 8 // This is compared with the plugin API version to verify that they are |
9 // compatible. | 9 // compatible. |
10 remoting.apiVersion = 2; | 10 remoting.apiVersion = 2; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 | 128 |
129 // Setup the callback that the plugin will call when the connection status | 129 // Setup the callback that the plugin will call when the connection status |
130 // has changes and the UI needs to be updated. It needs to be an object with | 130 // has changes and the UI needs to be updated. It needs to be an object with |
131 // a 'callback' property that contains the callback function. | 131 // a 'callback' property that contains the callback function. |
132 plugin.connectionInfoUpdate = connectionInfoUpdateCallback; | 132 plugin.connectionInfoUpdate = connectionInfoUpdateCallback; |
133 plugin.debugInfo = debugInfoCallback; | 133 plugin.debugInfo = debugInfoCallback; |
134 plugin.desktopSizeUpdate = desktopSizeChanged; | 134 plugin.desktopSizeUpdate = desktopSizeChanged; |
135 plugin.loginChallenge = loginChallengeCallback; | 135 plugin.loginChallenge = loginChallengeCallback; |
136 | 136 |
| 137 if (typeof plugin.connect !== 'function') { |
| 138 setClientStateMessage("Unable to load plugin. Please make sure that " + |
| 139 "'Remoting' and 'P2P API' are enabled in chrome://flags."); |
| 140 return; |
| 141 } |
| 142 |
137 if (!checkVersion(plugin)) { | 143 if (!checkVersion(plugin)) { |
138 // TODO(garykac): We need better messaging here. Perhaps an install link. | 144 // TODO(garykac): We need better messaging here. Perhaps an install link. |
139 setClientStateMessage("Out of date. Please re-install."); | 145 setClientStateMessage("Out of date. Please re-install."); |
140 return; | 146 return; |
141 } | 147 } |
142 | 148 |
143 addToDebugLog('Connect as user ' + remoting.username); | 149 addToDebugLog('Connect as user ' + remoting.username); |
144 | 150 registerConnection(); |
145 // TODO(garykac): Clean exit if |connect| isn't a function. | |
146 if (typeof plugin.connect === 'function') { | |
147 registerConnection(); | |
148 } else { | |
149 addToDebugLog('ERROR: remoting plugin not loaded'); | |
150 setClientStateMessage('Plugin not loaded'); | |
151 } | |
152 | |
153 } | 151 } |
154 | 152 |
155 function toggleScaleToFit() { | 153 function toggleScaleToFit() { |
156 remoting.scaleToFit = !remoting.scaleToFit; | 154 remoting.scaleToFit = !remoting.scaleToFit; |
157 document.getElementById('scale-to-fit-toggle').value = | 155 document.getElementById('scale-to-fit-toggle').value = |
158 remoting.scaleToFit ? 'No scaling' : 'Scale to fit'; | 156 remoting.scaleToFit ? 'No scaling' : 'Scale to fit'; |
159 remoting.plugin.setScaleToFit(remoting.scaleToFit); | 157 remoting.plugin.setScaleToFit(remoting.scaleToFit); |
160 } | 158 } |
161 | 159 |
162 /** | 160 /** |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 'Bandwidth: ' + videoBandwidth.toFixed(2) + units + | 308 'Bandwidth: ' + videoBandwidth.toFixed(2) + units + |
311 ', Capture: ' + videoCaptureLatency.toFixed(2) + 'ms' + | 309 ', Capture: ' + videoCaptureLatency.toFixed(2) + 'ms' + |
312 ', Encode: ' + videoEncodeLatency.toFixed(2) + 'ms' + | 310 ', Encode: ' + videoEncodeLatency.toFixed(2) + 'ms' + |
313 ', Decode: ' + videoDecodeLatency.toFixed(2) + 'ms' + | 311 ', Decode: ' + videoDecodeLatency.toFixed(2) + 'ms' + |
314 ', Render: ' + videoRenderLatency.toFixed(2) + 'ms' + | 312 ', Render: ' + videoRenderLatency.toFixed(2) + 'ms' + |
315 ', Latency: ' + roundTripLatency.toFixed(2) + 'ms'); | 313 ', Latency: ' + roundTripLatency.toFixed(2) + 'ms'); |
316 | 314 |
317 // Update the stats once per second. | 315 // Update the stats once per second. |
318 window.setTimeout('updateStatusBarStats()', 1000); | 316 window.setTimeout('updateStatusBarStats()', 1000); |
319 } | 317 } |
OLD | NEW |