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 Bridge that sends earcon messages from content scripts or 7 * other pages to the main background page. 8 * 9 */ 10 11 12goog.provide('cvox.ChromeEarcons'); 13 14goog.require('cvox.AbstractEarcons'); 15goog.require('cvox.ExtensionBridge'); 16goog.require('cvox.HostFactory'); 17 18 19/** 20 * @constructor 21 * @extends {cvox.AbstractEarcons} 22 */ 23cvox.ChromeEarcons = function() { 24 goog.base(this); 25}; 26goog.inherits(cvox.ChromeEarcons, cvox.AbstractEarcons); 27 28 29/** 30 * @override 31 */ 32cvox.ChromeEarcons.prototype.playEarcon = function(earcon) { 33 goog.base(this, 'playEarcon', earcon); 34 if (!this.enabled) { 35 return; 36 } 37 38 cvox.ExtensionBridge.send({ 39 'target': 'EARCON', 40 'action': 'play', 41 'earcon': earcon}); 42}; 43 44 45/** 46 * @override 47 */ 48cvox.ChromeEarcons.prototype.toggle = function() { 49 goog.base(this, 'toggle'); 50 cvox.ChromeVox.host.sendToBackgroundPage({ 51 'target': 'Prefs', 52 'action': 'setPref', 53 'pref': 'earcons', 54 'value': this.enabled 55 }); 56 if (!this.enabled) { 57 cvox.ChromeVox.host.sendToBackgroundPage({ 58 'target': 'Prefs', 59 'action': 'setPref', 60 'pref': 'useVerboseMode', 61 'value': true 62 }); 63 } 64 return this.enabled; 65}; 66 67 68cvox.HostFactory.earconsConstructor = cvox.ChromeEarcons; 69