Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * Implements a basic UX control for a connected remoting session. | 7 * Implements a basic UX control for a connected remoting session. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /** @suppress {duplicate} */ | 10 /** @suppress {duplicate} */ |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 /** @private {Element} */ | 36 /** @private {Element} */ |
| 37 this.debugRegionContainer_ = | 37 this.debugRegionContainer_ = |
| 38 viewportElement.querySelector('.debug-region-container'); | 38 viewportElement.querySelector('.debug-region-container'); |
| 39 | 39 |
| 40 var pluginElement = plugin.element(); | 40 var pluginElement = plugin.element(); |
| 41 | 41 |
| 42 /** private */ | 42 /** private */ |
| 43 this.disposables_ = new base.Disposables( | 43 this.disposables_ = new base.Disposables( |
| 44 this.cursor_, | 44 this.cursor_, |
| 45 new base.DomEventHook(pluginElement, 'focus', | |
| 46 this.onPluginGotFocus_.bind(this), false), | |
|
kelvinp
2015/04/09 00:28:26
moved to clipboard.js
| |
| 47 new base.DomEventHook(pluginElement, 'blur', | 45 new base.DomEventHook(pluginElement, 'blur', |
| 48 this.onPluginLostFocus_.bind(this), false), | 46 this.onPluginLostFocus_.bind(this), false), |
| 49 new base.DomEventHook(document, 'visibilitychange', | 47 new base.DomEventHook(document, 'visibilitychange', |
| 50 this.onVisibilityChanged_.bind(this), false) | 48 this.onVisibilityChanged_.bind(this), false), |
| 49 new remoting.Clipboard(plugin) | |
| 51 ); | 50 ); |
| 52 | 51 |
| 53 // TODO(wez): Only allow mouse lock if the app has the pointerLock permission. | 52 // TODO(wez): Only allow mouse lock if the app has the pointerLock permission. |
| 54 // Enable automatic mouse-lock. | 53 // Enable automatic mouse-lock. |
| 55 if (this.plugin_.hasFeature(remoting.ClientPlugin.Feature.ALLOW_MOUSE_LOCK)) { | 54 if (this.plugin_.hasFeature(remoting.ClientPlugin.Feature.ALLOW_MOUSE_LOCK)) { |
| 56 this.plugin_.allowMouseLock(); | 55 this.plugin_.allowMouseLock(); |
| 57 } | 56 } |
| 58 | 57 |
| 59 pluginElement.focus(); | 58 pluginElement.focus(); |
| 60 }; | 59 }; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 84 * Callback that the plugin invokes to indicate when the connection is | 83 * Callback that the plugin invokes to indicate when the connection is |
| 85 * ready. | 84 * ready. |
| 86 * | 85 * |
| 87 * @param {boolean} ready True if the connection is ready. | 86 * @param {boolean} ready True if the connection is ready. |
| 88 */ | 87 */ |
| 89 remoting.ConnectedView.prototype.onConnectionReady = function(ready) { | 88 remoting.ConnectedView.prototype.onConnectionReady = function(ready) { |
| 90 this.viewportElement_.classList.toggle('session-client-inactive', !ready); | 89 this.viewportElement_.classList.toggle('session-client-inactive', !ready); |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 /** | 92 /** |
| 94 * Callback function called when the plugin element gets focus. | |
| 95 * @private | |
| 96 */ | |
| 97 remoting.ConnectedView.prototype.onPluginGotFocus_ = function() { | |
| 98 remoting.clipboard.initiateToHost(); | |
| 99 }; | |
| 100 | |
| 101 /** | |
| 102 * Callback function called when the plugin element loses focus. | 93 * Callback function called when the plugin element loses focus. |
| 103 * @private | 94 * @private |
| 104 */ | 95 */ |
| 105 remoting.ConnectedView.prototype.onPluginLostFocus_ = function() { | 96 remoting.ConnectedView.prototype.onPluginLostFocus_ = function() { |
| 106 // Release all keys to prevent them becoming 'stuck down' on the host. | 97 // Release all keys to prevent them becoming 'stuck down' on the host. |
| 107 this.plugin_.releaseAllKeys(); | 98 this.plugin_.releaseAllKeys(); |
| 108 | 99 |
| 109 // Focus should stay on the element, not (for example) the toolbar. | 100 // Focus should stay on the element, not (for example) the toolbar. |
| 110 // Due to crbug.com/246335, we can't restore the focus immediately, | 101 // Due to crbug.com/246335, we can't restore the focus immediately, |
| 111 // otherwise the plugin gets confused about whether or not it has focus. | 102 // otherwise the plugin gets confused about whether or not it has focus. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 /** | 189 /** |
| 199 * @param {Event} event | 190 * @param {Event} event |
| 200 * @private | 191 * @private |
| 201 */ | 192 */ |
| 202 remoting.ConnectedView.Cursor.prototype.onMouseMoved_ = function(event) { | 193 remoting.ConnectedView.Cursor.prototype.onMouseMoved_ = function(event) { |
| 203 this.cursorElement_.style.top = event.offsetY + 'px'; | 194 this.cursorElement_.style.top = event.offsetY + 'px'; |
| 204 this.cursorElement_.style.left = event.offsetX + 'px'; | 195 this.cursorElement_.style.left = event.offsetX + 'px'; |
| 205 }; | 196 }; |
| 206 | 197 |
| 207 })(); | 198 })(); |
| OLD | NEW |