OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @fileoverview Commands to pass to the ChromeVox Panel. | |
David Tseng
2015/08/07 21:43:03
From? To?
dmazzoni
2015/11/05 23:59:41
Done.
| |
7 */ | |
8 | |
9 goog.provide('cvox.PanelCommand'); | |
10 goog.provide('cvox.PanelCommandType'); | |
11 | |
12 /** | |
13 * Create one command to pass to the ChromeVox Panel. | |
14 * @param {cvox.PanelCommandType} type The type of command. | |
15 * @param {string|ArrayBuffer=} opt_data | |
16 * Optional data associated with the command. | |
17 * @constructor | |
18 */ | |
19 cvox.PanelCommand = function(type, opt_data) { | |
20 this.type = type; | |
21 this.data = opt_data; | |
22 }; | |
23 | |
24 /** | |
25 * Send this command to the ChromeVox Panel window. | |
26 */ | |
27 cvox.PanelCommand.prototype.send = function() { | |
28 var views = chrome.extension.getViews(); | |
29 for (var i = 0; i < views.length; i++) { | |
30 if (views[i].location.href.indexOf('background/panel.html') > 0) { | |
31 console.log('Posting to panel: ' + JSON.stringify(this)); | |
David Tseng
2015/08/07 21:43:03
nit: remove
dmazzoni
2015/11/05 23:59:41
Done.
| |
32 views[i].postMessage(JSON.stringify(this), window.location.origin); | |
33 } | |
34 } | |
35 }; | |
36 | |
37 /** | |
38 * Possible panel commands. | |
39 * @enum {string} | |
40 */ | |
41 cvox.PanelCommandType = { | |
42 CLEAR_SPEECH: 'clear_speech', | |
43 ADD_NORMAL_SPEECH: 'add_normal_speech', | |
44 ADD_ANNOTATION_SPEECH: 'add_annotation_speech', | |
45 UPDATE_BRAILLE_TEXT: 'update_braille_text', | |
46 UPDATE_BRAILLE_CELLS: 'update_braille_cells' | |
47 }; | |
OLD | NEW |