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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 Bridge that sends earcon messages from content scripts or
7 * other pages to the main background page.
8 */
9
10 goog.provide('cvox.LocalEarconsManager');
11
12 goog.require('cvox.AbstractEarconsManager');
13
14 /**
15 * @constructor
16 * @param {Array} earcons Array of earcon classes.
17 * @param {cvox.AbstractTtsManager} ttsManager A TTS provider.
18 * @extends {cvox.AbstractEarconsManager}
19 */
20 cvox.LocalEarconsManager = function(earcons, ttsManager) {
21 //Inherit AbstractEarconsManager
22 cvox.AbstractEarconsManager.call(this);
23
24 this.earcons = earcons;
25 this.ttsManager = ttsManager;
26 this.currentEarcons = null;
27 this.currentEarconsIndex = -1;
28 this.nextEarcons(false);
29 };
30 goog.inherits(cvox.LocalEarconsManager, cvox.AbstractEarconsManager);
31
32 /**
33 * @return {string} The human-readable name of this instance.
34 */
35 cvox.LocalEarconsManager.prototype.getName = function() {
36 return 'LocalEarconsManager';
37 };
38
39 /**
40 * Plays the specified earcon.
41 * @param {number} earcon The index of the earcon to be played.
42 */
43 cvox.LocalEarconsManager.prototype.playEarcon = function(earcon) {
44 cvox.LocalEarconsManager.superClass_.playEarcon.call(this, earcon);
45 if (!this.currentEarcons) {
46 return;
47 }
48 this.currentEarcons.playEarcon(earcon);
49 };
50
51 /**
52 * Switch to the next earcon set and optionally announce its name.
53 * If no earcon sets have been specified this function is a NOOP.
54 * @param {boolean} announce If true, will announce the name of the
55 * new earcon set.
56 */
57 cvox.LocalEarconsManager.prototype.nextEarcons = function(announce) {
58 cvox.LocalEarconsManager.superClass_.nextEarcons.call(this, announce);
59 if (!this.earcons) {
60 return;
61 }
62 this.currentEarcons = null;
63 this.currentEarconsIndex =
64 (this.currentEarconsIndex + 1) % this.earcons.length;
65 try {
66 this.currentEarcons = new this.earcons[this.currentEarconsIndex];
67 console.log('Switching to earcons: ' + this.currentEarcons.getName());
68 if (announce) {
69 this.ttsManager.speak(this.currentEarcons.getName());
70 }
71 } catch (err) {
72 console.log('error switching to earcon #' + this.currentEarconsIndex);
73 }
74 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698