Commit 773c53fc authored by plundblad's avatar plundblad Committed by Commit bot

Refactor: remove a Chromevox abstract class.

Removes the superflous cvox.AbstractMsgs class and moves what was rpeviously
ChromeMsgs out of host.

BUG=341953
R=dtseng@chromium.org

Review URL: https://codereview.chromium.org/593133002

Cr-Commit-Position: refs/heads/master@{#296367}
parent d99e73cf
......@@ -13,7 +13,6 @@ goog.require('cvox.AbstractEarcons');
goog.require('cvox.AccessibilityApiHandler');
goog.require('cvox.BrailleBackground');
goog.require('cvox.BrailleCaptionsBackground');
goog.require('cvox.ChromeMsgs');
goog.require('cvox.ChromeVox');
goog.require('cvox.ChromeVoxEditableTextBase');
goog.require('cvox.ChromeVoxPrefs');
......@@ -23,6 +22,7 @@ goog.require('cvox.EarconsBackground');
goog.require('cvox.ExtensionBridge');
goog.require('cvox.HostFactory');
goog.require('cvox.InjectedScriptLoader');
goog.require('cvox.Msgs');
goog.require('cvox.NavBraille');
// TODO(dtseng): This is required to prevent Closure from stripping our export
// prefs on window.
......@@ -56,7 +56,7 @@ cvox.ChromeVoxBackground.prototype.init = function() {
return;
}
cvox.ChromeVox.msgs = cvox.HostFactory.getMsgs();
cvox.ChromeVox.msgs = new cvox.Msgs();
this.prefs = new cvox.ChromeVoxPrefs();
this.readPrefs();
......
......@@ -7,5 +7,5 @@
*
*/
goog.require('cvox.ChromeMsgs');
goog.require('cvox.ChromeVoxBackground');
goog.require('cvox.Msgs');
......@@ -13,7 +13,6 @@ goog.require('cvox.BrailleBackground');
goog.require('cvox.BrailleTable');
goog.require('cvox.ChromeEarcons');
goog.require('cvox.ChromeHost');
goog.require('cvox.ChromeMsgs');
goog.require('cvox.ChromeTts');
goog.require('cvox.ChromeVox');
goog.require('cvox.ChromeVoxPrefs');
......@@ -22,6 +21,7 @@ goog.require('cvox.ExtensionBridge');
goog.require('cvox.HostFactory');
goog.require('cvox.KeyMap');
goog.require('cvox.KeySequence');
goog.require('cvox.Msgs');
goog.require('cvox.PlatformFilter');
goog.require('cvox.PlatformUtil');
......@@ -67,7 +67,7 @@ cvox.OptionsPage.TEXT_TO_KEYCODE = {
* @suppress {missingProperties} Property prefs never defined on Window
*/
cvox.OptionsPage.init = function() {
cvox.ChromeVox.msgs = cvox.HostFactory.getMsgs();
cvox.ChromeVox.msgs = new cvox.Msgs();
cvox.OptionsPage.prefs = chrome.extension.getBackgroundPage().prefs;
cvox.OptionsPage.populateKeyMapSelect();
......
......@@ -46,7 +46,7 @@ cvox.InitGlobals.initGlobals = function() {
cvox.ChromeVox.mathJax = cvox.HostFactory.getMathJax();
cvox.ChromeVox.earcons = cvox.HostFactory.getEarcons();
cvox.ChromeVox.msgs = cvox.HostFactory.getMsgs();
cvox.ChromeVox.msgs = new cvox.Msgs();
cvox.ChromeVox.isActive = true;
cvox.ChromeVox.navigationManager = new cvox.NavigationManager();
cvox.ChromeVox.navigationManager.updateIndicator();
......
......@@ -12,7 +12,7 @@ window.CLOSURE_USE_EXT_MESSAGES = true;
goog.require('cvox.ChromeEarcons');
goog.require('cvox.ChromeHost');
goog.require('cvox.ChromeMathJax');
goog.require('cvox.ChromeMsgs');
goog.require('cvox.Msgs');
goog.require('cvox.ChromeTts');
goog.require('cvox.ChromeBraille');
goog.require('cvox.ChromeVoxInit');
......
......@@ -4,24 +4,16 @@
/**
* @fileoverview A cvox.AbstractMsgs implementation for Chrome.
* @fileoverview Defines methods related to retrieving translated messages.
*/
goog.provide('cvox.ChromeMsgs');
goog.require('cvox.AbstractMsgs');
goog.require('cvox.HostFactory');
goog.provide('cvox.Msgs');
/**
* @constructor
* @extends {cvox.AbstractMsgs}
*/
cvox.ChromeMsgs = function() {
cvox.AbstractMsgs.call(this);
cvox.Msgs = function() {
};
goog.inherits(cvox.ChromeMsgs, cvox.AbstractMsgs);
/**
......@@ -30,14 +22,14 @@ goog.inherits(cvox.ChromeMsgs, cvox.AbstractMsgs);
* @const
* @private
*/
cvox.ChromeMsgs.NAMESPACE_ = 'chromevox_';
cvox.Msgs.NAMESPACE_ = 'chromevox_';
/**
* Return the current locale.
* @return {string} The locale.
*/
cvox.ChromeMsgs.prototype.getLocale = function() {
cvox.Msgs.prototype.getLocale = function() {
return chrome.i18n.getMessage('locale');
};
......@@ -48,15 +40,15 @@ cvox.ChromeMsgs.prototype.getLocale = function() {
* If we can't find a message, throw an exception. This allows us to catch
* typos early.
*
* @param {string} message_id The id.
* @param {string} messageId The id.
* @param {Array.<string>=} opt_subs Substitution strings.
* @return {string} The message.
*/
cvox.ChromeMsgs.prototype.getMsg = function(message_id, opt_subs) {
cvox.Msgs.prototype.getMsg = function(messageId, opt_subs) {
var message = chrome.i18n.getMessage(
cvox.ChromeMsgs.NAMESPACE_ + message_id, opt_subs);
cvox.Msgs.NAMESPACE_ + messageId, opt_subs);
if (message == undefined || message == '') {
throw new Error('Invalid ChromeVox message id: ' + message_id);
throw new Error('Invalid ChromeVox message id: ' + messageId);
}
return message;
};
......@@ -68,7 +60,7 @@ cvox.ChromeMsgs.prototype.getMsg = function(message_id, opt_subs) {
*
* @param {Node} root The root node where the translation should be performed.
*/
cvox.ChromeMsgs.prototype.addTranslatedMessagesToDom = function(root) {
cvox.Msgs.prototype.addTranslatedMessagesToDom = function(root) {
var elts = root.querySelectorAll('.i18n');
for (var i = 0; i < elts.length; i++) {
var msgid = elts[i].getAttribute('msgid');
......@@ -87,8 +79,6 @@ cvox.ChromeMsgs.prototype.addTranslatedMessagesToDom = function(root) {
* @param {number} num The number.
* @return {string} The number in the correct locale.
*/
cvox.ChromeMsgs.prototype.getNumber = function(num) {
cvox.Msgs.prototype.getNumber = function(num) {
return '' + num;
};
cvox.HostFactory.msgsConstructor = cvox.ChromeMsgs;
......@@ -36,8 +36,8 @@ goog.addDependency(
[]);
goog.addDependency(
'../host/interface/abstract_msgs.js',
['cvox.AbstractMsgs'],
'../chromevox/messages/msgs.js',
['cvox.Msgs'],
[]);
goog.addDependency(
......@@ -97,7 +97,7 @@ cvox.ChromeVox.braille;
*/
cvox.ChromeVox.mathJax;
/**
* @type {cvox.AbstractMsgs}
* @type {cvox.Msgs}
*/
cvox.ChromeVox.msgs = null;
/**
......
// Copyright 2014 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 Defined the convenience function cvox.Msgs.getMsg.
*/
goog.provide('cvox.AbstractMsgs');
/**
* @constructor
*/
cvox.AbstractMsgs = function() { };
/**
* Return the current locale.
* @return {string} The locale.
*/
cvox.AbstractMsgs.prototype.getLocale = function() { };
/**
* Returns the message with the given message id.
*
* If we can't find a message, throw an exception. This allows us to catch
* typos early.
*
* @param {string} message_id The id.
* @param {Array.<string>=} opt_subs Substitution strings.
* @return {string} The message.
*/
cvox.AbstractMsgs.prototype.getMsg = function(message_id, opt_subs) {
};
/**
* Retuns a number formatted correctly.
*
* @param {number} num The number.
* @return {string} The number in the correct locale.
*/
cvox.AbstractMsgs.prototype.getNumber = function(num) {
};
......@@ -10,18 +10,15 @@
goog.provide('cvox.HostFactory');
goog.require('cvox.AbstractBraille');
goog.require('cvox.AbstractEarcons');
goog.require('cvox.AbstractHost');
goog.require('cvox.AbstractMathJax');
goog.require('cvox.AbstractMsgs');
goog.require('cvox.AbstractTts');
goog.require('cvox.AbstractBraille');
/**
* @namespace.
* @constructor
*/
cvox.HostFactory = function() {};
......@@ -49,14 +46,6 @@ cvox.HostFactory.getBraille = function() {
return new cvox.HostFactory.brailleConstructor;
};
/**
* Returns the message interface.
* @return {cvox.AbstractMsgs}
*/
cvox.HostFactory.getMsgs = function() {
return new cvox.HostFactory.msgsConstructor;
};
/**
* Returns the earcons interface.
* @return {cvox.AbstractEarcons}
......@@ -88,11 +77,6 @@ cvox.HostFactory.ttsConstructor;
*/
cvox.HostFactory.brailleConstructor;
/**
* @type {function (new:cvox.AbstractMsgs)}
*/
cvox.HostFactory.msgsConstructor;
/**
* @type {function (new:cvox.AbstractEarcons)}
*/
......
......@@ -9,25 +9,22 @@
goog.provide('cvox.TestMsgs');
goog.require('cvox.AbstractMsgs');
goog.require('cvox.HostFactory');
goog.require('cvox.Msgs');
goog.require('cvox.TestMessages');
/**
* @constructor
* @extends {cvox.AbstractMsgs}
* @extends {cvox.Msgs}
*/
cvox.TestMsgs = function() {
cvox.AbstractMsgs.call(this);
cvox.Msgs.call(this);
};
goog.inherits(cvox.TestMsgs, cvox.AbstractMsgs);
goog.inherits(cvox.TestMsgs, cvox.Msgs);
/**
* Return the current locale.
* @return {string} The locale.
* @override
*/
cvox.TestMsgs.prototype.getLocale = function() {
return 'testing';
......@@ -35,19 +32,15 @@ cvox.TestMsgs.prototype.getLocale = function() {
/**
* Returns the message with the given message id from the ChromeVox namespace.
*
* @param {string} message_id The id.
* @param {Array.<string>} opt_subs Substitution strings.
* @return {string} The message.
* @override
*/
cvox.TestMsgs.prototype.getMsg = function(message_id, opt_subs) {
if (!message_id) {
cvox.TestMsgs.prototype.getMsg = function(messageId, opt_subs) {
if (!messageId) {
throw Error('Message id required');
}
var message = cvox.TestMessages[('chromevox_' + message_id).toUpperCase()];
var message = cvox.TestMessages[('chromevox_' + messageId).toUpperCase()];
if (message == undefined) {
throw Error('missing-msg: ' + message_id);
throw Error('missing-msg: ' + messageId);
}
var messageString = message.message;
......@@ -59,19 +52,3 @@ cvox.TestMsgs.prototype.getMsg = function(message_id, opt_subs) {
}
return messageString;
};
/**
* Retuns a number formatted correctly.
*
* @param {number} num The number.
* @return {string} The number in the correct locale.
*/
cvox.TestMsgs.prototype.getNumber = function(num) {
return '' + num;
};
/**
* Cosntructor for the host factory.
*/
cvox.HostFactory.msgsConstructor = cvox.TestMsgs;
......@@ -70,7 +70,7 @@ cvox.TableShifter.prototype.getName = function() {
/**
* @override
* @suppress {checkTypes} actual parameter 2 of
* cvox.AbstractMsgs.prototype.getMsg does not match formal parameter
* cvox.Msgs.prototype.getMsg does not match formal parameter
* found : Array.<number>
* required: (Array.<string>|null|undefined)
*/
......
......@@ -55,7 +55,7 @@ cvox.TableWalker.prototype.sync = function(sel) {
/**
* @override
* @suppress {checkTypes} actual parameter 2 of
* cvox.AbstractMsgs.prototype.getMsg does not match formal parameter
* cvox.Msgs.prototype.getMsg does not match formal parameter
* found : Array.<number>
* required: (Array.<string>|null|undefined)
*/
......@@ -267,7 +267,7 @@ cvox.TableWalker.prototype.getHeaderText_ = function(sel) {
* @param {!cvox.CursorSelection} sel A valid selection.
* @return {Array.<cvox.NavDescription>} The location description.
* @suppress {checkTypes} actual parameter 2 of
* cvox.AbstractMsgs.prototype.getMsg does not match
* cvox.Msgs.prototype.getMsg does not match
* formal parameter
* found : Array.<number>
* required: (Array.<string>|null|undefined)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment