Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_command.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_command.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_command.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..39093fc10ecf012d07869d3dabea9bd19ca218ff |
| --- /dev/null |
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel_command.js |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @fileoverview Commands to pass from the ChromeVox background page context |
| + * to the ChromeVox Panel. |
| + */ |
| + |
| +goog.provide('PanelCommand'); |
| +goog.provide('PanelCommandType'); |
| + |
| +/** |
| + * Create one command to pass to the ChromeVox Panel. |
| + * @param {PanelCommandType} type The type of command. |
| + * @param {string|ArrayBuffer|{text: string, braille: string}=} opt_data |
|
Peter Lundblad
2015/11/10 10:46:36
Remove the ArrayBuffer. Not needed, and wouldn't b
dmazzoni
2015/11/10 17:33:17
Done.
|
| + * Optional data associated with the command. |
| + * @constructor |
| + */ |
| +PanelCommand = function(type, opt_data) { |
| + this.type = type; |
| + this.data = opt_data; |
| +}; |
| + |
| +/** |
| + * Send this command to the ChromeVox Panel window. |
| + */ |
| +PanelCommand.prototype.send = function() { |
| + var views = chrome.extension.getViews(); |
| + for (var i = 0; i < views.length; i++) { |
| + if (views[i].location.href.indexOf('background/panel.html') > 0) { |
| + views[i].postMessage(JSON.stringify(this), window.location.origin); |
| + } |
| + } |
| +}; |
| + |
| +/** |
| + * Possible panel commands. |
| + * @enum {string} |
| + */ |
| +PanelCommandType = { |
| + CLEAR_SPEECH: 'clear_speech', |
| + ADD_NORMAL_SPEECH: 'add_normal_speech', |
| + ADD_ANNOTATION_SPEECH: 'add_annotation_speech', |
| + UPDATE_BRAILLE: 'update_braille', |
| +}; |