Commit 06ce0d64 authored by kelvinp@chromium.org's avatar kelvinp@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#288466}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288466 0039d316-1c4b-4281-b951-d872f2087c98
parent 93630da5
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
'webapp/client_screen.js', 'webapp/client_screen.js',
'webapp/client_session.js', 'webapp/client_session.js',
'webapp/clipboard.js', 'webapp/clipboard.js',
'webapp/hangout_session.js',
'webapp/media_source_renderer.js', 'webapp/media_source_renderer.js',
'webapp/session_connector.js', 'webapp/session_connector.js',
'webapp/smart_reconnector.js', 'webapp/smart_reconnector.js',
......
...@@ -55,7 +55,7 @@ remoting.onVisibilityChanged = function() { ...@@ -55,7 +55,7 @@ remoting.onVisibilityChanged = function() {
remoting.clientSession.pauseVideo( remoting.clientSession.pauseVideo(
('hidden' in document) ? document.hidden : document.webkitHidden); ('hidden' in document) ? document.hidden : document.webkitHidden);
} }
} };
/** /**
* Disconnect the remoting client. * Disconnect the remoting client.
...@@ -89,6 +89,9 @@ function onClientStateChange_(state) { ...@@ -89,6 +89,9 @@ function onClientStateChange_(state) {
if (remoting.clientSession.getMode() == if (remoting.clientSession.getMode() ==
remoting.ClientSession.Mode.IT2ME) { remoting.ClientSession.Mode.IT2ME) {
remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME);
remoting.hangoutSessionEvents.raiseEvent(
remoting.hangoutSessionEvents.sessionStateChanged,
remoting.ClientSession.State.CLOSED);
} else { } else {
remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME);
} }
...@@ -133,6 +136,10 @@ function showConnectError_(errorTag) { ...@@ -133,6 +136,10 @@ function showConnectError_(errorTag) {
: remoting.connector.getConnectionMode(); : remoting.connector.getConnectionMode();
if (mode == remoting.ClientSession.Mode.IT2ME) { if (mode == remoting.ClientSession.Mode.IT2ME) {
remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME);
remoting.hangoutSessionEvents.raiseEvent(
remoting.hangoutSessionEvents.sessionStateChanged,
remoting.ClientSession.State.FAILED
);
} else { } else {
remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME);
} }
...@@ -317,6 +324,10 @@ remoting.onConnected = function(clientSession) { ...@@ -317,6 +324,10 @@ remoting.onConnected = function(clientSession) {
remoting.toolbar.preview(); remoting.toolbar.preview();
remoting.clipboard.startSession(); remoting.clipboard.startSession();
updateStatistics_(); updateStatistics_();
remoting.hangoutSessionEvents.raiseEvent(
remoting.hangoutSessionEvents.sessionStateChanged,
remoting.ClientSession.State.CONNECTED
);
if (remoting.connector.pairingRequested) { if (remoting.connector.pairingRequested) {
/** /**
* @param {string} clientId * @param {string} clientId
......
// 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
...@@ -38,7 +38,7 @@ found in the LICENSE file. ...@@ -38,7 +38,7 @@ found in the LICENSE file.
<iframe id="wcs-sandbox" src="wcs_sandbox.html" hidden></iframe> <iframe id="wcs-sandbox" src="wcs_sandbox.html" hidden></iframe>
<div id="scroller"> <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/ui_header.html"/>
<meta-include src="webapp/html/butterbar.html"/> <meta-include src="webapp/html/butterbar.html"/>
......
...@@ -51,6 +51,12 @@ chrome.runtime = { ...@@ -51,6 +51,12 @@ chrome.runtime = {
*/ */
chrome.runtime.connectNative = function(name) {}; chrome.runtime.connectNative = function(name) {};
/**
* @param {{name:string}} connectInfo
* @return {chrome.extension.Port}
*/
chrome.runtime.connect = function(connectInfo) {};
/** /**
* @param {string} extensionId * @param {string} extensionId
* @param {*} message * @param {*} message
......
...@@ -782,4 +782,8 @@ html.apps-v2.scrollable { ...@@ -782,4 +782,8 @@ html.apps-v2.scrollable {
.mouse-cursor-overlay { .mouse-cursor-overlay {
position: absolute; position: absolute;
pointer-events: none; pointer-events: none;
}; }
body.hangout-remote-desktop .home-screen {
display: none;
}
...@@ -141,6 +141,16 @@ remoting.init = function() { ...@@ -141,6 +141,16 @@ remoting.init = function() {
var hostId = urlParams['hostId']; var hostId = urlParams['hostId'];
remoting.connectMe2Me(hostId); remoting.connectMe2Me(hostId);
return; 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. // No valid URL parameters, start up normally.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment