| 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 Tools for interframe communication. To use this class, every | 6 * @fileoverview Tools for interframe communication. To use this class, every |
| 7 * window that wants to communicate with its child iframes should enumerate | 7 * window that wants to communicate with its child iframes should enumerate |
| 8 * them using document.getElementsByTagName('iframe'), create an ID to | 8 * them using document.getElementsByTagName('iframe'), create an ID to |
| 9 * associate with that iframe, then call cvox.Interframe.sendIdToIFrame | 9 * associate with that iframe, then call cvox.Interframe.sendIdToIFrame |
| 10 * on each of them. Then use cvox.Interframe.sendMessageToIFrame to send | 10 * on each of them. Then use cvox.Interframe.sendMessageToIFrame to send |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * The ID of this window (relative to its parent farme). | 52 * The ID of this window (relative to its parent farme). |
| 53 * @type {number|string|undefined} | 53 * @type {number|string|undefined} |
| 54 */ | 54 */ |
| 55 cvox.Interframe.id; | 55 cvox.Interframe.id; |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Array of functions that have been registered as listeners to interframe | 58 * Array of functions that have been registered as listeners to interframe |
| 59 * messages send to this window. | 59 * messages send to this window. |
| 60 * @type {Array.<function(Object)>} | 60 * @type {Array<function(Object)>} |
| 61 */ | 61 */ |
| 62 cvox.Interframe.listeners = []; | 62 cvox.Interframe.listeners = []; |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Maps an id to a function which gets called when a frame first sends an ack | 65 * Maps an id to a function which gets called when a frame first sends an ack |
| 66 * for a set id msg. | 66 * for a set id msg. |
| 67 @dict {!Object.<number|string, function()>} | 67 @dict {!Object<number|string, function()>} |
| 68 * @private | 68 * @private |
| 69 */ | 69 */ |
| 70 cvox.Interframe.idToCallback_ = {}; | 70 cvox.Interframe.idToCallback_ = {}; |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * Flag for unit testing. When false, skips over iframe.contentWindow check | 73 * Flag for unit testing. When false, skips over iframe.contentWindow check |
| 74 * in sendMessageToIframe. This is needed because in the wild, ChromeVox may | 74 * in sendMessageToIframe. This is needed because in the wild, ChromeVox may |
| 75 * not have access to iframe.contentWindow due to the same-origin security | 75 * not have access to iframe.contentWindow due to the same-origin security |
| 76 * policy. There is no reason to set this outside of a test. | 76 * policy. There is no reason to set this outside of a test. |
| 77 * @type {boolean} | 77 * @type {boolean} |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 /** | 232 /** |
| 233 * Returns true if inside iframe | 233 * Returns true if inside iframe |
| 234 * @return {boolean} true if inside iframe. | 234 * @return {boolean} true if inside iframe. |
| 235 */ | 235 */ |
| 236 cvox.Interframe.isIframe = function() { | 236 cvox.Interframe.isIframe = function() { |
| 237 return (window != window.parent); | 237 return (window != window.parent); |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 cvox.Interframe.init(); | 240 cvox.Interframe.init(); |
| OLD | NEW |