Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: remoting/webapp/background/it2me_helpee_channel.js

Issue 503063004: Hangouts Remote Desktop Part VI - Show confirm dialog before retrieving access code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/resources/remoting_strings.grd ('k') | remoting/webapp/background/message_window.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/background/it2me_helpee_channel.js
diff --git a/remoting/webapp/background/it2me_helpee_channel.js b/remoting/webapp/background/it2me_helpee_channel.js
index 94001883bbbbed43d4b417d0d03214d8e3ef916d..b53f79858fc635d9bdff346bd190046cfc9bd857 100644
--- a/remoting/webapp/background/it2me_helpee_channel.js
+++ b/remoting/webapp/background/it2me_helpee_channel.js
@@ -275,27 +275,80 @@ remoting.It2MeHelpeeChannel.prototype.handleConnect_ =
* ensures that even if Hangouts is compromised, an attacker cannot start the
* host without explicit user confirmation.
*
- * @return {Promise} A promise that resolves when the user clicks accept on the
- * dialog.
+ * @return {Promise} A promise that resolves to a boolean value, indicating
+ * whether the user accepts the remote assistance or not.
* @private
*/
remoting.It2MeHelpeeChannel.prototype.showConfirmDialog_ = function() {
+ if (base.isAppsV2()) {
+ return this.showConfirmDialogV2_();
+ } else {
+ return this.showConfirmDialogV1_();
+ }
+};
+
+/**
+ * @return {Promise} A promise that resolves to a boolean value, indicating
+ * whether the user accepts the remote assistance or not.
+ * @private
+ */
+remoting.It2MeHelpeeChannel.prototype.showConfirmDialogV1_ = function() {
+ var messageHeader = l10n.getTranslationOrError(
+ /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_MESSAGE_1');
+ var message1 = l10n.getTranslationOrError(
+ /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_MESSAGE_2');
+ var message2 = l10n.getTranslationOrError(
+ /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_MESSAGE_3');
+ var message = base.escapeHTML(messageHeader) + '\n' +
+ '- ' + base.escapeHTML(message1) + '\n' +
+ '- ' + base.escapeHTML(message2) + '\n';
+
+ if(window.confirm(message)) {
+ return Promise.resolve();
+ } else {
+ return Promise.reject(new Error(remoting.Error.CANCELLED));
+ }
+};
+
+/**
+ * @return {Promise} A promise that resolves to a boolean value, indicating
+ * whether the user accepts the remote assistance or not.
+ * @private
+ */
+remoting.It2MeHelpeeChannel.prototype.showConfirmDialogV2_ = function() {
+ var messageHeader = l10n.getTranslationOrError(
+ /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_MESSAGE_1');
+ var message1 = l10n.getTranslationOrError(
+ /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_MESSAGE_2');
+ var message2 = l10n.getTranslationOrError(
+ /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_MESSAGE_3');
+ var message = '<div>' + base.escapeHTML(messageHeader) + '</div>' +
+ '<ul class="insetList">' +
+ '<li>' + base.escapeHTML(message1) + '</li>' +
+ '<li>' + base.escapeHTML(message2) + '</li>' +
+ '</ul>';
/**
* @param {function(*=):void} resolve
* @param {function(*=):void} reject
*/
return new Promise(function(resolve, reject) {
- // TODO(kelvinp): The existing implementation doesn't work in the v2 app as
- // window.confirm is blacklisted. Implement the dialog using
- // chrome.app.window instead (crbug.com/405139).
- if (base.isAppsV2()) {
- resolve();
- // The unlocalized string will be replaced in (crbug.com/405139).
- } else if (window.confirm('Accept help?')) {
- resolve();
- } else {
- reject(new Error(remoting.Error.CANCELLED));
+ /** @param {number} result */
+ function confirmDialogCallback(result) {
+ if (result === 1) {
+ resolve();
+ } else {
+ reject(new Error(remoting.Error.CANCELLED));
+ }
}
+ remoting.MessageWindow.showConfirmWindow(
+ '', // Empty string to use the package name as the dialog title.
+ message,
+ l10n.getTranslationOrError(
+ /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_ACCEPT'),
+ l10n.getTranslationOrError(
+ /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_DECLINE'),
+ confirmDialogCallback
+ );
});
};
« no previous file with comments | « remoting/resources/remoting_strings.grd ('k') | remoting/webapp/background/message_window.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698