diff options
Diffstat (limited to 'remoting')
31 files changed, 447 insertions, 181 deletions
diff --git a/remoting/app_remoting_webapp.gyp b/remoting/app_remoting_webapp.gyp index fad6f42..c6a0065 100644 --- a/remoting/app_remoting_webapp.gyp +++ b/remoting/app_remoting_webapp.gyp @@ -45,12 +45,12 @@ ], }, { - 'action_name': 'Verify >(ar_app_name) background.js', + 'action_name': 'Verify >(ar_app_name) background.html', 'variables': { 'success_stamp': '<(PRODUCT_DIR)/>(_target_name)_background_jscompile.stamp', }, 'inputs': [ - '<@(ar_background_js_files)', + '<@(ar_background_html_js_files)', '<@(remoting_webapp_js_proto_files)', # Include zip as input so that this action is run after the build. '<(zip_path)', @@ -62,7 +62,7 @@ 'python', '../third_party/closure_compiler/compile.py', '<@(compiler_flags)', '--success-stamp', '<(success_stamp)', - '<@(ar_background_js_files)', + '<@(ar_background_html_js_files)', '<@(remoting_webapp_js_proto_files)', ], }, diff --git a/remoting/app_remoting_webapp_build.gypi b/remoting/app_remoting_webapp_build.gypi index bc6ffa6..50fb6d3 100644 --- a/remoting/app_remoting_webapp_build.gypi +++ b/remoting/app_remoting_webapp_build.gypi @@ -40,18 +40,10 @@ '>(ar_app_path)/icon128.png', '>(ar_app_path)/loading_splash.png', ], - 'ar_generated_html_files': [ - '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/loading_window.html', - '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/main.html', - '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/message_window.html', - '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/wcs_sandbox.html', - '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/feedback_consent.html', - ], 'ar_webapp_files': [ '<@(ar_app_specific_files)', - '<@(ar_shared_resource_files)', - '<@(ar_all_js_files)', - '<@(ar_generated_html_files)', + '<@(ar_vendor_js_files)', + '<@(ar_vendor_html_files)', ], 'output_dir': '<(PRODUCT_DIR)/app_streaming/<@(ar_service_environment)/>(_target_name)', 'zip_path': '<(PRODUCT_DIR)/app_streaming/<@(ar_service_environment)/>(_target_name).zip', @@ -102,7 +94,6 @@ '<(remoting_version_path)', '<@(ar_webapp_files)', '<@(remoting_webapp_locale_files)', - '<@(ar_generated_html_files)', '<(ar_app_manifest_app)', '<(DEPTH)/remoting/<(ar_app_manifest_common)', '<(ar_webapp_locales_listfile)', @@ -162,6 +153,25 @@ ], }, { + 'action_name': 'Build ">(ar_app_name)" ar_background.html', + 'inputs': [ + '<(DEPTH)/remoting/webapp/build-html.py', + '<(ar_background_template)', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/ar_background.html', + ], + 'action': [ + 'python', '<(DEPTH)/remoting/webapp/build-html.py', + '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/ar_background.html', + '<(ar_background_template)', + '--template-dir', + '<(DEPTH)/remoting', + '--js', + '<@(ar_background_html_js_files)', + ], + }, + { 'action_name': 'Build ">(ar_app_name)" wcs_sandbox.html', 'inputs': [ '<(DEPTH)/remoting/webapp/build-html.py', diff --git a/remoting/app_remoting_webapp_files.gypi b/remoting/app_remoting_webapp_files.gypi index fc5686d..09ce4a2 100644 --- a/remoting/app_remoting_webapp_files.gypi +++ b/remoting/app_remoting_webapp_files.gypi @@ -57,7 +57,6 @@ 'webapp/app_remoting/js/app_remoting.js', 'webapp/app_remoting/js/app_remoting_activity.js', 'webapp/app_remoting/js/ar_auth_dialog.js', - 'webapp/app_remoting/js/ar_main.js', 'webapp/app_remoting/js/context_menu_adapter.js', 'webapp/app_remoting/js/context_menu_chrome.js', 'webapp/app_remoting/js/context_menu_dom.js', @@ -69,8 +68,6 @@ 'webapp/app_remoting/js/loading_window.js', 'webapp/app_remoting/js/submenu_manager.js', 'webapp/app_remoting/js/window_activation_menu.js', - 'webapp/base/js/application.js', - 'webapp/base/js/base.js', 'webapp/base/js/message_window_helper.js', 'webapp/base/js/message_window_manager.js', '<@(remoting_webapp_shared_js_auth_google_files)', @@ -82,18 +79,30 @@ '<@(remoting_webapp_shared_js_ui_files)', ], - 'ar_background_js_files': [ + # Variables for ar_background.html. + 'ar_background_template': + '<(DEPTH)/remoting/webapp/app_remoting/html/template_background.html', + 'ar_background_html_js_files': [ 'webapp/app_remoting/js/ar_background.js', 'webapp/base/js/platform.js', ], + 'ar_vendor_js_files': [ + 'webapp/app_remoting/vendor/arv_main.js', + ], + + 'ar_vendor_html_files': [ + 'webapp/app_remoting/vendor/arv_background.html', + 'webapp/app_remoting/vendor/arv_main.html', + 'webapp/app_remoting/vendor/arv_wcs_sandbox.html', + ], + 'ar_all_js_files': [ '<@(ar_main_js_files)', '<@(ar_feedback_consent_html_js_files)', '<@(remoting_webapp_message_window_html_js_files)', '<@(remoting_webapp_wcs_sandbox_html_js_files)', - # Referenced from the manifest. - '<@(ar_background_js_files)', + '<@(ar_background_html_js_files)', ], # Files that contain localizable strings. diff --git a/remoting/remoting_options.gni b/remoting/remoting_options.gni index df1292f..6c1c7a1 100644 --- a/remoting/remoting_options.gni +++ b/remoting/remoting_options.gni @@ -11,6 +11,9 @@ declare_args() { # Set this to enable cast mode on the android client. enable_cast = 0 +# Set this to enable building internal AppRemoting apps. +enable_internal_app_remoting_targets = false + # Set this to use GCD instead of the remoting directory service. remoting_use_gcd = 0 diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi index 3657d33..ec05e58 100644 --- a/remoting/remoting_webapp_files.gypi +++ b/remoting/remoting_webapp_files.gypi @@ -169,7 +169,6 @@ ], # Remoting core JavaScript files. 'remoting_webapp_shared_js_core_files': [ - 'webapp/base/js/app_capabilities.js', 'webapp/base/js/application.js', 'webapp/base/js/base.js', 'webapp/base/js/ipc.js', diff --git a/remoting/webapp/BUILD.gn b/remoting/webapp/BUILD.gn index e3e7966..f6c765b 100644 --- a/remoting/webapp/BUILD.gn +++ b/remoting/webapp/BUILD.gn @@ -11,8 +11,13 @@ group("webapp") { deps = [ ":webapp_v1", ":ar_sample_app", + ":ar_shared_module", ] + if (enable_internal_app_remoting_targets) { + deps += [ "//remoting/internal:ar_internal_apps" ] + } + if (enable_nacl) { deps += [ ":webapp_v2" ] } @@ -40,8 +45,18 @@ app_remoting_webapp("ar_sample_app") { app_key = "Sample_App" app_id = "ljacajndfccfgnfohlgkdphmbnpkjflk" app_client_id = "sample_client_id" - app_name = "App Remoting Client" + app_vendor = "" + app_name = "sample_app" + app_fullname = "App Remoting Client" app_description = "App Remoting client" app_capabilities = [ "GOOGLE_DRIVE" ] manifest_key = "remotingdevbuild" } + +app_remoting_shared_module("ar_shared_module") { + app_client_id = "sample_client_id" + app_name = "shared_module" + app_fullname = "AppRemoting Shared Module" + app_description = "AppRemoting Shared Module" + manifest_key = "remotingdevbuild" +} diff --git a/remoting/webapp/app_remoting/html/context_menu.html b/remoting/webapp/app_remoting/html/context_menu.html index ebc056e..010c86d 100644 --- a/remoting/webapp/app_remoting/html/context_menu.html +++ b/remoting/webapp/app_remoting/html/context_menu.html @@ -6,7 +6,7 @@ found in the LICENSE file. <div id="context-menu" draggable="true" hidden> <div class="no-gaps"> - <img src="icon48.png" class="context-menu-icon"> + <img src="/icon48.png" class="context-menu-icon"> <span class="context-menu-stub etched"></span> </div> <ul> diff --git a/remoting/webapp/app_remoting/html/template_background.html b/remoting/webapp/app_remoting/html/template_background.html new file mode 100644 index 0000000..10d293b --- /dev/null +++ b/remoting/webapp/app_remoting/html/template_background.html @@ -0,0 +1,18 @@ +<!doctype html> +<!-- +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. +--> + +<html> + <head> + <meta charset="utf-8"> + + <meta-include type="javascript"/> + + <title></title> + </head> + <body> + </body> +</html> diff --git a/remoting/webapp/app_remoting/html/template_feedback_consent.html b/remoting/webapp/app_remoting/html/template_feedback_consent.html index 6fc98d8..4d839e4 100644 --- a/remoting/webapp/app_remoting/html/template_feedback_consent.html +++ b/remoting/webapp/app_remoting/html/template_feedback_consent.html @@ -8,7 +8,7 @@ found in the LICENSE file. <html> <head> <meta charset="utf-8"> - <link rel="icon" type="image/png" href="icon16.png"> + <link rel="icon" type="image/png" href="/icon16.png"> <link rel="stylesheet" href="open_sans.css"> <link rel="stylesheet" href="feedback_consent.css"> <link rel="stylesheet" href="main.css"> diff --git a/remoting/webapp/app_remoting/html/template_lg.html b/remoting/webapp/app_remoting/html/template_lg.html index 6f27a94..18aa95e 100644 --- a/remoting/webapp/app_remoting/html/template_lg.html +++ b/remoting/webapp/app_remoting/html/template_lg.html @@ -8,7 +8,7 @@ found in the LICENSE file. <html class="full-height app-remoting"> <head> <meta charset="utf-8"> - <link rel="icon" type="image/png" href="icon16.png"> + <link rel="icon" type="image/png" href="/icon16.png"> <link rel="stylesheet" href="ar_main.css"> <link rel="stylesheet" href="ar_dialog.css"> <link rel="stylesheet" href="connection_stats.css"> @@ -19,6 +19,8 @@ found in the LICENSE file. <meta-include type="javascript"/> + <link rel="import" href="/arv_main.html"> + <title i18n-content="PRODUCT_NAME_APP_STREAMING"></title> </head> diff --git a/remoting/webapp/app_remoting/html/template_loading_window.html b/remoting/webapp/app_remoting/html/template_loading_window.html index b69432e..713e798 100644 --- a/remoting/webapp/app_remoting/html/template_loading_window.html +++ b/remoting/webapp/app_remoting/html/template_loading_window.html @@ -17,7 +17,7 @@ found in the LICENSE file. <title></title> </head> <body> - <img src="loading_splash.png" id="splash-image"> + <img src="/loading_splash.png" id="splash-image"> <div class="message-container"> <div id="title" hidden></div> <p id="infobox" class="information-box"></p> diff --git a/remoting/webapp/app_remoting/js/app_remoting.js b/remoting/webapp/app_remoting/js/app_remoting.js index 87b9134..80417cb 100644 --- a/remoting/webapp/app_remoting/js/app_remoting.js +++ b/remoting/webapp/app_remoting/js/app_remoting.js @@ -14,25 +14,59 @@ var remoting = remoting || {}; /** - * @param {Array<string>} appCapabilities Array of application capabilities. - * @param {remoting.LicenseManager=} opt_licenseManager + * Parameters for the remoting.AppRemoting constructor. + * + * appId: The application ID. If this is not specified than the app id will + * be extracted from the app's manifest. + * + * appCapabilites: Array of application capabilites. + * + * licenseManager: Licence manager for this application. + * + * @typedef {{ + * appId: (string|undefined), + * appCapabilities: (Array<string>|undefined), + * licenseManager: (remoting.LicenseManager|undefined) + * }} + */ +remoting.AppRemotingParams; + +/** + * @param {remoting.AppRemotingParams} args * @constructor * @implements {remoting.ApplicationInterface} * @extends {remoting.Application} */ -remoting.AppRemoting = function(appCapabilities, opt_licenseManager) { +remoting.AppRemoting = function(args) { base.inherits(this, remoting.Application); /** @private {remoting.Activity} */ this.activity_ = null; + /** @private {string} */ + this.appId_ = (args.appId) ? args.appId : chrome.runtime.id; + /** @private */ - this.licenseManager_ = (opt_licenseManager) ? - opt_licenseManager : + this.licenseManager_ = (args.licenseManager) ? + args.licenseManager : new remoting.GaiaLicenseManager(); /** @private */ - this.appCapabilities_ = appCapabilities; + this.appCapabilities_ = (args.appCapabilities) ? args.appCapabilities : []; + + // This prefix must be added to message window paths so that the HTML + // files can be found in the shared module. + // TODO(garykac) Add support for dev/prod shared modules. + remoting.MessageWindow.htmlFilePrefix = + "_modules/koejkfhmphamcgafjmkellhnekdkopod/"; +}; + +/** + * @return {string} Application Id. + * @override {remoting.ApplicationInterface} + */ +remoting.AppRemoting.prototype.getApplicationId = function() { + return this.appId_; }; /** diff --git a/remoting/webapp/app_remoting/js/app_remoting_activity.js b/remoting/webapp/app_remoting/js/app_remoting_activity.js index 4ad682a..ef24629 100644 --- a/remoting/webapp/app_remoting/js/app_remoting_activity.js +++ b/remoting/webapp/app_remoting/js/app_remoting_activity.js @@ -94,7 +94,7 @@ remoting.AppRemotingActivity.prototype.cleanup_ = function() { */ remoting.AppRemotingActivity.prototype.getAppHostInfo_ = function(token) { var url = remoting.settings.APP_REMOTING_API_BASE_URL + '/applications/' + - remoting.settings.getAppRemotingApplicationId() + '/run'; + this.app_.getApplicationId() + '/run'; // TODO(kelvinp): Passes |this.subscriptionToken_| to the XHR. return new remoting.AutoRetryXhr({ method: 'POST', diff --git a/remoting/webapp/app_remoting/js/application_context_menu.js b/remoting/webapp/app_remoting/js/application_context_menu.js index 8d15824..a80ed85 100644 --- a/remoting/webapp/app_remoting/js/application_context_menu.js +++ b/remoting/webapp/app_remoting/js/application_context_menu.js @@ -103,6 +103,7 @@ remoting.ApplicationContextMenu.prototype.onClicked_ = function(info) { var onLoad = function() { var message = { method: 'init', + appId: remoting.app.getApplicationId(), hostId: that.hostId_, connectionStats: JSON.stringify(that.stats_.mostRecent()), sessionId: that.clientSession_.getLogger().getSessionId() diff --git a/remoting/webapp/app_remoting/js/ar_background.js b/remoting/webapp/app_remoting/js/ar_background.js index 4ee2507..d9ea8e5 100644 --- a/remoting/webapp/app_remoting/js/ar_background.js +++ b/remoting/webapp/app_remoting/js/ar_background.js @@ -55,7 +55,10 @@ function createWindow(opt_launchData) { appWindow.onClosed.addListener(onClosed); }; - chrome.app.window.create('main.html', windowAttributes, onCreate); + // TODO(garykac) Add code to switch between dev and prod shared modules. + chrome.app.window.create( + '_modules/koejkfhmphamcgafjmkellhnekdkopod/main.html', + windowAttributes, onCreate); }; /** @param {Event} event */ diff --git a/remoting/webapp/app_remoting/js/feedback_consent.js b/remoting/webapp/app_remoting/js/feedback_consent.js index 9dce238..2195ea5 100644 --- a/remoting/webapp/app_remoting/js/feedback_consent.js +++ b/remoting/webapp/app_remoting/js/feedback_consent.js @@ -5,6 +5,11 @@ 'use strict'; /** + * @type {string} The app id (from the webstore) for this application. + */ +var appId = ''; + +/** * @type {string} The host id corresponding to the user's VM. The @pending * place-holder instructs the Orchestrator to abandon any pending host, * and is used if no host id is provided by the main window. @@ -140,7 +145,7 @@ function onToken(token) { 'crashServiceReportId': crashServiceReportId }; var uri = remoting.settings.APP_REMOTING_API_BASE_URL + - '/applications/' + remoting.settings.getAppRemotingApplicationId() + + '/applications/' + appId + '/hosts/' + hostId + '/reportIssue'; var onDone = function(/** !remoting.Xhr.Response */ response) { @@ -250,6 +255,7 @@ function onWindowMessage(event) { if (event.data['hostId']) { hostId = /** @type {string} */ (event.data['hostId']); } + appId = /** @type {string} */ (event.data['appId']); connectionStats = /** @type {string} */ (event.data['connectionStats']); sessionId = /** @type {string} */ (event.data['sessionId']); } diff --git a/remoting/webapp/app_remoting/manifest_common.json.jinja2 b/remoting/webapp/app_remoting/manifest_common.json.jinja2 index 3f1884e..c04a8f5 100644 --- a/remoting/webapp/app_remoting/manifest_common.json.jinja2 +++ b/remoting/webapp/app_remoting/manifest_common.json.jinja2 @@ -6,9 +6,13 @@ "default_locale": "en", "app": { "background": { - "scripts": ["ar_background.js", "platform.js"] + "page": "arv_background.html" } }, + "import": [{ + "id": "koejkfhmphamcgafjmkellhnekdkopod" + } + ], "icons": { "128": "icon128.png", "48": "icon48.png", @@ -60,5 +64,5 @@ ] }, "sandbox": { - "pages": [ "wcs_sandbox.html" ] + "pages": [ "arv_wcs_sandbox.html" ] } diff --git a/remoting/webapp/app_remoting/shared_module/manifest.json b/remoting/webapp/app_remoting/shared_module/manifest.json new file mode 100644 index 0000000..7ac5731 --- /dev/null +++ b/remoting/webapp/app_remoting/shared_module/manifest.json @@ -0,0 +1,8 @@ +{ + "name": "AppRemoting Shared Module", + "manifest_version": 2, + "version": "1.0", + "export": {}, + "default_locale": "en", + "key": "AppRemotingSharedMod" +} diff --git a/remoting/webapp/app_remoting/vendor/arv_background.html b/remoting/webapp/app_remoting/vendor/arv_background.html new file mode 100644 index 0000000..85c419e --- /dev/null +++ b/remoting/webapp/app_remoting/vendor/arv_background.html @@ -0,0 +1,2 @@ +<!DOCTYPE html> +<iframe src="_modules/koejkfhmphamcgafjmkellhnekdkopod/ar_background.html"></iframe> diff --git a/remoting/webapp/app_remoting/vendor/arv_main.html b/remoting/webapp/app_remoting/vendor/arv_main.html new file mode 100644 index 0000000..0b655f8 --- /dev/null +++ b/remoting/webapp/app_remoting/vendor/arv_main.html @@ -0,0 +1,13 @@ +<!doctype html> +<!-- +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. +--> + +<!-- +This file is automatically HTML-imported by the main HTML page. +Multiple JS files can be listed here and they will all be included in the +app's main HTML page. +--> +<script src="arv_main.js"></script> diff --git a/remoting/webapp/app_remoting/js/ar_main.js b/remoting/webapp/app_remoting/vendor/arv_main.js index 2efe129..0278bf8 100644 --- a/remoting/webapp/app_remoting/js/ar_main.js +++ b/remoting/webapp/app_remoting/vendor/arv_main.js @@ -11,7 +11,14 @@ var remoting = remoting || {}; * Entry point ('load' handler) for App Remoting webapp. */ remoting.startAppRemoting = function() { - remoting.app = new remoting.AppRemoting(remoting.app_capabilities()); + // This string is overwritten with the actual app id by the build script. + var appId = 'APP_REMOTING_APPLICATION_ID'; + + // This string is overwritten with the actual capabilities required by + // this application. + var capabilities = ['APPLICATION_CAPABILITIES']; + + remoting.app = new remoting.AppRemoting(appId, capabilities); remoting.app.start(); }; diff --git a/remoting/webapp/app_remoting/vendor/arv_wcs_sandbox.html b/remoting/webapp/app_remoting/vendor/arv_wcs_sandbox.html new file mode 100644 index 0000000..cdca40a --- /dev/null +++ b/remoting/webapp/app_remoting/vendor/arv_wcs_sandbox.html @@ -0,0 +1,2 @@ +<!DOCTYPE html> +<iframe src="_modules/koejkfhmphamcgafjmkellhnekdkopod/wcs_sandbox.html"></iframe> diff --git a/remoting/webapp/base/js/app_capabilities.js b/remoting/webapp/base/js/app_capabilities.js deleted file mode 100644 index bdbc96c..0000000 --- a/remoting/webapp/base/js/app_capabilities.js +++ /dev/null @@ -1,18 +0,0 @@ -// 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. - -'use strict'; - -/** @suppress {duplicate} */ -var remoting = remoting || {}; - -/** - * Note that this needs to be a function because it gets expanded at - * compile-time into remoting.ClientSession.Capability enums and these - * are not guaranteed to be present yet when this file is loaded. - * @return {Array<remoting.ClientSession.Capability>} - */ -remoting.app_capabilities = function() { - return ['APPLICATION_CAPABILITIES']; -} diff --git a/remoting/webapp/base/js/application.js b/remoting/webapp/base/js/application.js index 3910405..ab3215b 100644 --- a/remoting/webapp/base/js/application.js +++ b/remoting/webapp/base/js/application.js @@ -108,6 +108,11 @@ remoting.Application.prototype.getExtensionInfo = function() { */ /** @return {string} */ +remoting.Application.prototype.getApplicationId = function() { + base.debug.assert(false, 'Subclass must override'); +}; + +/** @return {string} */ remoting.Application.prototype.getApplicationName = function() { base.debug.assert(false, 'Subclass must override'); }; @@ -154,6 +159,11 @@ remoting.Application.prototype.exitApplication_ = function() { remoting.ApplicationInterface = function() {}; /** + * @return {string} Application Id. + */ +remoting.ApplicationInterface.prototype.getApplicationId = function() {}; + +/** * @return {string} Application product name to be used in UI. */ remoting.ApplicationInterface.prototype.getApplicationName = function() {}; diff --git a/remoting/webapp/base/js/message_window_helper.js b/remoting/webapp/base/js/message_window_helper.js index d608a03..51d63c0 100644 --- a/remoting/webapp/base/js/message_window_helper.js +++ b/remoting/webapp/base/js/message_window_helper.js @@ -121,7 +121,9 @@ remoting.MessageWindow = function(options) { }; var htmlFile = options.htmlFile || 'message_window.html'; - chrome.app.window.create(htmlFile, windowAttributes, onCreate); + chrome.app.window.create( + remoting.MessageWindow.htmlFilePrefix + htmlFile, + windowAttributes, onCreate); if (duration != 0) { this.timer_ = window.setTimeout(this.onTimeoutHandler_.bind(this), @@ -130,6 +132,15 @@ remoting.MessageWindow = function(options) { }; /** + * This string is prepended to the htmlFile when message windows are created. + * Normally, this should be left empty, but the shared module needs to specify + * this so that the shared HTML files can be found when running in the + * context of the app stub. + * @type {string} + */ +remoting.MessageWindow.htmlFilePrefix = ""; + +/** * Called when the timer runs out. This in turn calls the window's * timeout handler (if any). */ diff --git a/remoting/webapp/base/js/plugin_settings.js b/remoting/webapp/base/js/plugin_settings.js index a4b56d2..e57acca 100644 --- a/remoting/webapp/base/js/plugin_settings.js +++ b/remoting/webapp/base/js/plugin_settings.js @@ -49,18 +49,6 @@ remoting.Settings.prototype.OAUTH2_REDIRECT_URL = function() { remoting.Settings.prototype.APP_REMOTING_API_BASE_URL = 'APP_REMOTING_API_BASE_URL'; -/** - * Return this app's Application ID. - * - * This is a function rather than a constant because the build script may - * replace this string with code to calculate the app id dynamically. - * - * @return {string} The Application ID. - */ -remoting.Settings.prototype.getAppRemotingApplicationId = function() { - return 'APP_REMOTING_APPLICATION_ID'; -}; - /** @type {string} XMPP JID for the remoting directory server bot. */ remoting.Settings.prototype.DIRECTORY_BOT_JID = 'DIRECTORY_BOT_JID'; diff --git a/remoting/webapp/build-webapp.py b/remoting/webapp/build-webapp.py index 7eb66b6..4a705e7 100755 --- a/remoting/webapp/build-webapp.py +++ b/remoting/webapp/build-webapp.py @@ -120,7 +120,9 @@ def buildWebApp(buildtype, version, destination, zip_path, zipfile: A string with path to the zipfile to create containing the contents of |destination|. manifest_template: jinja2 template file for manifest. - webapp_type: webapp type ("v1", "v2", "v2_pnacl" or "app_remoting"). + webapp_type: webapp type: + For DesktopRemoting: "v1", "v2" or "v2_pnacl" + For AppRemoting: "app_remoting" or "shared_module" appid: A string with the Remoting Application Id (only used for app remoting webapps). If supplied, it defaults to using the test API server. @@ -212,11 +214,20 @@ def buildWebApp(buildtype, version, destination, zip_path, else: raise Exception('Unknown extension: ' + current_locale) + is_app_remoting_webapp = webapp_type == 'app_remoting' + is_app_remoting_shared_module = webapp_type == 'shared_module' + is_app_remoting = is_app_remoting_webapp or is_app_remoting_shared_module + is_prod_service_environment = service_environment == 'vendor' or \ + service_environment == 'prod' or \ + service_environment == 'prod-testing' + is_desktop_remoting = not is_app_remoting + # Set client plugin type. # TODO(wez): Use 'native' in app_remoting until b/17441659 is resolved. - client_plugin = 'pnacl' if webapp_type == 'v2_pnacl' else 'native' - findAndReplace(os.path.join(destination, 'plugin_settings.js'), - "'CLIENT_PLUGIN_TYPE'", "'" + client_plugin + "'") + if not is_app_remoting_webapp: + client_plugin = 'pnacl' if webapp_type == 'v2_pnacl' else 'native' + findAndReplace(os.path.join(destination, 'plugin_settings.js'), + "'CLIENT_PLUGIN_TYPE'", "'" + client_plugin + "'") # Allow host names for google services/apis to be overriden via env vars. oauth2AccountsHost = os.environ.get( @@ -226,11 +237,7 @@ def buildWebApp(buildtype, version, destination, zip_path, directoryApiHost = os.environ.get( 'DIRECTORY_API_HOST', 'https://www.googleapis.com') - is_app_remoting_webapp = webapp_type == 'app_remoting' - is_prod_service_environment = service_environment == 'vendor' or \ - service_environment == 'prod' or \ - service_environment == 'prod-testing' - if is_app_remoting_webapp: + if is_app_remoting: appRemotingApiHost = os.environ.get( 'APP_REMOTING_API_HOST', None) appRemotingApplicationId = os.environ.get( @@ -260,19 +267,20 @@ def buildWebApp(buildtype, version, destination, zip_path, # If an Application ID was set (either from service_environment variable or # from a command line argument), hardcode it, otherwise get it at runtime. - effectiveAppId = appRemotingApplicationId or appid - if effectiveAppId: - appRemotingApplicationId = "'" + effectiveAppId + "'" - else: - appRemotingApplicationId = "chrome.i18n.getMessage('@@extension_id')" - findAndReplace(os.path.join(destination, 'plugin_settings.js'), - "'APP_REMOTING_APPLICATION_ID'", appRemotingApplicationId) + if is_app_remoting_webapp: + effectiveAppId = appRemotingApplicationId or appid + if effectiveAppId: + appRemotingApplicationId = "'" + effectiveAppId + "'" + else: + appRemotingApplicationId = "chrome.i18n.getMessage('@@extension_id')" + findAndReplace(os.path.join(destination, 'arv_main.js'), + "'APP_REMOTING_APPLICATION_ID'", appRemotingApplicationId) oauth2BaseUrl = oauth2AccountsHost + '/o/oauth2' oauth2ApiBaseUrl = oauth2ApiHost + '/oauth2' directoryApiBaseUrl = directoryApiHost + '/chromoting/v1' - if is_app_remoting_webapp: + if is_app_remoting: # Set the apiary endpoint and then set the endpoint version if not appRemotingApiHost: if is_prod_service_environment: @@ -280,7 +288,11 @@ def buildWebApp(buildtype, version, destination, zip_path, else: appRemotingApiHost = 'https://www-googleapis-test.sandbox.google.com' - if service_environment == 'dev': + # TODO(garykac) Currently, the shared module is always set up for the + # dev service_environment. Update build so that the dev environment can + # be controlled by the app stub rather than hard-coded into the shared + # module. + if service_environment == 'dev' or is_app_remoting_shared_module: appRemotingServicePath = '/appremoting/v1beta1_dev' elif service_environment == 'test': appRemotingServicePath = '/appremoting/v1beta1' @@ -298,13 +310,17 @@ def buildWebApp(buildtype, version, destination, zip_path, else: appRemotingApiBaseUrl = '' - replaceBool(destination, 'USE_GCD', use_gcd) - replaceString(destination, 'OAUTH2_BASE_URL', oauth2BaseUrl) - replaceString(destination, 'OAUTH2_API_BASE_URL', oauth2ApiBaseUrl) - replaceString(destination, 'DIRECTORY_API_BASE_URL', directoryApiBaseUrl) - if is_app_remoting_webapp: - replaceString(destination, 'APP_REMOTING_API_BASE_URL', - appRemotingApiBaseUrl) + # TODO(garykac) replaceString (et al.) implictly update plugin_settings.js, + # which doesn't exist for the app stub. We need to move app-specific + # AppRemoting options into arv_main.js. + if not is_app_remoting_webapp: + replaceBool(destination, 'USE_GCD', use_gcd) + replaceString(destination, 'OAUTH2_BASE_URL', oauth2BaseUrl) + replaceString(destination, 'OAUTH2_API_BASE_URL', oauth2ApiBaseUrl) + replaceString(destination, 'DIRECTORY_API_BASE_URL', directoryApiBaseUrl) + if is_app_remoting: + replaceString(destination, 'APP_REMOTING_API_BASE_URL', + appRemotingApiBaseUrl) # Substitute hosts in the manifest's CSP list. # Ensure we list the API host only once if it's the same for multiple APIs. @@ -342,21 +358,23 @@ def buildWebApp(buildtype, version, destination, zip_path, oauth2RedirectUrlJson = oauth2RedirectBaseUrlJson + '/dev*' thirdPartyAuthUrlJs = oauth2RedirectBaseUrlJs + '/thirdpartyauth' thirdPartyAuthUrlJson = oauth2RedirectBaseUrlJson + '/thirdpartyauth*' - replaceString(destination, 'TALK_GADGET_URL', talkGadgetBaseUrl) - findAndReplace(os.path.join(destination, 'plugin_settings.js'), - "'OAUTH2_REDIRECT_URL'", oauth2RedirectUrlJs) - - # Configure xmpp server and directory bot settings in the plugin. - replaceBool( - destination, 'XMPP_SERVER_USE_TLS', - getenvBool('XMPP_SERVER_USE_TLS', True)) xmppServer = os.environ.get('XMPP_SERVER', 'talk.google.com:443') - replaceString(destination, 'XMPP_SERVER', xmppServer) - replaceString(destination, 'DIRECTORY_BOT_JID', - os.environ.get('DIRECTORY_BOT_JID', - 'remoting@bot.talk.google.com')) - replaceString(destination, 'THIRD_PARTY_AUTH_REDIRECT_URL', - thirdPartyAuthUrlJs) + + if not is_app_remoting_webapp: + replaceString(destination, 'TALK_GADGET_URL', talkGadgetBaseUrl) + findAndReplace(os.path.join(destination, 'plugin_settings.js'), + "'OAUTH2_REDIRECT_URL'", oauth2RedirectUrlJs) + + # Configure xmpp server and directory bot settings in the plugin. + replaceBool( + destination, 'XMPP_SERVER_USE_TLS', + getenvBool('XMPP_SERVER_USE_TLS', True)) + replaceString(destination, 'XMPP_SERVER', xmppServer) + replaceString(destination, 'DIRECTORY_BOT_JID', + os.environ.get('DIRECTORY_BOT_JID', + 'remoting@bot.talk.google.com')) + replaceString(destination, 'THIRD_PARTY_AUTH_REDIRECT_URL', + thirdPartyAuthUrlJs) # Set the correct API keys. # For overriding the client ID/secret via env vars, see google_api_keys.py. @@ -372,15 +390,17 @@ def buildWebApp(buildtype, version, destination, zip_path, else: apiClientIdV2 = google_api_keys.GetClientID('REMOTING_IDENTITY_API') - replaceString(destination, 'API_CLIENT_ID', apiClientId) - replaceString(destination, 'API_CLIENT_SECRET', apiClientSecret) - replaceString(destination, 'API_KEY', apiKey) + if not is_app_remoting_webapp: + replaceString(destination, 'API_CLIENT_ID', apiClientId) + replaceString(destination, 'API_CLIENT_SECRET', apiClientSecret) + replaceString(destination, 'API_KEY', apiKey) # Write the application capabilities. - appCapabilities = ','.join( - ['remoting.ClientSession.Capability.' + x for x in app_capabilities]) - findAndReplace(os.path.join(destination, 'app_capabilities.js'), - "'APPLICATION_CAPABILITIES'", appCapabilities) + if is_app_remoting_webapp: + appCapabilities = ','.join( + ['remoting.ClientSession.Capability.' + x for x in app_capabilities]) + findAndReplace(os.path.join(destination, 'arv_main.js'), + "'APPLICATION_CAPABILITIES'", appCapabilities) # Use a consistent extension id for dev builds. # AppRemoting builds always use the dev app id - the correct app id gets diff --git a/remoting/webapp/build_template.gni b/remoting/webapp/build_template.gni index 0eff3e6..ebbd44c 100644 --- a/remoting/webapp/build_template.gni +++ b/remoting/webapp/build_template.gni @@ -79,7 +79,7 @@ template("build_webapp_html") { js_files = invoker.js_files html_output = invoker.html_output - script = "build-html.py" + script = rebase_path("//remoting/webapp/build-html.py", root_build_dir) inputs = [ html_template_file ] + html_template_include_files + js_files @@ -156,7 +156,7 @@ template("desktop_remoting_webapp") { } action(target_name) { - script = "build-webapp.py" + script = "//remoting/webapp/build-webapp.py" webapp_type = invoker.webapp_type output_dir = invoker.output_dir @@ -226,6 +226,138 @@ template("app_remoting_webapp") { locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt" build_locales_listfile(locales_listfile) { + # TODO(garykac) Replace resources with empty stub rather than duplicating + # all the resources needed by the shared module. + # Template uses locales_listfile_output from outer scope. + } + + action(target_name) { + script = "//remoting/webapp/build-webapp.py" + + app_key = invoker.app_key + app_id = invoker.app_id + app_client_id = invoker.app_client_id + app_vendor = invoker.app_vendor + app_name = invoker.app_name + app_fullname = invoker.app_fullname + app_description = invoker.app_description + app_capabilities = invoker.app_capabilities + manifest_key = invoker.manifest_key + + # These asserts are so that these variables get marked as being used so + # that GN doesn't complain about them. + assert(app_key != "" || app_key == "") + assert(app_id != "" || app_id == "") + + ar_base_path = "//remoting/webapp/app_remoting" + if (app_vendor != "") { + ar_app_path = "$ar_base_path/internal/apps/$app_vendor/$app_name" + } else { + ar_app_path = "$ar_base_path/apps/$app_name" + } + ar_app_manifest = "$ar_app_path/manifest.json.jinja2" + ar_app_manifest_common = "$ar_base_path/manifest_common.json.jinja2" + + output_dir = "remoting/app_remoting/$ar_service_environment/$target_name" + zip_path = "remoting/app_remoting/$ar_service_environment/$target_name.zip" + + # TODO(garykac) Move this list of files into files.gni. + ar_app_specific_files = [ + "$ar_app_path/icon16.png", + "$ar_app_path/icon48.png", + "$ar_app_path/icon128.png", + "$ar_app_path/loading_splash.png", + ] + + ar_webapp_files = + ar_app_specific_files + ar_vendor_js_files + ar_vendor_html_files + + inputs = [ + rebase_path(ar_app_manifest, root_build_dir), + rebase_path(ar_app_manifest_common, root_build_dir), + ] + remoting_version_files + ar_webapp_files + + outputs = [ + "$target_gen_dir/$zip_path", + ] + + deps = [ + ":$locales_listfile", + "//remoting/resources", + ] + + # Create a file that contains a list of all the resource files needed + # to build the webapp. This is needed to avoid problems on platforms that + # limit the size of a command line. + file_list = "$target_gen_dir/${target_name}_files.txt" + files = [] + files += rebase_path(ar_webapp_files, root_build_dir) + write_file(file_list, files) + + args = [ + buildtype, + version_full, + output_dir, + zip_path, + rebase_path(ar_app_manifest, root_build_dir), + "app_remoting", # Web app type + ] + args += [ + "--files_listfile", + rebase_path(file_list, root_build_dir), + ] + args += [ + "--locales_listfile", + rebase_path(locales_listfile_output, root_build_dir), + ] + args += [ + "--jinja_paths", + rebase_path("//remoting/webapp/app_remoting", root_build_dir), + ] + + if (is_debug) { + # Normally, the app-id for the orchestrator is automatically extracted + # from the webapp's extension id, but that approach doesn't work for + # dev webapp builds (since they all share the same dev extension id). + # The --appid arg will create a webapp that registers the given app-id + # rather than using the extension id. + # This is only done for Dev apps because the app-id for Release apps + # *must* match the extension id. + args += [ + "--appid", + app_id, + ] + } + + args += [ + "--app_name", + app_fullname, + ] + args += [ + "--app_description", + app_description, + ] + args += [ "--app_capabilities" ] + app_capabilities + args += [ + "--service_environment", + ar_service_environment, + ] + args += [ + "--manifest_key", + manifest_key, + ] + args += [ + "--app_client_id", + app_client_id, + ] + } +} + +template("app_remoting_shared_module") { + locales_listfile = target_name + "_locales" + locales_listfile_output = "$target_gen_dir/${target_name}_locales.txt" + + build_locales_listfile(locales_listfile) { # Template uses locales_listfile_output from outer scope. } @@ -275,6 +407,17 @@ template("app_remoting_webapp") { html_output = wcs_sandbox_html_output } + background_html = target_name + "_background_html" + background_html_output = + "$target_gen_dir/html/$target_name/ar_background.html" + + build_webapp_html(background_html) { + html_template_file = ar_background_template + html_template_include_files = [] + js_files = ar_background_html_js_files + html_output = background_html_output + } + main_html = target_name + "_main_html" main_html_output = "$target_gen_dir/html/$target_name/main.html" @@ -288,37 +431,20 @@ template("app_remoting_webapp") { action(target_name) { script = "build-webapp.py" - app_key = invoker.app_key - app_id = invoker.app_id app_client_id = invoker.app_client_id app_name = invoker.app_name + app_fullname = invoker.app_fullname app_description = invoker.app_description - app_capabilities = invoker.app_capabilities manifest_key = invoker.manifest_key - # These asserts are so that these variables get marked as being used so - # that GN doesn't complain about them. - assert(app_key != "" || app_key == "") - assert(app_id != "" || app_id == "") - - # TODO(garykac) For internal targets, we need to extract the vendor and app - # name from the target. - ar_app_name = "sample_app" #target_name - ar_app_path = "app_remoting/apps/$ar_app_name" - ar_app_manifest = "$ar_app_path/manifest.json.jinja2" - ar_app_manifest_common = "app_remoting/manifest_common.json.jinja2" + ar_path = "app_remoting/$app_name" + ar_manifest = "$ar_path/manifest.json" - output_dir = "remoting/app_remoting/$ar_service_environment/$target_name" - zip_path = "remoting/app_remoting/$ar_service_environment/$target_name.zip" - - ar_app_specific_files = [ - "$ar_app_path/icon16.png", - "$ar_app_path/icon48.png", - "$ar_app_path/icon128.png", - "$ar_app_path/loading_splash.png", - ] + output_dir = "remoting/app_remoting/$target_name" + zip_path = "remoting/app_remoting/$target_name.zip" ar_generated_html_files = [ + background_html_output, feedback_consent_html_output, loading_window_html_output, message_window_html_output, @@ -327,12 +453,10 @@ template("app_remoting_webapp") { ] ar_webapp_files = - ar_app_specific_files + ar_shared_resource_files + ar_all_js_files + ar_shared_resource_files + ar_all_js_files + ar_generated_html_files - inputs = [ - rebase_path(ar_app_manifest, root_build_dir), - rebase_path(ar_app_manifest_common, root_build_dir), - ] + remoting_version_files + ar_webapp_files + inputs = [ rebase_path(ar_manifest, root_build_dir) ] + + remoting_version_files + ar_webapp_files outputs = [ "$target_gen_dir/$zip_path", @@ -353,7 +477,6 @@ template("app_remoting_webapp") { # limit the size of a command line. file_list = "$target_gen_dir/${target_name}_files.txt" files = [] - files += rebase_path(ar_generated_html_files, root_build_dir) files += rebase_path(ar_webapp_files, root_build_dir) write_file(file_list, files) @@ -362,8 +485,8 @@ template("app_remoting_webapp") { version_full, output_dir, zip_path, - rebase_path(ar_app_manifest, root_build_dir), - "app_remoting", # Web app type + rebase_path(ar_manifest, root_build_dir), + "shared_module", # Web app type ] args += [ "--files_listfile", @@ -373,38 +496,15 @@ template("app_remoting_webapp") { "--locales_listfile", rebase_path(locales_listfile_output, root_build_dir), ] - args += [ - "--jinja_paths", - rebase_path("app_remoting", root_build_dir), - ] - - if (is_debug) { - # Normally, the app-id for the orchestrator is automatically extracted - # from the webapp's extension id, but that approach doesn't work for - # dev webapp builds (since they all share the same dev extension id). - # The --appid arg will create a webapp that registers the given app-id - # rather than using the extension id. - # This is only done for Dev apps because the app-id for Release apps - # *must* match the extension id. - args += [ - "--appid", - app_id, - ] - } args += [ "--app_name", - app_name, + app_fullname, ] args += [ "--app_description", app_description, ] - args += [ "--app_capabilities" ] + app_capabilities - args += [ - "--service_environment", - ar_service_environment, - ] args += [ "--manifest_key", manifest_key, diff --git a/remoting/webapp/crd/js/desktop_remoting.js b/remoting/webapp/crd/js/desktop_remoting.js index 965dc93..09bb38e 100644 --- a/remoting/webapp/crd/js/desktop_remoting.js +++ b/remoting/webapp/crd/js/desktop_remoting.js @@ -48,6 +48,15 @@ remoting.DesktopRemoting.prototype.getConnectionMode = function() { }; /** + * @return {string} Application Id. + * @override {remoting.ApplicationInterface} + */ +remoting.DesktopRemoting.prototype.getApplicationId = function() { + // Application IDs are not used in desktop remoting. + return ''; +}; + +/** * @return {string} Application product name to be used in UI. * @override {remoting.ApplicationInterface} */ diff --git a/remoting/webapp/crd/js/desktop_remoting_activity.js b/remoting/webapp/crd/js/desktop_remoting_activity.js index 3f7a723..9d32caa 100644 --- a/remoting/webapp/crd/js/desktop_remoting_activity.js +++ b/remoting/webapp/crd/js/desktop_remoting_activity.js @@ -28,7 +28,7 @@ remoting.DesktopRemotingActivity = function(parentActivity) { /** @private */ this.sessionFactory_ = new remoting.ClientSessionFactory( document.querySelector('#client-container .client-plugin-container'), - remoting.app_capabilities()); + [/* No special capabilities required. */]); /** @private {remoting.ClientSession} */ this.session_ = null; diff --git a/remoting/webapp/files.gni b/remoting/webapp/files.gni index 7e77289..2b4e66b 100644 --- a/remoting/webapp/files.gni +++ b/remoting/webapp/files.gni @@ -164,7 +164,6 @@ remoting_webapp_shared_js_client_files = [ # Remoting core JavaScript files. remoting_webapp_shared_js_core_files = [ - "base/js/app_capabilities.js", "base/js/application.js", "base/js/base.js", "base/js/ipc.js", @@ -539,7 +538,6 @@ ar_main_js_files = [ "app_remoting/js/app_remoting.js", "app_remoting/js/app_remoting_activity.js", "app_remoting/js/ar_auth_dialog.js", - "app_remoting/js/ar_main.js", "app_remoting/js/context_menu_adapter.js", "app_remoting/js/context_menu_chrome.js", "app_remoting/js/context_menu_dom.js", @@ -551,8 +549,6 @@ ar_main_js_files = [ "app_remoting/js/loading_window.js", "app_remoting/js/submenu_manager.js", "app_remoting/js/window_activation_menu.js", - "base/js/application.js", - "base/js/base.js", "base/js/message_window_helper.js", "base/js/message_window_manager.js", ] + remoting_webapp_shared_js_auth_google_files + @@ -596,19 +592,33 @@ ar_feedback_consent_html_all_js_files = [ ar_loading_window_template = "app_remoting/html/template_loading_window.html" # -# AppRemoting background JS files. -# These files are referenced from the manifest +# AppRemoting ar_background.html generation files. # -ar_background_js_files = [ +ar_background_template = "app_remoting/html/template_background.html" +ar_background_html_js_files = [ "app_remoting/js/ar_background.js", "base/js/platform.js", ] +# +# Vendor supplied files. +# These need a full path specification because they are referenced from the +# webapp directory (ar_sample_app) and from the internal app directory. +# + +ar_vendor_js_files = [ "//remoting/webapp/app_remoting/vendor/arv_main.js" ] + +ar_vendor_html_files = [ + "//remoting/webapp/app_remoting/vendor/arv_background.html", + "//remoting/webapp/app_remoting/vendor/arv_main.html", + "//remoting/webapp/app_remoting/vendor/arv_wcs_sandbox.html", +] + ar_all_js_files = ar_main_js_files + ar_feedback_consent_html_js_files + remoting_webapp_message_window_html_js_files + - remoting_webapp_wcs_sandbox_html_js_files + ar_background_js_files + remoting_webapp_wcs_sandbox_html_js_files + ar_background_html_js_files # Files that contain localizable strings. app_remoting_webapp_localizable_files = |