diff options
author | kelvinp <kelvinp@chromium.org> | 2015-10-01 12:16:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-01 19:17:52 +0000 |
commit | 08d28524dc2673bc7e85b37d2b82d0d65c34ea05 (patch) | |
tree | 6446118b5150fb451a59c557d13693abf327f455 | |
parent | 86d0a29db0067654762764bf51a69c450435668a (diff) | |
download | chromium_src-08d28524dc2673bc7e85b37d2b82d0d65c34ea05.zip chromium_src-08d28524dc2673bc7e85b37d2b82d0d65c34ea05.tar.gz chromium_src-08d28524dc2673bc7e85b37d2b82d0d65c34ea05.tar.bz2 |
[Chromoting] Remote Assistance in Public Session.
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}
-rw-r--r-- | remoting/remoting_client.gypi | 19 | ||||
-rw-r--r-- | remoting/remoting_webapp.gypi | 1 | ||||
-rw-r--r-- | remoting/remoting_webapp_files.gypi | 34 | ||||
-rw-r--r-- | remoting/webapp/base/js/application.js | 7 | ||||
-rw-r--r-- | remoting/webapp/base/js/ui_mode.js | 9 | ||||
-rw-r--r-- | remoting/webapp/build_template.gni | 17 | ||||
-rw-r--r-- | remoting/webapp/crd/html/public_session.css | 14 | ||||
-rw-r--r-- | remoting/webapp/crd/html/template_public_session.html | 28 | ||||
-rw-r--r-- | remoting/webapp/crd/js/activation_handler.js | 22 | ||||
-rw-r--r-- | remoting/webapp/crd/js/host_screen.js | 37 | ||||
-rw-r--r-- | remoting/webapp/crd/js/it2me_host_facade.js | 15 | ||||
-rw-r--r-- | remoting/webapp/crd/js/public_session_main.js | 51 | ||||
-rw-r--r-- | remoting/webapp/files.gni | 42 |
13 files changed, 250 insertions, 46 deletions
diff --git a/remoting/remoting_client.gypi b/remoting/remoting_client.gypi index 5490d52..891b625 100644 --- a/remoting/remoting_client.gypi +++ b/remoting/remoting_client.gypi @@ -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' diff --git a/remoting/remoting_webapp.gypi b/remoting/remoting_webapp.gypi index 6151bf2..230f153 100644 --- a/remoting/remoting_webapp.gypi +++ b/remoting/remoting_webapp.gypi @@ -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', }, diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi index 5e90ca7..a080136 100644 --- a/remoting/remoting_webapp_files.gypi +++ b/remoting/remoting_webapp_files.gypi @@ -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', @@ -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)', @@ -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': [ @@ -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', ], diff --git a/remoting/webapp/base/js/application.js b/remoting/webapp/base/js/application.js index d1b1530..8fac258 100644 --- a/remoting/webapp/base/js/application.js +++ b/remoting/webapp/base/js/application.js @@ -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)); }; /** diff --git a/remoting/webapp/base/js/ui_mode.js b/remoting/webapp/base/js/ui_mode.js index 5338860..07ad094 100644 --- a/remoting/webapp/base/js/ui_mode.js +++ b/remoting/webapp/base/js/ui_mode.js @@ -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));
\ No newline at end of file diff --git a/remoting/webapp/build_template.gni b/remoting/webapp/build_template.gni index 7053cd6..3b8d9509 100644 --- a/remoting/webapp/build_template.gni +++ b/remoting/webapp/build_template.gni @@ -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" @@ -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", ] @@ -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 diff --git a/remoting/webapp/crd/html/public_session.css b/remoting/webapp/crd/html/public_session.css new file mode 100644 index 0000000..0654c88 --- /dev/null +++ b/remoting/webapp/crd/html/public_session.css @@ -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; +}
\ No newline at end of file diff --git a/remoting/webapp/crd/html/template_public_session.html b/remoting/webapp/crd/html/template_public_session.html new file mode 100644 index 0000000..9196de8 --- /dev/null +++ b/remoting/webapp/crd/html/template_public_session.html @@ -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…</em> + </section> + <div data-ui-mode="home.host" hidden> + <meta-include src="webapp/crd/html/dialog_host.html"/> + </div> + </body> +</html> diff --git a/remoting/webapp/crd/js/activation_handler.js b/remoting/webapp/crd/js/activation_handler.js index 901dde9..cadb882 100644 --- a/remoting/webapp/crd/js/activation_handler.js +++ b/remoting/webapp/crd/js/activation_handler.js @@ -80,7 +80,7 @@ remoting.ActivationHandler.Ipc = { */ remoting.ActivationHandler.prototype.onContextMenu_ = function(info) { if (info.menuItemId == NEW_WINDOW_MENU_ID_) { - this.createWindow_(); + this.launchDefaultSession_(); } }; @@ -95,10 +95,15 @@ 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_(); + } }; /** @@ -106,7 +111,7 @@ remoting.ActivationHandler.prototype.onLaunched_ = function() { * * @private */ -remoting.ActivationHandler.prototype.createWindow_ = function() { +remoting.ActivationHandler.prototype.launchDefaultSession_ = function() { this.appLauncher_.launch().then(this.onWindowCreated_.bind(this)); }; @@ -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} */ diff --git a/remoting/webapp/crd/js/host_screen.js b/remoting/webapp/crd/js/host_screen.js index 656a703..b0b61b9 100644 --- a/remoting/webapp/crd/js/host_screen.js +++ b/remoting/webapp/crd/js/host_screen.js @@ -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); @@ -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 @@ -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(); @@ -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 - ); -}; +} })(); diff --git a/remoting/webapp/crd/js/it2me_host_facade.js b/remoting/webapp/crd/js/it2me_host_facade.js index c9167c8..0d517ad 100644 --- a/remoting/webapp/crd/js/it2me_host_facade.js +++ b/remoting/webapp/crd/js/it2me_host_facade.js @@ -63,6 +63,9 @@ remoting.It2MeHostFacade = function() { this.onNatPolicyChanged_ = function() {}; /** @private */ + this.hostVersion_ = ''; + + /** @private */ this.debugMessageHandler_ = new remoting.NativeMessageHostDebugMessageHandler(); @@ -205,6 +208,14 @@ remoting.It2MeHostFacade.prototype.getClient = function() { }; /** + * @return {string} + */ +remoting.It2MeHostFacade.prototype.getHostVersion = function() { + return this.hostVersion_; +}; + + +/** * Handler for incoming messages. * * @param {Object} message The received message. @@ -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 diff --git a/remoting/webapp/crd/js/public_session_main.js b/remoting/webapp/crd/js/public_session_main.js new file mode 100644 index 0000000..1257737 --- /dev/null +++ b/remoting/webapp/crd/js/public_session_main.js @@ -0,0 +1,51 @@ +// 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. + +/** @suppress {duplicate} */ +var remoting = remoting || {}; + +(function() { + +'use strict'; + +/** @constructor */ +remoting.PublicSession = function() { + // Initialize global dependencies. + l10n.localize(); + remoting.identity = new remoting.Identity(); + remoting.settings = new remoting.Settings(); + + // override remoting.setMode() so that the content will always fit. + var setMode = remoting.setMode; + remoting.setMode = function(/** string */ mode) { + setMode(mode); + base.resizeWindowToContent(); + }; + + /** @private */ + this.eventHooks_ = new base.Disposables( + new base.DomEventHook(document.getElementById('host-finished-button'), + 'click', this.exit_.bind(this), false), + new base.DomEventHook(document.getElementById('cancel-share-button'), + 'click', this.exit_.bind(this), false)); +}; + +remoting.PublicSession.prototype.start = function() { + remoting.tryShare(); +}; + +/** @private */ +remoting.PublicSession.prototype.exit_ = function() { + base.dispose(this.eventHooks_); + this.eventHooks_ = null; + chrome.app.window.current().close(); +}; + +window.addEventListener('load', function () { + remoting.publicSession = new remoting.PublicSession(); + remoting.publicSession.start(); +}, false); + +})(); + diff --git a/remoting/webapp/files.gni b/remoting/webapp/files.gni index 37042a9..070c9d4 100644 --- a/remoting/webapp/files.gni +++ b/remoting/webapp/files.gni @@ -287,6 +287,18 @@ remoting_webapp_js_host_control_files = [ "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 = [ + "crd/js/buffered_signal_strategy.js", + "crd/js/host_screen.js", + "crd/js/host_session.js", + "crd/js/host_install_dialog.js", + "crd/js/host_installer.js", + "crd/js/it2me_host_facade.js", + "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 = [ "crd/js/host_list.js", @@ -388,6 +400,32 @@ remoting_webapp_template_files = [ ] # +# DesktopRemoting public_session.html generation files. +# +remoting_webapp_template_public_session = + "crd/html/template_public_session.html" + +# The shared JavaScript files required by public_session.html. +remoting_webapp_public_session_html_all_js_files = + # Include the core files first as it is required by the other files. + # Otherwise, Jscompile will complain. + 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_ui_files + + remoting_webapp_shared_js_signaling_files + + remoting_webapp_js_it2me_host_control_files + + [ + "crd/js/crd_auth_dialog.js", + "crd/js/public_session_main.js", + ] + +# These template files are used to construct public_session.html. +remoting_webapp_public_session_template_files = [ "crd/html/dialog_host.html" ] + +# # DesktopRemoting background.html generation files. # @@ -521,13 +559,15 @@ remoting_webapp_resource_files = [ "crd/html/crd_main.css", "crd/html/toolbar.css", "crd/html/menu_button.css", + "crd/html/public_session.css", "crd/html/window_frame.css", "crd/resources/scale-to-fit.webp", ] remoting_webapp_crd_files = remoting_webapp_info_files + remoting_webapp_crd_js_files + - remoting_webapp_resource_files + remoting_webapp_resource_files + + remoting_webapp_public_session_html_all_js_files # Files that contain localizable strings. desktop_remoting_webapp_localizable_files = |