| 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 Public APIs to enable web applications to communicate | 6 * @fileoverview Public APIs to enable web applications to communicate |
| 7 * with ChromeVox. | 7 * with ChromeVox. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 if (typeof(goog) != 'undefined' && goog.provide) { | 10 if (typeof(goog) != 'undefined' && goog.provide) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 */ | 73 */ |
| 74 function connect_() { | 74 function connect_() { |
| 75 if (channel) { | 75 if (channel) { |
| 76 // If there is already an existing channel, close the existing ports. | 76 // If there is already an existing channel, close the existing ports. |
| 77 channel.port1.close(); | 77 channel.port1.close(); |
| 78 channel.port2.close(); | 78 channel.port2.close(); |
| 79 channel = null; | 79 channel = null; |
| 80 } | 80 } |
| 81 | 81 |
| 82 channel = new MessageChannel(); | 82 channel = new MessageChannel(); |
| 83 window.postMessage(PORT_SETUP_MSG, [channel.port2], '*'); | 83 window.postMessage(PORT_SETUP_MSG, '*', [channel.port2]); |
| 84 channel.port1.onmessage = function(event) { | 84 channel.port1.onmessage = function(event) { |
| 85 if (event.data == DISCONNECT_MSG) { | 85 if (event.data == DISCONNECT_MSG) { |
| 86 channel = null; | 86 channel = null; |
| 87 } | 87 } |
| 88 try { | 88 try { |
| 89 var message = JSON.parse(event.data); | 89 var message = JSON.parse(event.data); |
| 90 if (message['id'] && callbackMap_[message['id']]) { | 90 if (message['id'] && callbackMap_[message['id']]) { |
| 91 callbackMap_[message['id']](message); | 91 callbackMap_[message['id']](message); |
| 92 delete callbackMap_[message['id']]; | 92 delete callbackMap_[message['id']]; |
| 93 } | 93 } |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 */ | 569 */ |
| 570 // TODO (clchen, deboer): Put NodeDescription into externs for developers | 570 // TODO (clchen, deboer): Put NodeDescription into externs for developers |
| 571 // building ChromeVox extensions. | 571 // building ChromeVox extensions. |
| 572 cvox.NodeDescription = function(context, text, userValue, annotation) { | 572 cvox.NodeDescription = function(context, text, userValue, annotation) { |
| 573 this.context = context ? context : ''; | 573 this.context = context ? context : ''; |
| 574 this.text = text ? text : ''; | 574 this.text = text ? text : ''; |
| 575 this.userValue = userValue ? userValue : ''; | 575 this.userValue = userValue ? userValue : ''; |
| 576 this.annotation = annotation ? annotation : ''; | 576 this.annotation = annotation ? annotation : ''; |
| 577 }; | 577 }; |
| 578 })(); | 578 })(); |
| OLD | NEW |