| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * Provides a HTML5 postMessage channel to the injected JS to talk back | 7 * Provides a HTML5 postMessage channel to the injected JS to talk back |
| 8 * to Authenticator. | 8 * to Authenticator. |
| 9 */ | 9 */ |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 * @param {string} name | 275 * @param {string} name |
| 276 */ | 276 */ |
| 277 function PostMessagePort(channelId, name) { | 277 function PostMessagePort(channelId, name) { |
| 278 this.channelId = channelId; | 278 this.channelId = channelId; |
| 279 this.name = name; | 279 this.name = name; |
| 280 this.targetWindow = null; | 280 this.targetWindow = null; |
| 281 this.targetOrigin = ''; | 281 this.targetOrigin = ''; |
| 282 this.deferredMessages_ = []; | 282 this.deferredMessages_ = []; |
| 283 | 283 |
| 284 this.onMessage = new EventTarget(); | 284 this.onMessage = new EventTarget(); |
| 285 }; | 285 } |
| 286 | 286 |
| 287 PostMessagePort.prototype = { | 287 PostMessagePort.prototype = { |
| 288 /** | 288 /** |
| 289 * Sets the target window and origin. | 289 * Sets the target window and origin. |
| 290 * @param {DOMWindow} targetWindow | 290 * @param {DOMWindow} targetWindow |
| 291 * @param {string} targetOrigin | 291 * @param {string} targetOrigin |
| 292 */ | 292 */ |
| 293 setTarget: function(targetWindow, targetOrigin) { | 293 setTarget: function(targetWindow, targetOrigin) { |
| 294 this.targetWindow = targetWindow; | 294 this.targetWindow = targetWindow; |
| 295 this.targetOrigin = targetOrigin; | 295 this.targetOrigin = targetOrigin; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 318 } | 318 } |
| 319 }; | 319 }; |
| 320 | 320 |
| 321 /** | 321 /** |
| 322 * A message channel based on PostMessagePort. | 322 * A message channel based on PostMessagePort. |
| 323 * @extends {Channel} | 323 * @extends {Channel} |
| 324 * @constructor | 324 * @constructor |
| 325 */ | 325 */ |
| 326 function PostMessageChannel() { | 326 function PostMessageChannel() { |
| 327 Channel.apply(this, arguments); | 327 Channel.apply(this, arguments); |
| 328 }; | 328 } |
| 329 | 329 |
| 330 PostMessageChannel.prototype = { | 330 PostMessageChannel.prototype = { |
| 331 __proto__: Channel.prototype, | 331 __proto__: Channel.prototype, |
| 332 | 332 |
| 333 /** @override */ | 333 /** @override */ |
| 334 connect: function(name) { | 334 connect: function(name) { |
| 335 this.port_ = channelManager.connectToDaemon(name); | 335 this.port_ = channelManager.connectToDaemon(name); |
| 336 this.port_.onMessage.addListener(this.onMessage_.bind(this)); | 336 this.port_.onMessage.addListener(this.onMessage_.bind(this)); |
| 337 }, | 337 }, |
| 338 }; | 338 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 364 channelManager.onConnect.addListener(onConnect); | 364 channelManager.onConnect.addListener(onConnect); |
| 365 }; | 365 }; |
| 366 | 366 |
| 367 return PostMessageChannel; | 367 return PostMessageChannel; |
| 368 })(); | 368 })(); |
| 369 | 369 |
| 370 /** @override */ | 370 /** @override */ |
| 371 Channel.create = function() { | 371 Channel.create = function() { |
| 372 return new PostMessageChannel(); | 372 return new PostMessageChannel(); |
| 373 }; | 373 }; |
| OLD | NEW |