Skip to content

Commit

Permalink
[Chromoting] Remote Assistance in Public Session.
Browse files Browse the repository at this point in the history
This CL provides remote assistance in Public Session.
Summary of changes:
1. Move the remoting.testEvents initialization to ui_mode.js
   as it is only referenced there.
2. Create a separate page public_session.html that contains the
   main ui for public session.
3. Use the service account email address to infer whether we
   are currently in a public session.
4. Decouple remoting.HostController from host_screen.js
   Previously, remoting.HostController is used to retrieve the
   host version, which is problematic as that refers to the me2me
   host version as opposed to the it2me host version.

BUG=508608

Review URL: https://codereview.chromium.org/1370283004

Cr-Commit-Position: refs/heads/master@{#351861}
  • Loading branch information
kelvinp authored and Commit bot committed Oct 1, 2015
1 parent 86d0a29 commit 08d2852
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 46 deletions.
19 changes: 19 additions & 0 deletions remoting/remoting_client.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@
'--js', '<@(remoting_webapp_message_window_html_all_js_files)',
],
},
{
'action_name': 'Build Remoting Webapp public_session.html',
'inputs': [
'webapp/build-html.py',
'<(remoting_webapp_template_public_session)',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/remoting/public_session.html',
],
'action': [
'python', 'webapp/build-html.py',
'<(SHARED_INTERMEDIATE_DIR)/remoting/public_session.html',
'<(remoting_webapp_template_public_session)',
'--template-dir', '<(DEPTH)/remoting',
'--templates', '<@(remoting_webapp_public_session_template_files)',
'--js',
'<@(remoting_webapp_public_session_html_all_js_files)',
],
},
], # end of actions
}, # end of target 'remoting_webapp_html'

Expand Down
1 change: 1 addition & 0 deletions remoting/remoting_webapp.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'<(SHARED_INTERMEDIATE_DIR)/remoting/credits.html',
'<(SHARED_INTERMEDIATE_DIR)/remoting/message_window.html',
'<(SHARED_INTERMEDIATE_DIR)/remoting/wcs_sandbox.html',
'<(SHARED_INTERMEDIATE_DIR)/remoting/public_session.html',
],
'dr_webapp_locales_listfile': '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)_locales.txt',
},
Expand Down
34 changes: 34 additions & 0 deletions remoting/remoting_webapp_files.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@
'webapp/crd/js/native_message_host_log_message_handler.js',
'webapp/crd/js/paired_client_manager.js',
],
# Files for controlling the local it2me host.
# Included by public_session.html.
'remoting_webapp_js_it2me_host_control_files': [
'webapp/crd/js/buffered_signal_strategy.js',
'webapp/crd/js/host_screen.js',
'webapp/crd/js/host_session.js',
'webapp/crd/js/host_install_dialog.js',
'webapp/crd/js/host_installer.js',
'webapp/crd/js/it2me_host_facade.js',
'webapp/crd/js/native_message_host_log_message_handler.js',
],
# Files for displaying (in the client) info about available hosts.
'remoting_webapp_js_host_display_files': [
'webapp/crd/js/host_list.js',
Expand Down Expand Up @@ -353,6 +364,27 @@
'<@(remoting_webapp_js_host_display_files)',
],

'remoting_webapp_template_public_session':
'<(DEPTH)/remoting/webapp/crd/html/template_public_session.html',

# The shared JavaScript files required by public_session.html.
'remoting_webapp_public_session_html_all_js_files': [
'<@(remoting_webapp_shared_js_core_files)',
'<@(remoting_webapp_shared_js_auth_google_files)',
'<@(remoting_webapp_shared_js_client_files)',
'<@(remoting_webapp_shared_js_host_files)',
'<@(remoting_webapp_shared_js_logging_files)',
'<@(remoting_webapp_shared_js_signaling_files)',
'<@(remoting_webapp_shared_js_ui_files)',
'<@(remoting_webapp_js_it2me_host_control_files)',
'webapp/crd/js/public_session_main.js',
],

# These template files are used to construct public_session.html.
'remoting_webapp_public_session_template_files': [
'webapp/crd/html/dialog_host.html',
],

# The JS files required by unittest.html.
'remoting_webapp_unittest_html_all_js_files': [
'<@(remoting_webapp_shared_main_html_js_files)',
Expand Down Expand Up @@ -498,6 +530,7 @@
'<@(remoting_webapp_shared_js_files)',
'<@(remoting_webapp_crd_main_html_all_js_files)',
'<@(remoting_webapp_credits_html_all_js_files)',
'<@(remoting_webapp_public_session_html_all_js_files)',
],

'remoting_webapp_info_files': [
Expand Down Expand Up @@ -538,6 +571,7 @@
'webapp/crd/html/crd_main.css',
'webapp/crd/html/toolbar.css',
'webapp/crd/html/menu_button.css',
'webapp/crd/html/public_session.css',
'webapp/crd/html/window_frame.css',
'webapp/crd/resources/scale-to-fit.webp',
],
Expand Down
7 changes: 0 additions & 7 deletions remoting/webapp/base/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ remoting.Application.prototype.initGlobalObjects_ = function() {
remoting.wcsSandbox = new remoting.WcsSandboxContainer(
sandbox.contentWindow, this.windowMessageDispatcher_);
remoting.initModalDialogs();

remoting.testEvents = new base.EventSourceImpl();
/** @enum {string} */
remoting.testEvents.Names = {
uiModeChanged: 'uiModeChanged'
};
remoting.testEvents.defineEvents(base.values(remoting.testEvents.Names));
};

/**
Expand Down
9 changes: 9 additions & 0 deletions remoting/webapp/base/js/ui_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,12 @@ remoting.showSetupProcessingMessage = function(tag) {
l10n.localizeElementFromTag(messageDiv, tag);
remoting.setMode(remoting.AppMode.HOST_SETUP_PROCESSING);
}

remoting.testEvents = new base.EventSourceImpl();

/** @enum {string} */
remoting.testEvents.Names = {
uiModeChanged: 'uiModeChanged'
};

remoting.testEvents.defineEvents(base.values(remoting.testEvents.Names));
17 changes: 14 additions & 3 deletions remoting/webapp/build_template.gni
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ template("desktop_remoting_webapp") {
html_output = main_html_output
}

public_session_html = target_name + "_public_session_html"
public_session_html_output =
"$target_gen_dir/html/$target_name/public_session.html"

build_webapp_html(public_session_html) {
html_template_file = remoting_webapp_template_public_session
html_template_include_files = remoting_webapp_public_session_template_files
js_files = remoting_webapp_public_session_html_all_js_files
html_output = public_session_html_output
}

action(target_name) {
script = "//remoting/webapp/build-webapp.py"

Expand All @@ -181,6 +192,7 @@ template("desktop_remoting_webapp") {
message_window_html_output,
wcs_sandbox_html_output,
main_html_output,
public_session_html_output,
"$target_gen_dir/credits.html",
]

Expand Down Expand Up @@ -209,15 +221,14 @@ template("desktop_remoting_webapp") {
":$background_html",
":$message_window_html",
":$wcs_sandbox_html",
":$public_session_html",
":$main_html",
"//remoting/resources",
"//remoting/webapp:credits",
]

if (enable_pnacl) {
deps += [
"//remoting/client/plugin:remoting_client_plugin_newlib(//build/toolchain/nacl:newlib_pnacl)",
]
deps += [ "//remoting/client/plugin:remoting_client_plugin_newlib(//build/toolchain/nacl:newlib_pnacl)" ]
}

# Create a file that contains a list of all the resource files needed
Expand Down
14 changes: 14 additions & 0 deletions remoting/webapp/crd/html/public_session.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Copyright 2015 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.
*/

.public-session section {
width: 510px;
}

.public-session .kd-modaldialog {
border: none;
outline: none;
box-shadow: none;
}
28 changes: 28 additions & 0 deletions remoting/webapp/crd/html/template_public_session.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<!--
Copyright (c) 2012 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.
-->

<html>
<head>
<meta charset="utf-8">
<link rel="icon" type="image/png" href="chromoting16.webp">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="open_sans.css">
<link rel="stylesheet" href="public_session.css">

<meta-include type="javascript"/>
<title i18n-content="PRODUCT_NAME"></title>
</head>

<body class="public-session">
<section id="loading-mode" data-ui-mode="">
<em>Loading&hellip;</em>
</section>
<div data-ui-mode="home.host" hidden>
<meta-include src="webapp/crd/html/dialog_host.html"/>
</div>
</body>
</html>
22 changes: 18 additions & 4 deletions remoting/webapp/crd/js/activation_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ remoting.ActivationHandler.Ipc = {
*/
remoting.ActivationHandler.prototype.onContextMenu_ = function(info) {
if (info.menuItemId == NEW_WINDOW_MENU_ID_) {
this.createWindow_();
this.launchDefaultSession_();
}
};

Expand All @@ -95,18 +95,23 @@ remoting.ActivationHandler.prototype.onRestart_ = function(id) {
};

/**
* @param {Event} launchData
* @private
*/
remoting.ActivationHandler.prototype.onLaunched_ = function() {
this.createWindow_();
remoting.ActivationHandler.prototype.onLaunched_ = function(launchData) {
if (launchData['isPublicSession']) {
this.launchIt2MeSession_();
} else {
this.launchDefaultSession_();
}
};

/**
* Create a new app window and register for the closed event.
*
* @private
*/
remoting.ActivationHandler.prototype.createWindow_ = function() {
remoting.ActivationHandler.prototype.launchDefaultSession_ = function() {
this.appLauncher_.launch().then(this.onWindowCreated_.bind(this));
};

Expand Down Expand Up @@ -144,6 +149,15 @@ remoting.ActivationHandler.prototype.onWindowClosed_ = function(id) {
this.raiseEvent(remoting.ActivationHandler.Events.windowClosed, id);
};

/** @private */
remoting.ActivationHandler.prototype.launchIt2MeSession_ = function() {
chrome.app.window.create("public_session.html", {
'width': 570,
'height': 300,
'resizable': false
});
};

})();

/** @enum {string} */
Expand Down
37 changes: 8 additions & 29 deletions remoting/webapp/crd/js/host_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ var it2meLogger = null;
* to install them if necessary.
*/
remoting.tryShare = function() {
ensureIT2MeLogger_().then(tryShareWithLogger_);
};

function tryShareWithLogger_() {
ensureIT2MeLogger_();
it2meLogger.setSessionId();
it2meLogger.logClientSessionStateChange(
remoting.ClientSession.State.INITIALIZING, remoting.Error.none(), null);
Expand Down Expand Up @@ -79,11 +76,11 @@ function tryShareWithLogger_() {
*/
remoting.startHostUsingFacade_ = function(hostFacade) {
console.log('Attempting to share...');
setHostVersion_()
.then(remoting.identity.getToken.bind(remoting.identity))
.then(remoting.tryShareWithToken_.bind(null, hostFacade),
remoting.Error.handler(showShareError_));
}
it2meLogger.setHostVersion(hostFacade.getHostVersion());
remoting.identity.getToken().then(
remoting.tryShareWithToken_.bind(null, hostFacade),
remoting.Error.handler(showShareError_));
};

/**
* @param {remoting.It2MeHostFacade} hostFacade An initialized
Expand Down Expand Up @@ -364,13 +361,10 @@ function onNatTraversalPolicyChanged_(enabled) {

/**
* Create an IT2Me LogToServer instance if one does not already exist.
*
* @return {Promise} Promise that resolves when the host version (if available),
* has been set on the logger instance.
*/
function ensureIT2MeLogger_() {
if (it2meLogger) {
return Promise.resolve();
return;
}

var xmppConnection = new remoting.XmppConnection();
Expand All @@ -386,21 +380,6 @@ function ensureIT2MeLogger_() {
new remoting.BufferedSignalStrategy(xmppConnection);
it2meLogger = new remoting.LogToServer(bufferedSignalStrategy, true);
it2meLogger.setLogEntryMode(remoting.ChromotingEvent.Mode.IT2ME);

return setHostVersion_();
};

/**
* @return {Promise} Promise that resolves when the host version (if available),
* has been set on the logger instance.
*/
function setHostVersion_() {
return remoting.hostController.getLocalHostVersion().then(
function(/** string */ version) {
it2meLogger.setHostVersion(version);
}).catch(
base.doNothing
);
};
}

})();
15 changes: 13 additions & 2 deletions remoting/webapp/crd/js/it2me_host_facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ remoting.It2MeHostFacade = function() {
/** @private {?function(boolean):void} */
this.onNatPolicyChanged_ = function() {};

/** @private */
this.hostVersion_ = '';

/** @private */
this.debugMessageHandler_ =
new remoting.NativeMessageHostDebugMessageHandler();
Expand Down Expand Up @@ -204,6 +207,14 @@ remoting.It2MeHostFacade.prototype.getClient = function() {
return this.clientId_;
};

/**
* @return {string}
*/
remoting.It2MeHostFacade.prototype.getHostVersion = function() {
return this.hostVersion_;
};


/**
* Handler for incoming messages.
*
Expand All @@ -221,8 +232,8 @@ remoting.It2MeHostFacade.prototype.onIncomingMessage_ =

switch (type) {
case 'helloResponse':
var version = base.getStringAttr(message, 'version');
console.log('Host version: ', version);
this.hostVersion_ = base.getStringAttr(message, 'version');
console.log('Host version: ', this.hostVersion_);
this.initialized_ = true;
// A "hello" request is sent immediately after the native messaging host
// is started. We can proceed to the next task once we receive the
Expand Down
Loading

0 comments on commit 08d2852

Please sign in to comment.