Commit 1f67ef5a authored by garykac's avatar garykac Committed by Commit bot

[Chromoting] Enable jscompile for AppRemoting's feedback_consent page.

The cl does 4 things:
(1) Adds a list (in gyp) for the feedback_consent js files.
(2) Uses build-html.py to build feedback_consent.html from a template.
(3) Adds an action to run jscompile over the feedback_consent js files.
(4) Fixes the errors/warnings reported by jscompile.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#318822}
parent fb1d7742
...@@ -62,6 +62,29 @@ ...@@ -62,6 +62,29 @@
'<@(remoting_webapp_js_proto_files)', '<@(remoting_webapp_js_proto_files)',
], ],
}, },
{
'action_name': 'Verify >(ar_app_name) feedback_consent.html',
'variables': {
'success_stamp': '<(PRODUCT_DIR)/>(_target_name)_feedback_consent_jscompile.stamp',
},
'inputs': [
'<@(ar_feedback_consent_js_files)',
'<@(remoting_webapp_js_proto_files)',
# Include zip as input so that this action is run after the build.
'<(zip_path)',
],
'outputs': [
'<(success_stamp)',
],
'action': [
'python', '../third_party/closure_compiler/checker.py',
'--strict',
'--no-single-file',
'--success-stamp', '<(success_stamp)',
'<@(ar_feedback_consent_js_files)',
'<@(remoting_webapp_js_proto_files)',
],
},
], # actions ], # actions
}], }],
], # conditions ], # conditions
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
'ar_generated_html_files': [ 'ar_generated_html_files': [
'<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/main.html', '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/main.html',
'<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/wcs_sandbox.html', '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/wcs_sandbox.html',
'<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/feedback_consent.html',
], ],
'ar_webapp_files': [ 'ar_webapp_files': [
'<@(ar_app_specific_files)', '<@(ar_app_specific_files)',
...@@ -189,6 +190,28 @@ ...@@ -189,6 +190,28 @@
'<@(remoting_webapp_wcs_sandbox_html_js_files)', '<@(remoting_webapp_wcs_sandbox_html_js_files)',
], ],
}, },
{
'action_name': 'Build ">(ar_app_name)" feedback_consent.html',
'inputs': [
'<(DEPTH)/remoting/webapp/build-html.py',
'<(ar_feedback_consent_template)',
'<@(ar_feedback_consent_template_files)',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/feedback_consent.html',
],
'action': [
'python', '<(DEPTH)/remoting/webapp/build-html.py',
'<(SHARED_INTERMEDIATE_DIR)/>(_target_name)/feedback_consent.html',
'<(ar_feedback_consent_template)',
'--template-dir',
'<(DEPTH)/remoting',
'--templates',
'<@(ar_feedback_consent_template_files)',
'--js',
'<@(ar_feedback_consent_js_files)',
],
},
], # actions ], # actions
'conditions': [ 'conditions': [
['buildtype == "Dev"', { ['buildtype == "Dev"', {
......
...@@ -7,12 +7,27 @@ ...@@ -7,12 +7,27 @@
'ar_shared_resource_files': [ 'ar_shared_resource_files': [
'webapp/app_remoting/html/ar_dialog.css', 'webapp/app_remoting/html/ar_dialog.css',
'webapp/app_remoting/html/feedback_consent.css', 'webapp/app_remoting/html/feedback_consent.css',
'webapp/app_remoting/html/feedback_consent.html',
'webapp/app_remoting/html/context_menu.css', 'webapp/app_remoting/html/context_menu.css',
'resources/drag.webp', 'resources/drag.webp',
'<@(remoting_webapp_resource_files)', '<@(remoting_webapp_resource_files)',
], ],
# Variables for feedback_consent.html.
'ar_feedback_consent_template':
'<(DEPTH)/remoting/webapp/app_remoting/html/template_feedback_consent.html',
'ar_feedback_consent_template_files': [
],
'ar_feedback_consent_js_files': [
'webapp/app_remoting/js/feedback_consent.js',
'webapp/base/js/base.js',
'webapp/crd/js/error.js',
'webapp/crd/js/oauth2_api.js',
'webapp/crd/js/oauth2_api_impl.js',
'webapp/crd/js/plugin_settings.js',
'webapp/crd/js/l10n.js',
'webapp/crd/js/xhr.js',
],
# Variables for main.html. # Variables for main.html.
# These template files are used to construct the webapp html files. # These template files are used to construct the webapp html files.
'ar_main_template': 'ar_main_template':
...@@ -74,7 +89,7 @@ ...@@ -74,7 +89,7 @@
'app_remoting_webapp_localizable_files': [ 'app_remoting_webapp_localizable_files': [
'<(ar_main_template)', '<(ar_main_template)',
'<@(ar_main_template_files)', '<@(ar_main_template_files)',
'webapp/app_remoting/html/feedback_consent.html', '<(ar_feedback_consent_template)',
'<@(ar_all_js_files)', '<@(ar_all_js_files)',
], ],
......
...@@ -13,13 +13,9 @@ found in the LICENSE file. ...@@ -13,13 +13,9 @@ found in the LICENSE file.
<link rel="stylesheet" href="feedback_consent.css"> <link rel="stylesheet" href="feedback_consent.css">
<link rel="stylesheet" href="main.css"> <link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="message_window.css"> <link rel="stylesheet" href="message_window.css">
<script src="base.js"></script>
<script src="error.js"></script> <meta-include type="javascript"/>
<script src="feedback_consent.js"></script>
<script src="oauth2_api_impl.js"></script>
<script src="plugin_settings.js"></script>
<script src="l10n.js"></script>
<script src="xhr.js"></script>
<title i18n-content="FEEDBACK_CONSENT_TITLE"></title> <title i18n-content="FEEDBACK_CONSENT_TITLE"></title>
</head> </head>
<body> <body>
......
...@@ -15,7 +15,7 @@ var hostId = '@pending'; ...@@ -15,7 +15,7 @@ var hostId = '@pending';
* @type {string} The network stats at the time the feedback consent dialog * @type {string} The network stats at the time the feedback consent dialog
* was shown. * was shown.
*/ */
var connectionStats = null; var connectionStats = '';
/** /**
* @type {string} "no" => user did not request a VM reset; "yes" => VM was * @type {string} "no" => user did not request a VM reset; "yes" => VM was
...@@ -102,8 +102,8 @@ function showError() { ...@@ -102,8 +102,8 @@ function showError() {
*/ */
function generateId() { function generateId() {
var idArray = new Uint8Array(20); var idArray = new Uint8Array(20);
crypto.getRandomValues(idArray); window.crypto.getRandomValues(idArray);
return btoa(String.fromCharCode.apply(null, idArray)); return window.btoa(String.fromCharCode.apply(null, idArray));
} }
/** /**
...@@ -123,10 +123,6 @@ function onToken(token) { ...@@ -123,10 +123,6 @@ function onToken(token) {
'abandonHost': 'true', 'abandonHost': 'true',
'crashServiceReportId': crashServiceReportId 'crashServiceReportId': crashServiceReportId
}; };
var headers = {
'Authorization': 'OAuth ' + token,
'Content-type': 'application/json'
};
var uri = remoting.settings.APP_REMOTING_API_BASE_URL + var uri = remoting.settings.APP_REMOTING_API_BASE_URL +
'/applications/' + remoting.settings.getAppRemotingApplicationId() + '/applications/' + remoting.settings.getAppRemotingApplicationId() +
'/hosts/' + hostId + '/hosts/' + hostId +
...@@ -139,7 +135,13 @@ function onToken(token) { ...@@ -139,7 +135,13 @@ function onToken(token) {
showError(); showError();
} }
}; };
remoting.xhr.post(uri, onDone, JSON.stringify(body), headers); remoting.xhr.start({
method: 'POST',
url: uri,
onDone: onDone,
jsonContent: body,
oauthToken: token
});
} else { } else {
getUserInfo(); getUserInfo();
} }
...@@ -184,6 +186,7 @@ function onToggleLogs() { ...@@ -184,6 +186,7 @@ function onToggleLogs() {
} }
} }
/** @param {Event} event */
function onLearnMore(event) { function onLearnMore(event) {
event.preventDefault(); // Clicking the link should not tick the checkbox. event.preventDefault(); // Clicking the link should not tick the checkbox.
var learnMoreLink = document.getElementById('learn-more'); var learnMoreLink = document.getElementById('learn-more');
......
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