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 // TODO(jamiewalch): strict mode causes the page to crash so it's disabled for | 5 // TODO(jamiewalch): strict mode causes the page to crash so it's disabled for |
6 // now. Reinstate this when the associated bug is fixed. | 6 // now. Reinstate this when the associated bug is fixed. |
7 // http://code.google.com/p/v8/issues/detail?id=1423 | 7 // http://code.google.com/p/v8/issues/detail?id=1423 |
8 //"use strict"; | 8 //"use strict"; |
9 | 9 |
10 // TODO(ajwong): This seems like a bad idea to share the exact same object | 10 // TODO(ajwong): This seems like a bad idea to share the exact same object |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 } | 150 } |
151 | 151 |
152 function setGlobalModePersistent(mode) { | 152 function setGlobalModePersistent(mode) { |
153 setGlobalMode(mode); | 153 setGlobalMode(mode); |
154 remoting.setItem('startup-mode', mode); | 154 remoting.setItem('startup-mode', mode); |
155 } | 155 } |
156 | 156 |
157 function setHostMode(mode) { | 157 function setHostMode(mode) { |
158 var section = document.getElementById('host-section'); | 158 var section = document.getElementById('host-section'); |
159 var modes = section.getElementsByClassName('mode'); | 159 var modes = section.getElementsByClassName('mode'); |
160 addToDebugLog('Host mode: ' + mode); | |
160 setMode_(mode, modes); | 161 setMode_(mode, modes); |
161 } | 162 } |
162 | 163 |
163 function setClientMode(mode) { | 164 function setClientMode(mode) { |
164 var section = document.getElementById('client-section'); | 165 var section = document.getElementById('client-section'); |
165 var modes = section.getElementsByClassName('mode'); | 166 var modes = section.getElementsByClassName('mode'); |
167 addToDebugLog('Client mode: ' + mode); | |
166 setMode_(mode, modes); | 168 setMode_(mode, modes); |
167 } | 169 } |
168 | 170 |
169 function tryShare() { | 171 function tryShare() { |
172 addToDebugLog("Attempting to share..."); | |
170 if (remoting.oauth2.needsNewAccessToken()) { | 173 if (remoting.oauth2.needsNewAccessToken()) { |
174 addToDebugLog("Refreshing token..."); | |
171 remoting.oauth2.refreshAccessToken(function() { | 175 remoting.oauth2.refreshAccessToken(function() { |
172 if (remoting.oauth2.needsNewAccessToken()) { | 176 if (remoting.oauth2.needsNewAccessToken()) { |
173 // If we still need it, we're going to infinite loop. | 177 // If we still need it, we're going to infinite loop. |
178 addToDebugLog("Unable to get access token"); | |
174 throw "Unable to get access token"; | 179 throw "Unable to get access token"; |
175 } | 180 } |
176 tryShare(); | 181 tryShare(); |
177 }); | 182 }); |
178 return; | 183 return; |
179 } | 184 } |
180 | 185 |
181 var div = document.getElementById('plugin-wrapper'); | 186 var div = document.getElementById('plugin-wrapper'); |
182 var plugin = document.createElement('embed'); | 187 var plugin = document.createElement('embed'); |
183 plugin.setAttribute('type', remoting.PLUGIN_MIMETYPE); | 188 plugin.setAttribute('type', remoting.PLUGIN_MIMETYPE); |
(...skipping 14 matching lines...) Expand all Loading... | |
198 var accessCode = plugin.accessCode; | 203 var accessCode = plugin.accessCode; |
199 var accessCodeDisplay = document.getElementById('access-code-display'); | 204 var accessCodeDisplay = document.getElementById('access-code-display'); |
200 accessCodeDisplay.innerText = accessCode; | 205 accessCodeDisplay.innerText = accessCode; |
201 setHostMode('ready-to-share'); | 206 setHostMode('ready-to-share'); |
202 } else if (state == plugin.CONNECTED) { | 207 } else if (state == plugin.CONNECTED) { |
203 setHostMode('shared'); | 208 setHostMode('shared'); |
204 } else if (state == plugin.DISCONNECTED) { | 209 } else if (state == plugin.DISCONNECTED) { |
205 setHostMode('unshared'); | 210 setHostMode('unshared'); |
206 plugin.parentNode.removeChild(plugin); | 211 plugin.parentNode.removeChild(plugin); |
207 } else { | 212 } else { |
213 addToDebugLog('Unknown state -> ' + state); | |
208 window.alert('Unknown state -> ' + state); | 214 window.alert('Unknown state -> ' + state); |
Jamie
2011/06/07 18:58:32
It seems redundant to do both of these.
garykac
2011/06/07 20:44:32
Done.
| |
209 } | 215 } |
210 } | 216 } |
211 | 217 |
212 function cancelShare() { | 218 function cancelShare() { |
219 addToDebugLog('Canceling share'); | |
Jamie
2011/06/07 18:58:32
pico-nit: Add an elipsis to this (and the next) lo
garykac
2011/06/07 20:44:32
Done.
| |
213 var plugin = document.getElementById(remoting.HOST_PLUGIN_ID); | 220 var plugin = document.getElementById(remoting.HOST_PLUGIN_ID); |
214 plugin.disconnect(); | 221 plugin.disconnect(); |
215 } | 222 } |
216 | 223 |
217 function startSession_() { | 224 function startSession_() { |
225 addToDebugLog('Starting session'); | |
218 remoting.username = remoting.getItem(remoting.XMPP_LOGIN_NAME); | 226 remoting.username = remoting.getItem(remoting.XMPP_LOGIN_NAME); |
219 document.location = 'remoting_session.html'; | 227 document.location = 'remoting_session.html'; |
220 } | 228 } |
221 | 229 |
222 function showConnectError_(responseCode, responseString) { | 230 function showConnectError_(responseCode, responseString) { |
223 var invalid = document.getElementById('invalid-access-code'); | 231 var invalid = document.getElementById('invalid-access-code'); |
224 var other = document.getElementById('other-connect-error'); | 232 var other = document.getElementById('other-connect-error'); |
225 if (responseCode == 404) { | 233 if (responseCode == 404) { |
226 invalid.style.display = 'block'; | 234 invalid.style.display = 'block'; |
227 other.style.display = 'none'; | 235 other.style.display = 'none'; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 } else { | 301 } else { |
294 setClientMode('connecting'); | 302 setClientMode('connecting'); |
295 resolveSupportId(parts[0]); | 303 resolveSupportId(parts[0]); |
296 } | 304 } |
297 } | 305 } |
298 | 306 |
299 function cancelConnect() { | 307 function cancelConnect() { |
300 remoting.accessCode = ''; | 308 remoting.accessCode = ''; |
301 setClientMode('unconnected'); | 309 setClientMode('unconnected'); |
302 } | 310 } |
OLD | NEW |