Chromium Code Reviews| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
| 8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
| 9 | 9 |
| 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; | 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 // Create global objects. | 37 // Create global objects. |
| 38 remoting.oauth2 = new remoting.OAuth2(); | 38 remoting.oauth2 = new remoting.OAuth2(); |
| 39 remoting.stats = new remoting.ConnectionStats( | 39 remoting.stats = new remoting.ConnectionStats( |
| 40 document.getElementById('statistics')); | 40 document.getElementById('statistics')); |
| 41 remoting.formatIq = new remoting.FormatIq(); | 41 remoting.formatIq = new remoting.FormatIq(); |
| 42 remoting.hostList = new remoting.HostList( | 42 remoting.hostList = new remoting.HostList( |
| 43 document.getElementById('host-list'), | 43 document.getElementById('host-list'), |
| 44 document.getElementById('host-list-error')); | 44 document.getElementById('host-list-error')); |
| 45 remoting.toolbar = new remoting.Toolbar( | 45 remoting.toolbar = new remoting.Toolbar( |
| 46 document.getElementById('session-toolbar')); | 46 document.getElementById('session-toolbar')); |
| 47 remoting.clipboard = new remoting.Clipboard(); | |
| 47 | 48 |
| 48 refreshEmail_(); | 49 refreshEmail_(); |
| 49 var email = remoting.oauth2.getCachedEmail(); | 50 var email = remoting.oauth2.getCachedEmail(); |
| 50 if (email) { | 51 if (email) { |
| 51 document.getElementById('current-email').innerText = email; | 52 document.getElementById('current-email').innerText = email; |
| 52 } | 53 } |
| 53 | 54 |
| 55 window.addEventListener('focus', pluginGotFocus_, false); | |
| 54 window.addEventListener('blur', pluginLostFocus_, false); | 56 window.addEventListener('blur', pluginLostFocus_, false); |
| 57 window.addEventListener('paste', pluginGotPaste_, false); | |
| 55 | 58 |
| 56 // Parse URL parameters. | 59 // Parse URL parameters. |
| 57 var urlParams = getUrlParameters_(); | 60 var urlParams = getUrlParameters_(); |
| 58 if ('mode' in urlParams) { | 61 if ('mode' in urlParams) { |
| 59 if (urlParams['mode'] == 'me2me') { | 62 if (urlParams['mode'] == 'me2me') { |
| 60 var hostId = urlParams['hostId']; | 63 var hostId = urlParams['hostId']; |
| 61 remoting.connectMe2Me(hostId, true); | 64 remoting.connectMe2Me(hostId, true); |
| 62 return; | 65 return; |
| 63 } | 66 } |
| 64 } | 67 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 /** | 120 /** |
| 118 * Sign the user out of Chromoting by clearing the OAuth refresh token. | 121 * Sign the user out of Chromoting by clearing the OAuth refresh token. |
| 119 */ | 122 */ |
| 120 remoting.clearOAuth2 = function() { | 123 remoting.clearOAuth2 = function() { |
| 121 remoting.oauth2.clear(); | 124 remoting.oauth2.clear(); |
| 122 window.localStorage.removeItem(KEY_EMAIL_); | 125 window.localStorage.removeItem(KEY_EMAIL_); |
| 123 remoting.setMode(remoting.AppMode.UNAUTHENTICATED); | 126 remoting.setMode(remoting.AppMode.UNAUTHENTICATED); |
| 124 }; | 127 }; |
| 125 | 128 |
| 126 /** | 129 /** |
| 130 * Callback function called when the browser window gets focus. | |
| 131 */ | |
| 132 function pluginGotFocus_() { | |
| 133 var documentCast = /** @type {remoting.Document} */ document; | |
|
Jamie
2012/03/14 00:43:47
This can be simpler if you just annotate execComma
| |
| 134 documentCast.execCommand("paste"); | |
| 135 } | |
| 136 | |
| 137 /** | |
| 138 * Callback function called when the browser window gets a paste operation. | |
| 139 * | |
| 140 * @param {Event} eventUncast | |
| 141 * @return {boolean} | |
| 142 */ | |
| 143 function pluginGotPaste_(eventUncast) { | |
| 144 var event = /** @type {remoting.Event} */ eventUncast; | |
| 145 if (event && event.clipboardData) { | |
| 146 remoting.clipboard.toHost(event.clipboardData); | |
| 147 } | |
| 148 return false; | |
| 149 } | |
| 150 | |
| 151 /** | |
| 127 * Callback function called when the browser window loses focus. In this case, | 152 * Callback function called when the browser window loses focus. In this case, |
| 128 * release all keys to prevent them becoming 'stuck down' on the host. | 153 * release all keys to prevent them becoming 'stuck down' on the host. |
| 129 */ | 154 */ |
| 130 function pluginLostFocus_() { | 155 function pluginLostFocus_() { |
| 131 if (remoting.clientSession && remoting.clientSession.plugin) { | 156 if (remoting.clientSession && remoting.clientSession.plugin) { |
| 132 remoting.clientSession.plugin.releaseAllKeys(); | 157 remoting.clientSession.plugin.releaseAllKeys(); |
| 133 } | 158 } |
| 134 } | 159 } |
| 135 | 160 |
| 136 /** | 161 /** |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 */ | 225 */ |
| 201 function getUrlParameters_() { | 226 function getUrlParameters_() { |
| 202 var result = {}; | 227 var result = {}; |
| 203 var parts = window.location.search.substring(1).split('&'); | 228 var parts = window.location.search.substring(1).split('&'); |
| 204 for (var i = 0; i < parts.length; i++) { | 229 for (var i = 0; i < parts.length; i++) { |
| 205 var pair = parts[i].split('='); | 230 var pair = parts[i].split('='); |
| 206 result[pair[0]] = decodeURIComponent(pair[1]); | 231 result[pair[0]] = decodeURIComponent(pair[1]); |
| 207 } | 232 } |
| 208 return result; | 233 return result; |
| 209 } | 234 } |
| OLD | NEW |