Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: remoting/webapp/crd/js/desktop_connected_view.js

Issue 981083002: [Chromoting] Move ownership of ClientPlugin into SessionConnector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove createPluginAndConnect Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * Class handling user-facing aspects of the client session. 7 * Class handling user-facing aspects of the client session.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 remoting.enableMouseLock = false; 25 remoting.enableMouseLock = false;
26 26
27 /** 27 /**
28 * @param {remoting.ClientSession} session 28 * @param {remoting.ClientSession} session
29 * @param {HTMLElement} container 29 * @param {HTMLElement} container
30 * @param {remoting.Host} host 30 * @param {remoting.Host} host
31 * @param {remoting.DesktopConnectedView.Mode} mode The mode of this connection. 31 * @param {remoting.DesktopConnectedView.Mode} mode The mode of this connection.
32 * @param {string} defaultRemapKeys The default set of remap keys, to use 32 * @param {string} defaultRemapKeys The default set of remap keys, to use
33 * when the client doesn't define any. 33 * when the client doesn't define any.
34 * @param {function(remoting.Error, remoting.ClientPlugin): void} onInitialized
35 * @constructor 34 * @constructor
36 * @extends {base.EventSourceImpl} 35 * @extends {base.EventSourceImpl}
37 */ 36 */
38 remoting.DesktopConnectedView = function(session, container, host, mode, 37 remoting.DesktopConnectedView = function(session, container, host, mode,
39 defaultRemapKeys, onInitialized) { 38 defaultRemapKeys) {
40 this.session_ = session; 39 this.session_ = session;
41 40
42 /** @type {HTMLElement} @private */ 41 /** @type {HTMLElement} @private */
43 this.container_ = container; 42 this.container_ = container;
44 43
45 /** @type {remoting.ClientPlugin} @private */ 44 /** @type {remoting.ClientPlugin} @private */
46 this.plugin_ = null; 45 this.plugin_ = null;
47 46
48 /** @private */ 47 /** @private */
49 this.host_ = host; 48 this.host_ = host;
50 49
51 /** @private */ 50 /** @private */
52 this.mode_ = mode; 51 this.mode_ = mode;
53 52
54 /** @type {string} @private */ 53 /** @type {string} @private */
55 this.defaultRemapKeys_ = defaultRemapKeys; 54 this.defaultRemapKeys_ = defaultRemapKeys;
56 55
57 /**
58 * Called when the UI is finished initializing.
59 * @type {function(remoting.Error, remoting.ClientPlugin):void}
60 */
61 this.onInitialized_ = onInitialized;
62
63 /** @private */ 56 /** @private */
64 this.callPluginLostFocus_ = this.pluginLostFocus_.bind(this); 57 this.callPluginLostFocus_ = this.pluginLostFocus_.bind(this);
65 /** @private */ 58 /** @private */
66 this.callPluginGotFocus_ = this.pluginGotFocus_.bind(this); 59 this.callPluginGotFocus_ = this.pluginGotFocus_.bind(this);
67 /** @type {Element} @private */ 60 /** @type {Element} @private */
68 this.debugRegionContainer_ = 61 this.debugRegionContainer_ =
69 this.container_.querySelector('.debug-region-container'); 62 this.container_.querySelector('.debug-region-container');
70 63
71 /** @type {Element} @private */ 64 /** @type {Element} @private */
72 this.mouseCursorOverlay_ = 65 this.mouseCursorOverlay_ =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 remoting.DesktopConnectedView.prototype.getPluginContainer_ = function() { 140 remoting.DesktopConnectedView.prototype.getPluginContainer_ = function() {
148 return this.container_.querySelector('.client-plugin-container'); 141 return this.container_.querySelector('.client-plugin-container');
149 }; 142 };
150 143
151 /** @return {remoting.DesktopViewport} */ 144 /** @return {remoting.DesktopViewport} */
152 remoting.DesktopConnectedView.prototype.getViewportForTesting = function() { 145 remoting.DesktopConnectedView.prototype.getViewportForTesting = function() {
153 return this.viewport_; 146 return this.viewport_;
154 }; 147 };
155 148
156 /** 149 /**
157 * Adds <embed> element to the UI container and readies the session object. 150 * @param {remoting.ClientPlugin} plugin
158 *
159 * @param {function(string, string):boolean} onExtensionMessage The handler for
160 * protocol extension messages. Returns true if a message is recognized;
161 * false otherwise.
162 * @param {Array<string>} requiredCapabilities A list of capabilities
163 * required by this application.
164 */ 151 */
165 remoting.DesktopConnectedView.prototype.createPluginAndConnect = 152 remoting.DesktopConnectedView.prototype.onPluginInitialized = function(plugin) {
166 function(onExtensionMessage, requiredCapabilities) { 153 this.plugin_ = plugin;
167 this.plugin_ = remoting.ClientPlugin.factory.createPlugin(
garykac 2015/03/06 00:45:04 Sessionconnector creates this now.
168 this.getPluginContainer_(),
169 onExtensionMessage, requiredCapabilities);
170 var that = this;
171 this.host_.options.load().then(function(){
172 that.plugin_.initialize(that.onPluginInitialized_.bind(that));
173 });
174 };
175
176 /**
177 * @param {boolean} initialized
178 */
179 remoting.DesktopConnectedView.prototype.onPluginInitialized_ = function(
180 initialized) {
181 if (!initialized) {
182 console.error('ERROR: remoting plugin not loaded');
183 this.onInitialized_(remoting.Error.MISSING_PLUGIN, this.plugin_);
184 return;
185 }
186
187 if (!this.plugin_.isSupportedVersion()) {
188 this.onInitialized_(remoting.Error.BAD_PLUGIN_VERSION, this.plugin_);
189 return;
190 }
191 154
192 // Show the Send Keys menu only if the plugin has the injectKeyEvent feature, 155 // Show the Send Keys menu only if the plugin has the injectKeyEvent feature,
193 // and the Ctrl-Alt-Del button only in Me2Me mode. 156 // and the Ctrl-Alt-Del button only in Me2Me mode.
194 if (!this.plugin_.hasFeature( 157 if (!this.plugin_.hasFeature(
195 remoting.ClientPlugin.Feature.INJECT_KEY_EVENT)) { 158 remoting.ClientPlugin.Feature.INJECT_KEY_EVENT)) {
196 var sendKeysElement = document.getElementById('send-keys-menu'); 159 var sendKeysElement = document.getElementById('send-keys-menu');
197 sendKeysElement.hidden = true; 160 sendKeysElement.hidden = true;
198 } else if (this.mode_ != remoting.DesktopConnectedView.Mode.ME2ME && 161 } else if (this.mode_ != remoting.DesktopConnectedView.Mode.ME2ME &&
199 this.mode_ != remoting.DesktopConnectedView.Mode.APP_REMOTING) { 162 this.mode_ != remoting.DesktopConnectedView.Mode.APP_REMOTING) {
200 var sendCadElement = document.getElementById('send-ctrl-alt-del'); 163 var sendCadElement = document.getElementById('send-ctrl-alt-del');
201 sendCadElement.hidden = true; 164 sendCadElement.hidden = true;
202 } 165 }
203 166
204 // Apply customized key remappings if the plugin supports remapKeys. 167 // Apply customized key remappings if the plugin supports remapKeys.
205 if (this.plugin_.hasFeature(remoting.ClientPlugin.Feature.REMAP_KEY)) { 168 if (this.plugin_.hasFeature(remoting.ClientPlugin.Feature.REMAP_KEY)) {
206 this.applyRemapKeys_(true); 169 this.applyRemapKeys_(true);
207 } 170 }
208 171
209 // TODO(wez): Only allow mouse lock if the app has the pointerLock permission. 172 // TODO(wez): Only allow mouse lock if the app has the pointerLock permission.
210 // Enable automatic mouse-lock. 173 // Enable automatic mouse-lock.
211 if (remoting.enableMouseLock && 174 if (remoting.enableMouseLock &&
212 this.plugin_.hasFeature(remoting.ClientPlugin.Feature.ALLOW_MOUSE_LOCK)) { 175 this.plugin_.hasFeature(remoting.ClientPlugin.Feature.ALLOW_MOUSE_LOCK)) {
213 this.plugin_.allowMouseLock(); 176 this.plugin_.allowMouseLock();
214 } 177 }
215 178
216 this.plugin_.setMouseCursorHandler(this.updateMouseCursorImage_.bind(this)); 179 this.plugin_.setMouseCursorHandler(this.updateMouseCursorImage_.bind(this));
217
218 this.onInitialized_(remoting.Error.NONE, this.plugin_);
219 }; 180 };
220 181
221 /** 182 /**
222 * This is a callback that gets called when the window is resized. 183 * This is a callback that gets called when the window is resized.
223 * 184 *
224 * @return {void} Nothing. 185 * @return {void} Nothing.
225 * @private. 186 * @private.
226 */ 187 */
227 remoting.DesktopConnectedView.prototype.onResize_ = function() { 188 remoting.DesktopConnectedView.prototype.onResize_ = function() {
228 if (this.viewport_) { 189 if (this.viewport_) {
(...skipping 29 matching lines...) Expand all
258 * disconnected by the Host. 219 * disconnected by the Host.
259 * 220 *
260 * @return {void} Nothing. 221 * @return {void} Nothing.
261 */ 222 */
262 remoting.DesktopConnectedView.prototype.removePlugin = function() { 223 remoting.DesktopConnectedView.prototype.removePlugin = function() {
263 if (this.plugin_) { 224 if (this.plugin_) {
264 this.plugin_.element().removeEventListener( 225 this.plugin_.element().removeEventListener(
265 'focus', this.callPluginGotFocus_, false); 226 'focus', this.callPluginGotFocus_, false);
266 this.plugin_.element().removeEventListener( 227 this.plugin_.element().removeEventListener(
267 'blur', this.callPluginLostFocus_, false); 228 'blur', this.callPluginLostFocus_, false);
268 this.plugin_.dispose();
garykac 2015/03/06 00:45:04 SessionConnector disposes of the plugin when appro
269 this.plugin_ = null; 229 this.plugin_ = null;
270 } 230 }
271 231
272 this.updateClientSessionUi_(null); 232 this.updateClientSessionUi_(null);
273 }; 233 };
274 234
275 /** 235 /**
276 * @param {remoting.ClientSession} clientSession The active session, or null if 236 * @param {remoting.ClientSession} clientSession The active session, or null if
277 * there is no connection. 237 * there is no connection.
278 */ 238 */
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 var rect = document.createElement('div'); 554 var rect = document.createElement('div');
595 rect.classList.add('debug-region-rect'); 555 rect.classList.add('debug-region-rect');
596 rect.style.left = rects[i][0] + 'px'; 556 rect.style.left = rects[i][0] + 'px';
597 rect.style.top = rects[i][1] +'px'; 557 rect.style.top = rects[i][1] +'px';
598 rect.style.width = rects[i][2] +'px'; 558 rect.style.width = rects[i][2] +'px';
599 rect.style.height = rects[i][3] + 'px'; 559 rect.style.height = rects[i][3] + 'px';
600 this.debugRegionContainer_.appendChild(rect); 560 this.debugRegionContainer_.appendChild(rect);
601 } 561 }
602 } 562 }
603 }; 563 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698