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'; |
11 | 11 |
12 <include src="../gaia_auth/channel.js"> | 12 <include src="../gaia_auth/channel.js"> |
13 | 13 |
14 var PostMessageChannel = (function() { | 14 var PostMessageChannel = (function() { |
15 /** | 15 /** |
16 * Allowed origins of the hosting page. | 16 * Allowed origins of the hosting page. |
17 * @type {Array.<string>} | 17 * @type {Array<string>} |
18 */ | 18 */ |
19 var ALLOWED_ORIGINS = [ | 19 var ALLOWED_ORIGINS = [ |
20 'chrome://oobe', | 20 'chrome://oobe', |
21 'chrome://chrome-signin' | 21 'chrome://chrome-signin' |
22 ]; | 22 ]; |
23 | 23 |
24 /** @const */ | 24 /** @const */ |
25 var PORT_MESSAGE = 'post-message-port-message'; | 25 var PORT_MESSAGE = 'post-message-port-message'; |
26 | 26 |
27 /** @const */ | 27 /** @const */ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 /** | 71 /** |
72 * Window and origin to forward message up the hierarchy. For subframes, | 72 * Window and origin to forward message up the hierarchy. For subframes, |
73 * they defaults to window.parent and any origin. For top level window, | 73 * they defaults to window.parent and any origin. For top level window, |
74 * this would be set to the hosting webview on CHANNEL_INIT_MESSAGE. | 74 * this would be set to the hosting webview on CHANNEL_INIT_MESSAGE. |
75 */ | 75 */ |
76 this.upperWindow = isTopLevel() ? null : window.parent; | 76 this.upperWindow = isTopLevel() ? null : window.parent; |
77 this.upperOrigin = isTopLevel() ? '' : '*'; | 77 this.upperOrigin = isTopLevel() ? '' : '*'; |
78 | 78 |
79 /** | 79 /** |
80 * Channle Id to port map. | 80 * Channle Id to port map. |
81 * @type {Object.<number, PostMessagePort>} | 81 * @type {Object<number, PostMessagePort>} |
82 */ | 82 */ |
83 this.channels_ = {}; | 83 this.channels_ = {}; |
84 | 84 |
85 /** | 85 /** |
86 * Deferred messages to be posted to |upperWindow|. | 86 * Deferred messages to be posted to |upperWindow|. |
87 * @type {Array} | 87 * @type {Array} |
88 */ | 88 */ |
89 this.deferredUpperWindowMessages_ = []; | 89 this.deferredUpperWindowMessages_ = []; |
90 | 90 |
91 /** | 91 /** |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 channelManager.onConnect.addListener(onConnect); | 363 channelManager.onConnect.addListener(onConnect); |
364 }; | 364 }; |
365 | 365 |
366 return PostMessageChannel; | 366 return PostMessageChannel; |
367 })(); | 367 })(); |
368 | 368 |
369 /** @override */ | 369 /** @override */ |
370 Channel.create = function() { | 370 Channel.create = function() { |
371 return new PostMessageChannel(); | 371 return new PostMessageChannel(); |
372 }; | 372 }; |
OLD | NEW |