X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fremoting%2Fwebapp%2Fclient_session.js;h=ac27d01e9927d8fdac0d8e7604732e9fece5d471;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=85610cdc03783ff847bae27347ba9bcefc6d1863;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/remoting/webapp/client_session.js b/src/remoting/webapp/client_session.js index 85610cd..ac27d01 100644 --- a/src/remoting/webapp/client_session.js +++ b/src/remoting/webapp/client_session.js @@ -23,6 +23,14 @@ var remoting = remoting || {}; /** + * True if Cast capability is supported. + * + * @type {boolean} + */ +remoting.enableCast = false; + +/** + * @param {remoting.SignalStrategy} signalStrategy Signal strategy. * @param {HTMLElement} container Container element for the client view. * @param {string} hostDisplayName A human-readable name for the host. * @param {string} accessCode The IT2Me access code. Blank for Me2Me. @@ -48,8 +56,8 @@ var remoting = remoting || {}; * @constructor * @extends {base.EventSource} */ -remoting.ClientSession = function(container, hostDisplayName, accessCode, - fetchPin, fetchThirdPartyToken, +remoting.ClientSession = function(signalStrategy, container, hostDisplayName, + accessCode, fetchPin, fetchThirdPartyToken, authenticationMethods, hostId, hostJid, hostPublicKey, mode, clientPairingId, clientPairedSecret) { @@ -100,6 +108,14 @@ remoting.ClientSession = function(container, hostDisplayName, accessCode, this.hasReceivedFrame_ = false; this.logToServer = new remoting.LogToServer(); + /** @private */ + this.signalStrategy_ = signalStrategy; + base.debug.assert(this.signalStrategy_.getState() == + remoting.SignalStrategy.State.CONNECTED); + this.signalStrategy_.setIncomingStanzaCallback( + this.onIncomingMessage_.bind(this)); + remoting.formatIq.setJids(this.signalStrategy_.getJid(), hostJid); + /** @type {number?} @private */ this.notifyClientResolutionTimer_ = null; /** @type {number?} @private */ @@ -126,20 +142,8 @@ remoting.ClientSession = function(container, hostDisplayName, accessCode, /** @private */ this.callPluginGotFocus_ = this.pluginGotFocus_.bind(this); /** @private */ - this.callToggleFullScreen_ = remoting.fullscreen.toggle.bind( - remoting.fullscreen); - /** @private */ this.callOnFullScreenChanged_ = this.onFullScreenChanged_.bind(this) - /** @private */ - this.screenOptionsMenu_ = new remoting.MenuButton( - document.getElementById('screen-options-menu'), - this.onShowOptionsMenu_.bind(this)); - /** @private */ - this.sendKeysMenu_ = new remoting.MenuButton( - document.getElementById('send-keys-menu') - ); - /** @type {HTMLMediaElement} @private */ this.video_ = null; @@ -155,26 +159,15 @@ remoting.ClientSession = function(container, hostDisplayName, accessCode, img.style.left = event.x + 'px'; }; - /** @type {HTMLElement} @private */ - this.resizeToClientButton_ = - document.getElementById('screen-resize-to-client'); - /** @type {HTMLElement} @private */ - this.shrinkToFitButton_ = document.getElementById('screen-shrink-to-fit'); - /** @type {HTMLElement} @private */ - this.fullScreenButton_ = document.getElementById('toggle-full-screen'); - /** @type {remoting.GnubbyAuthHandler} @private */ this.gnubbyAuthHandler_ = null; - if (this.mode_ == remoting.ClientSession.Mode.IT2ME) { - // Resize-to-client is not supported for IT2Me hosts. - this.resizeToClientButton_.hidden = true; - } else { - this.resizeToClientButton_.hidden = false; - } + /** @type {remoting.CastExtensionHandler} @private */ + this.castExtensionHandler_ = null; + + /** @type {remoting.VideoFrameRecorder} @private */ + this.videoFrameRecorder_ = null; - this.fullScreenButton_.addEventListener( - 'click', this.callToggleFullScreen_, false); this.defineEvents(Object.keys(remoting.ClientSession.Events)); }; @@ -211,15 +204,15 @@ remoting.ClientSession.prototype.updateScrollbarVisibility = function() { // Determine whether or not horizontal or vertical scrollbars are // required, taking into account their width. var clientArea = this.getClientArea_(); - needsVerticalScroll = clientArea.height < this.plugin_.desktopHeight; - needsHorizontalScroll = clientArea.width < this.plugin_.desktopWidth; + needsVerticalScroll = clientArea.height < this.plugin_.getDesktopHeight(); + needsHorizontalScroll = clientArea.width < this.plugin_.getDesktopWidth(); var kScrollBarWidth = 16; if (needsHorizontalScroll && !needsVerticalScroll) { needsVerticalScroll = - clientArea.height - kScrollBarWidth < this.plugin_.desktopHeight; + clientArea.height - kScrollBarWidth < this.plugin_.getDesktopHeight(); } else if (!needsHorizontalScroll && needsVerticalScroll) { needsHorizontalScroll = - clientArea.width - kScrollBarWidth < this.plugin_.desktopWidth; + clientArea.width - kScrollBarWidth < this.plugin_.getDesktopWidth(); } } @@ -366,7 +359,8 @@ remoting.ClientSession.Capability = { // this.plugin_.notifyClientResolution(). SEND_INITIAL_RESOLUTION: 'sendInitialResolution', RATE_LIMIT_RESIZE_REQUESTS: 'rateLimitResizeRequests', - VIDEO_RECORDER: 'videoRecorder' + VIDEO_RECORDER: 'videoRecorder', + CAST: 'casting' }; /** @@ -423,7 +417,7 @@ remoting.ClientSession.prototype.pluginLostFocus_ = function() { */ remoting.ClientSession.prototype.createPluginAndConnect = function(onExtensionMessage) { - this.plugin_ = new remoting.ClientPlugin( + this.plugin_ = remoting.ClientPlugin.factory.createPlugin( this.container_.querySelector('.client-plugin-container'), onExtensionMessage); remoting.HostSettings.load(this.hostId_, @@ -475,7 +469,8 @@ remoting.ClientSession.prototype.setFocusHandlers_ = function() { * @param {remoting.Error} error */ remoting.ClientSession.prototype.resetWithError_ = function(error) { - this.plugin_.cleanup(); + this.signalStrategy_.setIncomingStanzaCallback(null); + this.plugin_.dispose(); this.plugin_ = null; this.error_ = error; this.setState_(remoting.ClientSession.State.FAILED); @@ -512,7 +507,6 @@ remoting.ClientSession.prototype.onPluginInitialized_ = function(initialized) { this.applyRemapKeys_(true); } - // Enable MediaSource-based rendering on Chrome 37 and above. var chromeVersionMajor = parseInt((remoting.getChromeVersion() || '0').split('.')[0], 10); @@ -533,21 +527,24 @@ remoting.ClientSession.prototype.onPluginInitialized_ = function(initialized) { this.container_.classList.remove('mediasource-rendering'); } - /** @param {string} msg The IQ stanza to send. */ - this.plugin_.onOutgoingIqHandler = this.sendIq_.bind(this); - /** @param {string} msg The message to log. */ - this.plugin_.onDebugMessageHandler = function(msg) { - console.log('plugin: ' + msg.trimRight()); - }; + this.plugin_.setOnOutgoingIqHandler(this.sendIq_.bind(this)); + this.plugin_.setOnDebugMessageHandler( + /** @param {string} msg */ + function(msg) { + console.log('plugin: ' + msg.trimRight()); + }); - this.plugin_.onConnectionStatusUpdateHandler = - this.onConnectionStatusUpdate_.bind(this); - this.plugin_.onConnectionReadyHandler = this.onConnectionReady_.bind(this); - this.plugin_.onDesktopSizeUpdateHandler = - this.onDesktopSizeChanged_.bind(this); - this.plugin_.onSetCapabilitiesHandler = this.onSetCapabilities_.bind(this); - this.plugin_.onGnubbyAuthHandler = this.processGnubbyAuthMessage_.bind(this); - this.plugin_.updateMouseCursorImage = this.updateMouseCursorImage_.bind(this); + this.plugin_.setConnectionStatusUpdateHandler( + this.onConnectionStatusUpdate_.bind(this)); + this.plugin_.setConnectionReadyHandler(this.onConnectionReady_.bind(this)); + this.plugin_.setDesktopSizeUpdateHandler( + this.onDesktopSizeChanged_.bind(this)); + this.plugin_.setCapabilitiesHandler(this.onSetCapabilities_.bind(this)); + this.plugin_.setGnubbyAuthHandler( + this.processGnubbyAuthMessage_.bind(this)); + this.plugin_.setMouseCursorHandler(this.updateMouseCursorImage_.bind(this)); + this.plugin_.setCastExtensionHandler( + this.processCastExtensionMessage_.bind(this)); this.initiateConnection_(); }; @@ -564,17 +561,12 @@ remoting.ClientSession.prototype.removePlugin = function() { 'focus', this.callPluginGotFocus_, false); this.plugin_.element().removeEventListener( 'blur', this.callPluginLostFocus_, false); - this.plugin_.cleanup(); + this.plugin_.dispose(); this.plugin_ = null; } - // Delete event handlers that aren't relevent when not connected. - this.fullScreenButton_.removeEventListener( - 'click', this.callToggleFullScreen_, false); - // Leave full-screen mode, and stop listening for related events. var listener = this.callOnFullScreenChanged_; - remoting.fullscreen.syncWithMaximize(false); remoting.fullscreen.activate( false, function() { @@ -585,6 +577,8 @@ remoting.ClientSession.prototype.removePlugin = function() { } else { remoting.toolbar.setClientSession(null); } + remoting.optionsMenu.setClientSession(null); + document.body.classList.remove('connected'); // Remove mediasource-rendering class from the container - this will also // hide the