| 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 // Flag to indicate whether or not to show offline hosts in the host list. | 5 // Flag to indicate whether or not to show offline hosts in the host list. |
| 6 chromoting.showOfflineHosts = true; | 6 chromoting.showOfflineHosts = true; |
| 7 | 7 |
| 8 // String to identify bad auth tokens. | 8 // String to identify bad auth tokens. |
| 9 var BAD_AUTH_TOKEN = 'bad_token'; | 9 var BAD_AUTH_TOKEN = 'bad_token'; |
| 10 | 10 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 message = 'No hosts available.' + | 164 message = 'No hosts available.' + |
| 165 ' See LINK for info on how to set up a new host.'; | 165 ' See LINK for info on how to set up a new host.'; |
| 166 } else { | 166 } else { |
| 167 message = 'No online hosts available (' + | 167 message = 'No online hosts available (' + |
| 168 numOfflineHosts + ' offline hosts).'; | 168 numOfflineHosts + ' offline hosts).'; |
| 169 } | 169 } |
| 170 displayMessage(hostlistDiv, 'message', message); | 170 displayMessage(hostlistDiv, 'message', message); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 function openSession(hostname, hostjid, method) { |
| 175 var proxy = document.getElementById('oauth2_proxy').value; |
| 176 var token_type = 'oauth2'; |
| 177 if (document.getElementById('use_clientlogin').checked) { |
| 178 proxy = document.getElementById('clientlogin_proxy').value; |
| 179 token_type = 'clientlogin'; |
| 180 } |
| 181 |
| 182 var url = 'session?hostname=' + encodeURIComponent(hostname) |
| 183 + '&hostjid=' + encodeURIComponent(hostjid) |
| 184 + '&http_xmpp_proxy=' + encodeURIComponent(proxy) |
| 185 + '&token_type=' + encodeURIComponent(token_type) + |
| 186 '&connect_method=' + encodeURIComponent(method); |
| 187 |
| 188 window.open(url); |
| 189 } |
| 190 |
| 174 // Create a single host description element. | 191 // Create a single host description element. |
| 175 function addHostInfo(host) { | 192 function addHostInfo(host) { |
| 176 var hostEntry = document.createElement('div'); | 193 var hostEntry = document.createElement('div'); |
| 177 hostEntry.setAttribute('class', 'hostentry'); | 194 hostEntry.setAttribute('class', 'hostentry'); |
| 178 | 195 |
| 179 var hostIcon = document.createElement('img'); | 196 var hostIcon = document.createElement('img'); |
| 180 hostIcon.className = "hosticon"; | 197 hostIcon.className = "hosticon"; |
| 181 hostIcon.style.height = 64; | 198 hostIcon.style.height = 64; |
| 182 hostIcon.style.width = 64; | 199 hostIcon.style.width = 64; |
| 183 hostEntry.appendChild(hostIcon); | 200 hostEntry.appendChild(hostIcon); |
| 184 | 201 |
| 185 if (host.status == 'ONLINE') { | 202 if (host.status == 'ONLINE') { |
| 186 var span = document.createElement('span'); | 203 var span = document.createElement('span'); |
| 187 span.setAttribute('class', 'connect'); | 204 span.setAttribute('class', 'connect'); |
| 188 var connect = document.createElement('input'); | 205 var connect = document.createElement('input'); |
| 189 | 206 |
| 190 connect.setAttribute('type', 'button'); | 207 connect.setAttribute('type', 'button'); |
| 191 connect.setAttribute('value', 'Connect'); | 208 connect.setAttribute('value', 'Connect'); |
| 192 connect.setAttribute('onclick', "window.open('session?hostname=" + | 209 connect.setAttribute('onclick', |
| 193 encodeURIComponent(host.hostName) + | 210 "openSession('" + host.hostName + "', " |
| 194 "&hostjid=" + encodeURIComponent(host.jabberId) + | 211 + "'" + host.jabberId + "', 'direct');"); |
| 195 "');"); | |
| 196 span.appendChild(connect); | 212 span.appendChild(connect); |
| 197 | 213 |
| 198 var connectSandboxed = document.createElement('input'); | 214 var connectSandboxed = document.createElement('input'); |
| 199 connectSandboxed.setAttribute('type', 'button'); | 215 connectSandboxed.setAttribute('type', 'button'); |
| 200 connectSandboxed.setAttribute('value', 'Connect Sandboxed'); | 216 connectSandboxed.setAttribute('value', 'Connect Sandboxed'); |
| 201 connectSandboxed.setAttribute('onclick', | 217 connectSandboxed.setAttribute('onclick', |
| 202 "window.open('session?hostname=" + encodeURIComponent(host.hostName) + | 218 "openSession('" + host.hostName + "', " |
| 203 "&hostjid=" + encodeURIComponent(host.jabberId) + | 219 + "'" + host.jabberId + "', 'sandboxed');"); |
| 204 "&http_xmpp_proxy=" + encodeURIComponent( | |
| 205 document.getElementById('http_xmpp_proxy').value) + | |
| 206 "&connect_method=sandboxed');"); | |
| 207 span.appendChild(connectSandboxed); | 220 span.appendChild(connectSandboxed); |
| 208 | 221 |
| 209 hostEntry.appendChild(span); | 222 hostEntry.appendChild(span); |
| 210 hostIcon.setAttribute('src', 'static_files/online.png'); | 223 hostIcon.setAttribute('src', 'static_files/online.png'); |
| 211 } else { | 224 } else { |
| 212 hostIcon.setAttribute('src', 'static_files/offline.png'); | 225 hostIcon.setAttribute('src', 'static_files/offline.png'); |
| 213 } | 226 } |
| 214 | 227 |
| 215 var hostName = document.createElement('p'); | 228 var hostName = document.createElement('p'); |
| 216 hostName.setAttribute('class', 'hostindent hostname'); | 229 hostName.setAttribute('class', 'hostindent hostname'); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 'apps.googleusercontent.com') | 272 'apps.googleusercontent.com') |
| 260 + '&redirect_uri=' + window.location.origin + '/auth/oauth2_return' | 273 + '&redirect_uri=' + window.location.origin + '/auth/oauth2_return' |
| 261 + '&scope=' + encodeURIComponent( | 274 + '&scope=' + encodeURIComponent( |
| 262 'https://www.googleapis.com/auth/chromoting ' + | 275 'https://www.googleapis.com/auth/chromoting ' + |
| 263 'https://www.googleapis.com/auth/googletalk') | 276 'https://www.googleapis.com/auth/googletalk') |
| 264 + '&state=' + encodeURIComponent(window.location.href) | 277 + '&state=' + encodeURIComponent(window.location.href) |
| 265 + '&response_type=code'; | 278 + '&response_type=code'; |
| 266 window.location.replace(oauth_code_url); | 279 window.location.replace(oauth_code_url); |
| 267 } | 280 } |
| 268 | 281 |
| OLD | NEW |