diff options
author | kelvinp@chromium.org <kelvinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-08 23:24:39 +0000 |
---|---|---|
committer | kelvinp@chromium.org <kelvinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-08 23:24:39 +0000 |
commit | faf48606b83e5f91d362a830be8c299bb03162e6 (patch) | |
tree | 7a2b480a1512938fdc601d09b93cde1fdc02f332 /remoting | |
parent | 5a940f84ba3f5fe55174eb0f30d3564afed483c7 (diff) | |
download | chromium_src-faf48606b83e5f91d362a830be8c299bb03162e6.zip chromium_src-faf48606b83e5f91d362a830be8c299bb03162e6.tar.gz chromium_src-faf48606b83e5f91d362a830be8c299bb03162e6.tar.bz2 |
Hangout remote desktop part I - It2Me mode
This CL enables the user to launch the chrome remote desktop app directly into an immersive it2me helper session.
In the immersive session, the app will
1. hide the home screen
2. create an hrd_helper_session object to communicate with the it2me_background service.
Review URL: https://codereview.chromium.org/439923002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288466 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/remoting_webapp_files.gypi | 1 | ||||
-rw-r--r-- | remoting/webapp/client_screen.js | 13 | ||||
-rw-r--r-- | remoting/webapp/hangout_session.js | 72 | ||||
-rw-r--r-- | remoting/webapp/html/template_main.html | 2 | ||||
-rw-r--r-- | remoting/webapp/js_proto/chrome_proto.js | 6 | ||||
-rw-r--r-- | remoting/webapp/main.css | 6 | ||||
-rw-r--r-- | remoting/webapp/remoting.js | 10 |
7 files changed, 107 insertions, 3 deletions
diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi index 070f899..93b74bb 100644 --- a/remoting/remoting_webapp_files.gypi +++ b/remoting/remoting_webapp_files.gypi @@ -46,6 +46,7 @@ 'webapp/client_screen.js', 'webapp/client_session.js', 'webapp/clipboard.js', + 'webapp/hangout_session.js', 'webapp/media_source_renderer.js', 'webapp/session_connector.js', 'webapp/smart_reconnector.js', diff --git a/remoting/webapp/client_screen.js b/remoting/webapp/client_screen.js index cb54aa3..f1f0bac 100644 --- a/remoting/webapp/client_screen.js +++ b/remoting/webapp/client_screen.js @@ -55,7 +55,7 @@ remoting.onVisibilityChanged = function() { remoting.clientSession.pauseVideo( ('hidden' in document) ? document.hidden : document.webkitHidden); } -} +}; /** * Disconnect the remoting client. @@ -89,6 +89,9 @@ function onClientStateChange_(state) { if (remoting.clientSession.getMode() == remoting.ClientSession.Mode.IT2ME) { remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); + remoting.hangoutSessionEvents.raiseEvent( + remoting.hangoutSessionEvents.sessionStateChanged, + remoting.ClientSession.State.CLOSED); } else { remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); } @@ -133,6 +136,10 @@ function showConnectError_(errorTag) { : remoting.connector.getConnectionMode(); if (mode == remoting.ClientSession.Mode.IT2ME) { remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); + remoting.hangoutSessionEvents.raiseEvent( + remoting.hangoutSessionEvents.sessionStateChanged, + remoting.ClientSession.State.FAILED + ); } else { remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); } @@ -317,6 +324,10 @@ remoting.onConnected = function(clientSession) { remoting.toolbar.preview(); remoting.clipboard.startSession(); updateStatistics_(); + remoting.hangoutSessionEvents.raiseEvent( + remoting.hangoutSessionEvents.sessionStateChanged, + remoting.ClientSession.State.CONNECTED + ); if (remoting.connector.pairingRequested) { /** * @param {string} clientId diff --git a/remoting/webapp/hangout_session.js b/remoting/webapp/hangout_session.js new file mode 100644 index 0000000..7f11ee3 --- /dev/null +++ b/remoting/webapp/hangout_session.js @@ -0,0 +1,72 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** + * @fileoverview + * Class to communicate with the background scripts via chrome runtime + * messages to + * 1. Forward session state notifications + * 2. Closes the window when the session terminates + */ + +'use strict'; + +/** @suppress {duplicate} */ +var remoting = remoting || {}; + +/** + * @constructor + */ +remoting.HangoutSession = function() { + /** + * @private + * @type {chrome.extension.Port} + */ + this.port_ = null; +}; + +remoting.HangoutSession.prototype.init = function() { + this.port_ = chrome.runtime.connect({name: 'it2me.helper.webapp'}); + + remoting.hangoutSessionEvents.addEventListener( + remoting.hangoutSessionEvents.sessionStateChanged, + this.onSessionStateChanged_.bind(this)); +}; + +/** + * @param {remoting.ClientSession.State} state + */ +remoting.HangoutSession.prototype.onSessionStateChanged_ = function(state) { + var State = remoting.ClientSession.State; + try { + this.port_.postMessage({method: 'sessionStateChanged', state: state}); + } catch (e) { + // postMessage will throw an exception if the port is disconnected. + // We can safely ignore this exception. + } finally { + if (state === State.FAILED || state === State.CLOSED) { + // close the current window + if (remoting.isAppsV2) { + chrome.app.window.current().close(); + } else { + window.close(); + } + } + } +}; + + +/** + * remoting.clientSession does not exist until the session is connected. + * hangoutSessionEvents serves as a global event source to plumb session + * state changes until we cleanup clientSession and sessionConnector. + * @type {base.EventSource} + */ +remoting.hangoutSessionEvents = new base.EventSource(); + +/** @type {string} */ +remoting.hangoutSessionEvents.sessionStateChanged = "sessionStateChanged"; + +remoting.hangoutSessionEvents.defineEvents( + [remoting.hangoutSessionEvents.sessionStateChanged]);
\ No newline at end of file diff --git a/remoting/webapp/html/template_main.html b/remoting/webapp/html/template_main.html index e49551d..f0a29de 100644 --- a/remoting/webapp/html/template_main.html +++ b/remoting/webapp/html/template_main.html @@ -38,7 +38,7 @@ found in the LICENSE file. <iframe id="wcs-sandbox" src="wcs_sandbox.html" hidden></iframe> <div id="scroller"> - <div class="inset" data-ui-mode="home" hidden> + <div class="inset home-screen" data-ui-mode="home" hidden> <meta-include src="webapp/html/ui_header.html"/> <meta-include src="webapp/html/butterbar.html"/> diff --git a/remoting/webapp/js_proto/chrome_proto.js b/remoting/webapp/js_proto/chrome_proto.js index 3c1a7bb..f7b9a6f 100644 --- a/remoting/webapp/js_proto/chrome_proto.js +++ b/remoting/webapp/js_proto/chrome_proto.js @@ -52,6 +52,12 @@ chrome.runtime = { chrome.runtime.connectNative = function(name) {}; /** + * @param {{name:string}} connectInfo + * @return {chrome.extension.Port} + */ +chrome.runtime.connect = function(connectInfo) {}; + +/** * @param {string} extensionId * @param {*} message * @param {Object=} opt_options diff --git a/remoting/webapp/main.css b/remoting/webapp/main.css index 30ff3ae..822d6e2 100644 --- a/remoting/webapp/main.css +++ b/remoting/webapp/main.css @@ -782,4 +782,8 @@ html.apps-v2.scrollable { .mouse-cursor-overlay { position: absolute; pointer-events: none; -}; +} + +body.hangout-remote-desktop .home-screen { + display: none; +} diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js index 188dc06..c02a48b 100644 --- a/remoting/webapp/remoting.js +++ b/remoting/webapp/remoting.js @@ -141,6 +141,16 @@ remoting.init = function() { var hostId = urlParams['hostId']; remoting.connectMe2Me(hostId); return; + } else if (urlParams['mode'] == 'hangout') { + var accessCode = urlParams['accessCode']; + remoting.ensureSessionConnector_(); + remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); + remoting.connector.connectIT2Me(accessCode); + + document.body.classList.add('hangout-remote-desktop'); + var hangoutSession = new remoting.HangoutSession(); + hangoutSession.init(); + return; } } // No valid URL parameters, start up normally. |