Skip to content

Commit

Permalink
Hangout remote desktop part I - It2Me mode
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kelvinp@chromium.org committed Aug 8, 2014
1 parent 93630da commit 06ce0d6
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 3 deletions.
1 change: 1 addition & 0 deletions remoting/remoting_webapp_files.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
13 changes: 12 additions & 1 deletion remoting/webapp/client_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ remoting.onVisibilityChanged = function() {
remoting.clientSession.pauseVideo(
('hidden' in document) ? document.hidden : document.webkitHidden);
}
}
};

/**
* Disconnect the remoting client.
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
72 changes: 72 additions & 0 deletions remoting/webapp/hangout_session.js
Original file line number Diff line number Diff line change
@@ -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]);
2 changes: 1 addition & 1 deletion remoting/webapp/html/template_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<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"/>
Expand Down
6 changes: 6 additions & 0 deletions remoting/webapp/js_proto/chrome_proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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
Expand Down
6 changes: 5 additions & 1 deletion remoting/webapp/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -782,4 +782,8 @@ html.apps-v2.scrollable {
.mouse-cursor-overlay {
position: absolute;
pointer-events: none;
};
}

body.hangout-remote-desktop .home-screen {
display: none;
}
10 changes: 10 additions & 0 deletions remoting/webapp/remoting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 06ce0d6

Please sign in to comment.