Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / chromeos / chromevox / chromevox / injected / console_tts.js
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
3 // found in the LICENSE file.
4
5 /**
6  * @fileoverview A TTS engine that writes to window.console.
7  */
8
9 goog.provide('cvox.ConsoleTts');
10
11 goog.require('cvox.AbstractTts');
12 goog.require('cvox.TtsInterface');
13
14 /**
15  * @constructor
16  * @implements {cvox.TtsInterface}
17  */
18 cvox.ConsoleTts = function() {
19   /**
20    * True if the console TTS is enabled by the user.
21    * @type {boolean}
22    * @private
23    */
24   this.enabled_ = false;
25 };
26 goog.addSingletonGetter(cvox.ConsoleTts);
27
28
29 /** @override */
30 cvox.ConsoleTts.prototype.speak = function(textString, queueMode, properties) {
31   if (this.enabled_ && window['console']) {
32     var logStr = 'Speak';
33     if (queueMode == cvox.QueueMode.FLUSH) {
34       logStr += ' (I)';
35     } else if (queueMode == cvox.QueueMode.CATEGORY_FLUSH) {
36       logStr += ' (C)';
37     } else {
38       logStr += ' (Q)';
39     }
40     if (properties && properties.category) {
41       logStr += ' category=' + properties.category;
42     }
43     logStr += ' "' + textString + '"';
44     window['console']['log'](logStr);
45
46     if (properties && properties['startCallback'] != undefined) {
47       window.console.log('  using startCallback');
48     }
49
50     if (properties && properties['endCallback'] != undefined) {
51       window.console.log('  using endCallback');
52     }
53   }
54   return this;
55 };
56
57 /** @override */
58 cvox.ConsoleTts.prototype.isSpeaking = function() { return false; };
59
60 /** @override */
61 cvox.ConsoleTts.prototype.stop = function() {
62   if (this.enabled_) {
63     window['console']['log']('Stop');
64   }
65 };
66
67 /** @override */
68 cvox.ConsoleTts.prototype.addCapturingEventListener = function(listener) { };
69
70 /** @override */
71 cvox.ConsoleTts.prototype.increaseOrDecreaseProperty = function() { };
72
73 /**
74  * Sets the enabled bit.
75  * @param {boolean} enabled The new enabled bit.
76  */
77 cvox.ConsoleTts.prototype.setEnabled = function(enabled) {
78   this.enabled_ = enabled;
79 };
80
81 /** @override */
82 cvox.ConsoleTts.prototype.getDefaultProperty = function(property) { };