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 // Maximum numer of lines to record in the debug log. | 5 // Maximum numer of lines to record in the debug log. |
6 // Only the most recent <n> lines are displayed. | 6 // Only the most recent <n> lines are displayed. |
7 var MAX_DEBUG_LOG_SIZE = 1000; | 7 var MAX_DEBUG_LOG_SIZE = 1000; |
8 | 8 |
9 // Message id so that we can identify (and ignore) message fade operations for | 9 // Message id so that we can identify (and ignore) message fade operations for |
10 // old messages. This starts at 1 and is incremented for each new message. | 10 // old messages. This starts at 1 and is incremented for each new message. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 xhr.withCredentials = true; | 46 xhr.withCredentials = true; |
47 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | 47 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
48 xhr.onreadystatechange = function() { | 48 xhr.onreadystatechange = function() { |
49 if (xhr.readyState == 4) { | 49 if (xhr.readyState == 4) { |
50 if (xhr.status == 200) { | 50 if (xhr.status == 200) { |
51 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); | 51 addToDebugLog('Receiving Iq: --' + xhr.responseText + '--'); |
52 var clientjid = xhr.responseText; | 52 var clientjid = xhr.responseText; |
53 | 53 |
54 chromoting.plugin.sendIq = sendIq; | 54 chromoting.plugin.sendIq = sendIq; |
55 // TODO:(jamiewalch): Pass in the correct nonce. | 55 // TODO:(jamiewalch): Pass in the correct nonce. |
56 chromoting.plugin.connectSandboxed(clientjid, chromoting.hostjid, ''); | 56 chromoting.plugin.connectSandboxed(clientjid, chromoting.hostjid); |
Jamie
2011/05/23 19:24:12
Add a TODO here to revisit once it's been renamed
awong
2011/05/23 20:43:23
Don't think it's necessary. All that code will ju
| |
57 // TODO(ajwong): This should just be feedIq(); | 57 // TODO(ajwong): This should just be feedIq(); |
58 window.setTimeout(feedIq, 1000); | 58 window.setTimeout(feedIq, 1000); |
59 } else { | 59 } else { |
60 addToDebugLog('FailedToConnect: --' + xhr.responseText + | 60 addToDebugLog('FailedToConnect: --' + xhr.responseText + |
61 '-- (status=' + xhr.status + ')'); | 61 '-- (status=' + xhr.status + ')'); |
62 setClientStateMessage("Failed") | 62 setClientStateMessage("Failed") |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 xhr.send('host_jid=' + encodeURIComponent(chromoting.hostjid) + | 66 xhr.send('host_jid=' + encodeURIComponent(chromoting.hostjid) + |
67 '&username=' + encodeURIComponent(chromoting.username) + | 67 '&username=' + encodeURIComponent(chromoting.username) + |
68 '&password=' + encodeURIComponent(chromoting.xmppAuthToken)); | 68 '&password=' + encodeURIComponent(chromoting.talkToken)); |
69 setClientStateMessage("Connecting") | 69 setClientStateMessage("Connecting") |
70 } | 70 } |
71 | 71 |
72 function sendIq(msg) { | 72 function sendIq(msg) { |
73 addToDebugLog('Sending Iq: ' + msg); | 73 addToDebugLog('Sending Iq: ' + msg); |
74 | 74 |
75 // Extract the top level fields of the Iq packet. | 75 // Extract the top level fields of the Iq packet. |
76 // TODO(ajwong): Can the plugin just return these fields broken out. | 76 // TODO(ajwong): Can the plugin just return these fields broken out. |
77 parser = new DOMParser(); | 77 parser = new DOMParser(); |
78 iqNode = parser.parseFromString(msg,"text/xml").firstChild; | 78 iqNode = parser.parseFromString(msg,"text/xml").firstChild; |
(...skipping 14 matching lines...) Expand all Loading... | |
93 } | 93 } |
94 | 94 |
95 function init() { | 95 function init() { |
96 // Kick off the connection. | 96 // Kick off the connection. |
97 var plugin = document.getElementById('chromoting'); | 97 var plugin = document.getElementById('chromoting'); |
98 | 98 |
99 chromoting.plugin = plugin; | 99 chromoting.plugin = plugin; |
100 chromoting.username = document.username; | 100 chromoting.username = document.username; |
101 chromoting.hostname = document.hostname; | 101 chromoting.hostname = document.hostname; |
102 chromoting.hostjid = document.hostjid; | 102 chromoting.hostjid = document.hostjid; |
103 chromoting.xmppAuthToken = document.xmppAuthToken; | 103 chromoting.talkToken = document.talkToken; |
104 chromoting.connectMethod = document.connectMethod; | 104 chromoting.connectMethod = document.connectMethod; |
105 | 105 |
106 // Only allow https connections to the httpXmppProxy unless we're running in | 106 // Only allow https connections to the httpXmppProxy unless we're running in |
107 // insecure mode. | 107 // insecure mode. |
108 if (document.insecure != "1" && | 108 if (document.insecure != "1" && |
109 document.httpXmppProxy.search(/^ *https:\/\//) == -1) { | 109 document.httpXmppProxy.search(/^ *https:\/\//) == -1) { |
110 addToDebugLog('Aborting. httpXmppProxy does not specify https protocol: ' + | 110 addToDebugLog('Aborting. httpXmppProxy does not specify https protocol: ' + |
111 document.httpXmppProxy); | 111 document.httpXmppProxy); |
112 return; | 112 return; |
113 } | 113 } |
(...skipping 11 matching lines...) Expand all Loading... | |
125 addToDebugLog('Connect to ' + chromoting.hostname + ' as user ' + | 125 addToDebugLog('Connect to ' + chromoting.hostname + ' as user ' + |
126 chromoting.username); | 126 chromoting.username); |
127 | 127 |
128 // TODO(garykac): Clean exit if |connect| isn't a function. | 128 // TODO(garykac): Clean exit if |connect| isn't a function. |
129 if (typeof plugin.connect === 'function') { | 129 if (typeof plugin.connect === 'function') { |
130 if (chromoting.connectMethod == "sandboxed") { | 130 if (chromoting.connectMethod == "sandboxed") { |
131 registerConnection(); | 131 registerConnection(); |
132 } else { | 132 } else { |
133 // TODO:(jamiewalch): Pass in the correct nonce. | 133 // TODO:(jamiewalch): Pass in the correct nonce. |
134 plugin.connect(chromoting.username, chromoting.hostjid, | 134 plugin.connect(chromoting.username, chromoting.hostjid, |
135 chromoting.xmppAuthToken, ''); | 135 chromoting.talkToken, ''); |
136 } | 136 } |
137 } else { | 137 } else { |
138 addToDebugLog('ERROR: chromoting plugin not loaded'); | 138 addToDebugLog('ERROR: chromoting plugin not loaded'); |
139 setClientStateMessage('Plugin not loaded'); | 139 setClientStateMessage('Plugin not loaded'); |
140 } | 140 } |
141 | 141 |
142 document.getElementById('title').innerText = chromoting.hostname; | 142 document.getElementById('title').innerText = chromoting.hostname; |
143 } | 143 } |
144 | 144 |
145 function toggleDebugLog() { | 145 function toggleDebugLog() { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 setClientStateMessage( | 339 setClientStateMessage( |
340 "Video stats: bandwidth: " + videoBandwidth.toFixed(2) + "Kbps" + | 340 "Video stats: bandwidth: " + videoBandwidth.toFixed(2) + "Kbps" + |
341 ", Latency: capture: " + videoCaptureLatency.toFixed(2) + "ms" + | 341 ", Latency: capture: " + videoCaptureLatency.toFixed(2) + "ms" + |
342 ", encode: " + videoEncodeLatency.toFixed(2) + "ms" + | 342 ", encode: " + videoEncodeLatency.toFixed(2) + "ms" + |
343 ", decode: " + videoDecodeLatency.toFixed(2) + "ms" + | 343 ", decode: " + videoDecodeLatency.toFixed(2) + "ms" + |
344 ", render: " + videoRenderLatency.toFixed(2) + "ms"); | 344 ", render: " + videoRenderLatency.toFixed(2) + "ms"); |
345 | 345 |
346 // Update the stats once per second. | 346 // Update the stats once per second. |
347 window.setTimeout("updateStatusBarStats()", 1000); | 347 window.setTimeout("updateStatusBarStats()", 1000); |
348 } | 348 } |
OLD | NEW |