OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * | 7 * |
8 * It2MeHelpeeChannel relays messages between the Hangouts web page (Hangouts) | 8 * It2MeHelpeeChannel relays messages between the Hangouts web page (Hangouts) |
9 * and the It2Me Native Messaging Host (It2MeHost) for the helpee (the Hangouts | 9 * and the It2Me Native Messaging Host (It2MeHost) for the helpee (the Hangouts |
10 * participant who is receiving remoting assistance). | 10 * participant who is receiving remoting assistance). |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 /** | 273 /** |
274 * Prompts the user before starting the It2Me Native Messaging Host. This | 274 * Prompts the user before starting the It2Me Native Messaging Host. This |
275 * ensures that even if Hangouts is compromised, an attacker cannot start the | 275 * ensures that even if Hangouts is compromised, an attacker cannot start the |
276 * host without explicit user confirmation. | 276 * host without explicit user confirmation. |
277 * | 277 * |
278 * @return {Promise} A promise that resolves when the user clicks accept on the | 278 * @return {Promise} A promise that resolves when the user clicks accept on the |
279 * dialog. | 279 * dialog. |
280 * @private | 280 * @private |
281 */ | 281 */ |
282 remoting.It2MeHelpeeChannel.prototype.showConfirmDialog_ = function() { | 282 remoting.It2MeHelpeeChannel.prototype.showConfirmDialog_ = function() { |
283 /** | 283 var message = l10n.getTranslationOrError( |
284 * @param {function(*=):void} resolve | 284 /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_MESSAGE'); |
285 * @param {function(*=):void} reject | 285 |
286 */ | 286 if (base.isAppsV2()) { |
287 return new Promise(function(resolve, reject) { | 287 /** |
288 // TODO(kelvinp): The existing implementation doesn't work in the v2 app as | 288 * @param {function(*=):void} resolve |
289 // window.confirm is blacklisted. Implement the dialog using | 289 * @param {function(*=):void} reject |
290 // chrome.app.window instead (crbug.com/405139). | 290 */ |
291 if (base.isAppsV2()) { | 291 return new Promise(function(resolve, reject) { |
292 resolve(); | 292 /** @param {number} result */ |
293 // The unlocalized string will be replaced in (crbug.com/405139). | 293 function confirmDialogCallback(result) { |
294 } else if (window.confirm('Accept help?')) { | 294 if (result === 1) { |
295 resolve(); | 295 resolve(); |
296 } else { | 296 } else { |
297 reject(new Error(remoting.Error.CANCELLED)); | 297 reject(new Error(remoting.Error.CANCELLED)); |
298 } | 298 } |
299 }); | 299 } |
| 300 |
| 301 remoting.MessageWindow.showConfirmWindow( |
| 302 '', // Empty string to use the package name as the dialog title. |
| 303 message, |
| 304 l10n.getTranslationOrError( |
| 305 /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_ACCEPT'), |
| 306 l10n.getTranslationOrError( |
| 307 /*i18n-content*/'HANGOUTS_CONFIRM_DIALOG_DECLINE'), |
| 308 confirmDialogCallback |
| 309 ); |
| 310 }); |
| 311 } else if (window.confirm(message)) { |
| 312 return Promise.resolve(); |
| 313 } else { |
| 314 return Promise.reject(new Error(remoting.Error.CANCELLED)); |
| 315 } |
300 }; | 316 }; |
301 | 317 |
302 /** | 318 /** |
303 * @return {Promise} A promise that resolves when the host is initialized. | 319 * @return {Promise} A promise that resolves when the host is initialized. |
304 * @private | 320 * @private |
305 */ | 321 */ |
306 remoting.It2MeHelpeeChannel.prototype.initializeHost_ = function() { | 322 remoting.It2MeHelpeeChannel.prototype.initializeHost_ = function() { |
307 /** @type {remoting.It2MeHostFacade} */ | 323 /** @type {remoting.It2MeHostFacade} */ |
308 var host = this.host_; | 324 var host = this.host_; |
309 | 325 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 435 |
420 console.error('Error responding to message method:' + | 436 console.error('Error responding to message method:' + |
421 (incomingMessage ? incomingMessage.method : 'null') + | 437 (incomingMessage ? incomingMessage.method : 'null') + |
422 ' error:' + error); | 438 ' error:' + error); |
423 this.hangoutPort_.postMessage({ | 439 this.hangoutPort_.postMessage({ |
424 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.ERROR, | 440 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.ERROR, |
425 message: error, | 441 message: error, |
426 request: incomingMessage | 442 request: incomingMessage |
427 }); | 443 }); |
428 }; | 444 }; |
OLD | NEW |