Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1838)

Unified Diff: chrome/browser/resources/access_chromevox/audio/common/local_earcons_manager.js

Issue 6254007: Adding ChromeVox as a component extensions (enabled only for ChromeOS, for no... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/access_chromevox/audio/common/local_earcons_manager.js
===================================================================
--- chrome/browser/resources/access_chromevox/audio/common/local_earcons_manager.js (revision 0)
+++ chrome/browser/resources/access_chromevox/audio/common/local_earcons_manager.js (revision 0)
@@ -0,0 +1,74 @@
+// Copyright (c) 2011 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 Bridge that sends earcon messages from content scripts or
+ * other pages to the main background page.
+ */
+
+goog.provide('cvox.LocalEarconsManager');
+
+goog.require('cvox.AbstractEarconsManager');
+
+/**
+ * @constructor
+ * @param {Array} earcons Array of earcon classes.
+ * @param {cvox.AbstractTtsManager} ttsManager A TTS provider.
+ * @extends {cvox.AbstractEarconsManager}
+ */
+cvox.LocalEarconsManager = function(earcons, ttsManager) {
+ //Inherit AbstractEarconsManager
+ cvox.AbstractEarconsManager.call(this);
+
+ this.earcons = earcons;
+ this.ttsManager = ttsManager;
+ this.currentEarcons = null;
+ this.currentEarconsIndex = -1;
+ this.nextEarcons(false);
+};
+goog.inherits(cvox.LocalEarconsManager, cvox.AbstractEarconsManager);
+
+/**
+ * @return {string} The human-readable name of this instance.
+ */
+cvox.LocalEarconsManager.prototype.getName = function() {
+ return 'LocalEarconsManager';
+};
+
+/**
+ * Plays the specified earcon.
+ * @param {number} earcon The index of the earcon to be played.
+ */
+cvox.LocalEarconsManager.prototype.playEarcon = function(earcon) {
+ cvox.LocalEarconsManager.superClass_.playEarcon.call(this, earcon);
+ if (!this.currentEarcons) {
+ return;
+ }
+ this.currentEarcons.playEarcon(earcon);
+};
+
+/**
+ * Switch to the next earcon set and optionally announce its name.
+ * If no earcon sets have been specified this function is a NOOP.
+ * @param {boolean} announce If true, will announce the name of the
+ * new earcon set.
+ */
+cvox.LocalEarconsManager.prototype.nextEarcons = function(announce) {
+ cvox.LocalEarconsManager.superClass_.nextEarcons.call(this, announce);
+ if (!this.earcons) {
+ return;
+ }
+ this.currentEarcons = null;
+ this.currentEarconsIndex =
+ (this.currentEarconsIndex + 1) % this.earcons.length;
+ try {
+ this.currentEarcons = new this.earcons[this.currentEarconsIndex];
+ console.log('Switching to earcons: ' + this.currentEarcons.getName());
+ if (announce) {
+ this.ttsManager.speak(this.currentEarcons.getName());
+ }
+ } catch (err) {
+ console.log('error switching to earcon #' + this.currentEarconsIndex);
+ }
+};
Property changes on: chrome/browser/resources/access_chromevox/audio/common/local_earcons_manager.js
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698