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 if (isHostModeSupported_()) { | 59 if (isHostModeSupported_()) { |
57 var noShare = document.getElementById('chrome-os-no-share'); | 60 var noShare = document.getElementById('chrome-os-no-share'); |
58 noShare.parentNode.removeChild(noShare); | 61 noShare.parentNode.removeChild(noShare); |
59 } else { | 62 } else { |
60 var button = document.getElementById('share-button'); | 63 var button = document.getElementById('share-button'); |
61 button.disabled = true; | 64 button.disabled = true; |
62 } | 65 } |
63 | 66 |
64 // Parse URL parameters. | 67 // Parse URL parameters. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 /** | 127 /** |
125 * Sign the user out of Chromoting by clearing the OAuth refresh token. | 128 * Sign the user out of Chromoting by clearing the OAuth refresh token. |
126 */ | 129 */ |
127 remoting.clearOAuth2 = function() { | 130 remoting.clearOAuth2 = function() { |
128 remoting.oauth2.clear(); | 131 remoting.oauth2.clear(); |
129 window.localStorage.removeItem(KEY_EMAIL_); | 132 window.localStorage.removeItem(KEY_EMAIL_); |
130 remoting.setMode(remoting.AppMode.UNAUTHENTICATED); | 133 remoting.setMode(remoting.AppMode.UNAUTHENTICATED); |
131 }; | 134 }; |
132 | 135 |
133 /** | 136 /** |
| 137 * Callback function called when the browser window gets focus. |
| 138 */ |
| 139 function pluginGotFocus_() { |
| 140 /** @type {function(string): void} */ |
| 141 document.execCommand; |
| 142 document.execCommand("paste"); |
| 143 } |
| 144 |
| 145 /** |
| 146 * Callback function called when the browser window gets a paste operation. |
| 147 * |
| 148 * @param {Event} eventUncast |
| 149 * @return {boolean} |
| 150 */ |
| 151 function pluginGotPaste_(eventUncast) { |
| 152 var event = /** @type {remoting.ClipboardEvent} */ eventUncast; |
| 153 if (event && event.clipboardData) { |
| 154 remoting.clipboard.toHost(event.clipboardData); |
| 155 } |
| 156 return false; |
| 157 } |
| 158 |
| 159 /** |
134 * Callback function called when the browser window loses focus. In this case, | 160 * Callback function called when the browser window loses focus. In this case, |
135 * release all keys to prevent them becoming 'stuck down' on the host. | 161 * release all keys to prevent them becoming 'stuck down' on the host. |
136 */ | 162 */ |
137 function pluginLostFocus_() { | 163 function pluginLostFocus_() { |
138 if (remoting.clientSession && remoting.clientSession.plugin) { | 164 if (remoting.clientSession && remoting.clientSession.plugin) { |
139 remoting.clientSession.plugin.releaseAllKeys(); | 165 remoting.clientSession.plugin.releaseAllKeys(); |
140 } | 166 } |
141 } | 167 } |
142 | 168 |
143 /** | 169 /** |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 */ | 233 */ |
208 function getUrlParameters_() { | 234 function getUrlParameters_() { |
209 var result = {}; | 235 var result = {}; |
210 var parts = window.location.search.substring(1).split('&'); | 236 var parts = window.location.search.substring(1).split('&'); |
211 for (var i = 0; i < parts.length; i++) { | 237 for (var i = 0; i < parts.length; i++) { |
212 var pair = parts[i].split('='); | 238 var pair = parts[i].split('='); |
213 result[pair[0]] = decodeURIComponent(pair[1]); | 239 result[pair[0]] = decodeURIComponent(pair[1]); |
214 } | 240 } |
215 return result; | 241 return result; |
216 } | 242 } |
OLD | NEW |