Commit 0e18cb68 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Eliminate unintended dependency in ChromeVox Content script

LogStore through TreeDumper depends on chrome.automation (which is only available in the background page).

Unfortunately, NavBraille and ConsoleTts require LogStore and are still currently included in the injected content script which pulls in all LogStore deps. This change:
1. removes ConsoleTts from the content script. Logging within a content script might have been useful in the past, but doesn't seem relevant today.
2. NavBraille logging was moved to BackgroundBraille.

Test: load  a page. Verify no errors come from access to automation api being undefined. Ensure there are no references to 'automation' in the compiled page script(s).
Change-Id: Ief450600f4a23588900843678c40baf5efdfbf8b
Reviewed-on: https://chromium-review.googlesource.com/1249270
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594947}
parent 3431fc62
...@@ -45,7 +45,6 @@ chromevox_modules = [ ...@@ -45,7 +45,6 @@ chromevox_modules = [
"chromevox/background/tabs_api_handler.js", "chromevox/background/tabs_api_handler.js",
"chromevox/injected/active_indicator.js", "chromevox/injected/active_indicator.js",
"chromevox/injected/api_implementation.js", "chromevox/injected/api_implementation.js",
"chromevox/injected/console_tts.js",
"chromevox/injected/event_suspender.js", "chromevox/injected/event_suspender.js",
"chromevox/injected/event_watcher.js", "chromevox/injected/event_watcher.js",
"chromevox/injected/history.js", "chromevox/injected/history.js",
...@@ -125,6 +124,7 @@ chromevox_modules = [ ...@@ -125,6 +124,7 @@ chromevox_modules = [
"cvox2/background/braille_command_handler.js", "cvox2/background/braille_command_handler.js",
"cvox2/background/chromevox_state.js", "cvox2/background/chromevox_state.js",
"cvox2/background/command_handler.js", "cvox2/background/command_handler.js",
"cvox2/background/console_tts.js",
"cvox2/background/constants.js", "cvox2/background/constants.js",
"cvox2/background/cursors.js", "cvox2/background/cursors.js",
"cvox2/background/custom_automation_event.js", "cvox2/background/custom_automation_event.js",
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
goog.provide('cvox.NavBraille'); goog.provide('cvox.NavBraille');
goog.require('LogStore');
goog.require('TextLog');
goog.require('Spannable'); goog.require('Spannable');
/** /**
...@@ -111,15 +109,3 @@ cvox.NavBraille.prototype.toJson = function() { ...@@ -111,15 +109,3 @@ cvox.NavBraille.prototype.toJson = function() {
endIndex: this.endIndex endIndex: this.endIndex
}; };
}; };
/**
* Output braille text to console.
*/
cvox.NavBraille.prototype.brailleLogging = function() {
if (localStorage['enableBrailleLogging'] != 'true')
return;
var logStr = 'Braille "' + this.text.toString() + '"';
LogStore.getInstance().writeTextLog(logStr, TextLog.LogType.BRAILLE);
console.log(logStr);
};
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
goog.provide('cvox.ChromeVoxBackground'); goog.provide('cvox.ChromeVoxBackground');
goog.require('ChromeVoxState'); goog.require('ChromeVoxState');
goog.require('ConsoleTts');
goog.require('EventStreamLogger'); goog.require('EventStreamLogger');
goog.require('LogStore'); goog.require('LogStore');
goog.require('Msgs'); goog.require('Msgs');
...@@ -21,7 +22,6 @@ goog.require('cvox.ChromeVoxEditableTextBase'); ...@@ -21,7 +22,6 @@ goog.require('cvox.ChromeVoxEditableTextBase');
goog.require('cvox.ChromeVoxPrefs'); goog.require('cvox.ChromeVoxPrefs');
goog.require('cvox.ClassicEarcons'); goog.require('cvox.ClassicEarcons');
goog.require('cvox.CompositeTts'); goog.require('cvox.CompositeTts');
goog.require('cvox.ConsoleTts');
goog.require('cvox.ExtensionBridge'); goog.require('cvox.ExtensionBridge');
goog.require('cvox.InjectedScriptLoader'); goog.require('cvox.InjectedScriptLoader');
goog.require('cvox.NavBraille'); goog.require('cvox.NavBraille');
...@@ -131,7 +131,7 @@ cvox.ChromeVoxBackground.prototype.init = function() { ...@@ -131,7 +131,7 @@ cvox.ChromeVoxBackground.prototype.init = function() {
this.prefs = new cvox.ChromeVoxPrefs(); this.prefs = new cvox.ChromeVoxPrefs();
cvox.ChromeVoxBackground.readPrefs(); cvox.ChromeVoxBackground.readPrefs();
var consoleTts = cvox.ConsoleTts.getInstance(); var consoleTts = ConsoleTts.getInstance();
consoleTts.setEnabled(this.prefs.getPrefs()['enableSpeechLogging'] == 'true'); consoleTts.setEnabled(this.prefs.getPrefs()['enableSpeechLogging'] == 'true');
LogStore.getInstance(); LogStore.getInstance();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
goog.provide('cvox.OptionsPage'); goog.provide('cvox.OptionsPage');
goog.require('ConsoleTts');
goog.require('EventStreamLogger'); goog.require('EventStreamLogger');
goog.require('Msgs'); goog.require('Msgs');
goog.require('PanelCommand'); goog.require('PanelCommand');
...@@ -19,7 +20,6 @@ goog.require('cvox.ChromeTts'); ...@@ -19,7 +20,6 @@ goog.require('cvox.ChromeTts');
goog.require('cvox.ChromeVox'); goog.require('cvox.ChromeVox');
goog.require('cvox.ChromeVoxPrefs'); goog.require('cvox.ChromeVoxPrefs');
goog.require('cvox.CommandStore'); goog.require('cvox.CommandStore');
goog.require('cvox.ConsoleTts');
goog.require('cvox.ExtensionBridge'); goog.require('cvox.ExtensionBridge');
goog.require('cvox.PlatformFilter'); goog.require('cvox.PlatformFilter');
goog.require('cvox.PlatformUtil'); goog.require('cvox.PlatformUtil');
...@@ -38,7 +38,7 @@ cvox.OptionsPage.prefs; ...@@ -38,7 +38,7 @@ cvox.OptionsPage.prefs;
/** /**
* The ChromeVoxConsoleTts object. * The ChromeVoxConsoleTts object.
* @type {cvox.ConsoleTts} * @type {ConsoleTts}
*/ */
cvox.OptionsPage.consoleTts; cvox.OptionsPage.consoleTts;
...@@ -50,7 +50,7 @@ cvox.OptionsPage.consoleTts; ...@@ -50,7 +50,7 @@ cvox.OptionsPage.consoleTts;
cvox.OptionsPage.init = function() { cvox.OptionsPage.init = function() {
cvox.OptionsPage.prefs = chrome.extension.getBackgroundPage().prefs; cvox.OptionsPage.prefs = chrome.extension.getBackgroundPage().prefs;
cvox.OptionsPage.consoleTts = cvox.OptionsPage.consoleTts =
chrome.extension.getBackgroundPage().cvox.ConsoleTts.getInstance(); chrome.extension.getBackgroundPage().ConsoleTts.getInstance();
cvox.OptionsPage.populateVoicesSelect(); cvox.OptionsPage.populateVoicesSelect();
cvox.BrailleTable.getAll(function(tables) { cvox.BrailleTable.getAll(function(tables) {
/** @type {!Array<cvox.BrailleTable.Table>} */ /** @type {!Array<cvox.BrailleTable.Table>} */
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
goog.provide('cvox.ChromeVoxPrefs'); goog.provide('cvox.ChromeVoxPrefs');
goog.require('ConsoleTts');
goog.require('EventStreamLogger'); goog.require('EventStreamLogger');
goog.require('cvox.ChromeVox'); goog.require('cvox.ChromeVox');
goog.require('cvox.ConsoleTts');
goog.require('cvox.ExtensionBridge'); goog.require('cvox.ExtensionBridge');
goog.require('cvox.KeyMap'); goog.require('cvox.KeyMap');
...@@ -303,7 +303,7 @@ cvox.ChromeVoxPrefs.loggingPrefs = { ...@@ -303,7 +303,7 @@ cvox.ChromeVoxPrefs.loggingPrefs = {
cvox.ChromeVoxPrefs.prototype.setLoggingPrefs = function(key, value) { cvox.ChromeVoxPrefs.prototype.setLoggingPrefs = function(key, value) {
localStorage[key] = value; localStorage[key] = value;
if (key == 'enableSpeechLogging') if (key == 'enableSpeechLogging')
cvox.ConsoleTts.getInstance().setEnabled(value); ConsoleTts.getInstance().setEnabled(value);
else if (key == 'enableEventStreamLogging') else if (key == 'enableEventStreamLogging')
EventStreamLogger.instance.notifyEventStreamFilterChangedAll(value); EventStreamLogger.instance.notifyEventStreamFilterChangedAll(value);
}; };
......
// 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 A TTS engine that writes to window.console.
*/
goog.provide('cvox.ConsoleTts');
goog.require('LogStore');
goog.require('TextLog');
goog.require('cvox.AbstractTts');
goog.require('cvox.TtsInterface');
/**
* @constructor
* @implements {cvox.TtsInterface}
*/
cvox.ConsoleTts = function() {
/**
* True if the console TTS is enabled by the user.
* @type {boolean}
* @private
*/
this.enabled_ = false;
};
goog.addSingletonGetter(cvox.ConsoleTts);
/** @override */
cvox.ConsoleTts.prototype.speak = function(textString, queueMode, properties) {
if (this.enabled_ && window['console']) {
var logStr = 'Speak';
if (queueMode == cvox.QueueMode.FLUSH) {
logStr += ' (I)';
} else if (queueMode == cvox.QueueMode.CATEGORY_FLUSH) {
logStr += ' (C)';
} else {
logStr += ' (Q)';
}
if (properties && properties.category) {
logStr += ' category=' + properties.category;
}
logStr += ' "' + textString + '"';
LogStore.getInstance().writeTextLog(logStr, TextLog.LogType.SPEECH);
console.log(logStr);
}
return this;
};
/** @override */
cvox.ConsoleTts.prototype.isSpeaking = function() {
return false;
};
/** @override */
cvox.ConsoleTts.prototype.stop = function() {
if (this.enabled_) {
console.log('Stop');
}
};
/** @override */
cvox.ConsoleTts.prototype.addCapturingEventListener = function(listener) {};
/** @override */
cvox.ConsoleTts.prototype.increaseOrDecreaseProperty = function() {};
/** @override */
cvox.ConsoleTts.prototype.propertyToPercentage = function() {};
/**
* Sets the enabled bit.
* @param {boolean} enabled The new enabled bit.
*/
cvox.ConsoleTts.prototype.setEnabled = function(enabled) {
this.enabled_ = enabled;
};
/** @override */
cvox.ConsoleTts.prototype.getDefaultProperty = function(property) {};
/** @override */
cvox.ConsoleTts.prototype.toggleSpeechOnOrOff = function() {};
...@@ -12,7 +12,6 @@ goog.provide('cvox.InitGlobals'); ...@@ -12,7 +12,6 @@ goog.provide('cvox.InitGlobals');
goog.require('cvox.ChromeVox'); goog.require('cvox.ChromeVox');
goog.require('cvox.ChromeVoxEventWatcher'); goog.require('cvox.ChromeVoxEventWatcher');
goog.require('cvox.CompositeTts'); goog.require('cvox.CompositeTts');
goog.require('cvox.ConsoleTts');
goog.require('cvox.HostFactory'); goog.require('cvox.HostFactory');
goog.require('cvox.NavigationManager'); goog.require('cvox.NavigationManager');
goog.require('cvox.Serializer'); goog.require('cvox.Serializer');
...@@ -35,8 +34,7 @@ cvox.InitGlobals.initGlobals = function() { ...@@ -35,8 +34,7 @@ cvox.InitGlobals.initGlobals = function() {
cvox.ChromeVox.tts = new cvox.CompositeTts() cvox.ChromeVox.tts = new cvox.CompositeTts()
.add(cvox.HostFactory.getTts()) .add(cvox.HostFactory.getTts())
.add(cvox.History.getInstance()) .add(cvox.History.getInstance());
.add(cvox.ConsoleTts.getInstance());
if (!cvox.ChromeVox.braille) { if (!cvox.ChromeVox.braille) {
cvox.ChromeVox.braille = cvox.HostFactory.getBraille(); cvox.ChromeVox.braille = cvox.HostFactory.getBraille();
......
...@@ -22,7 +22,6 @@ goog.require('cvox.BrailleOverlayWidget'); ...@@ -22,7 +22,6 @@ goog.require('cvox.BrailleOverlayWidget');
goog.require('cvox.ChromeVox'); goog.require('cvox.ChromeVox');
goog.require('cvox.ChromeVoxKbHandler'); goog.require('cvox.ChromeVoxKbHandler');
goog.require('cvox.CommandStore'); goog.require('cvox.CommandStore');
goog.require('cvox.ConsoleTts');
goog.require('cvox.ContextMenuWidget'); goog.require('cvox.ContextMenuWidget');
goog.require('cvox.DomPredicates'); goog.require('cvox.DomPredicates');
goog.require('cvox.DomUtil'); goog.require('cvox.DomUtil');
...@@ -572,9 +571,6 @@ cvox.ChromeVoxUserCommands.doCommand_ = function(cmdStruct) { ...@@ -572,9 +571,6 @@ cvox.ChromeVoxUserCommands.doCommand_ = function(cmdStruct) {
case 'stopHistoryRecording': case 'stopHistoryRecording':
cvox.History.getInstance().stopRecording(); cvox.History.getInstance().stopRecording();
break; break;
case 'enableConsoleTts':
cvox.ConsoleTts.getInstance().setEnabled(true);
break;
case 'toggleBrailleCaptions': case 'toggleBrailleCaptions':
cvox.ChromeVox.host.sendToBackgroundPage({ cvox.ChromeVox.host.sendToBackgroundPage({
'target': 'Prefs', 'target': 'Prefs',
......
// 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 A TTS engine that writes to window.console.
*/
goog.provide('ConsoleTts');
goog.require('LogStore');
goog.require('TextLog');
goog.require('cvox.AbstractTts');
goog.require('cvox.TtsInterface');
/**
* @constructor
* @implements {cvox.TtsInterface}
*/
ConsoleTts = function() {
/**
* True if the console TTS is enabled by the user.
* @type {boolean}
* @private
*/
this.enabled_ = false;
};
goog.addSingletonGetter(ConsoleTts);
/** @override */
ConsoleTts.prototype = {
speak: function(textString, queueMode, properties) {
if (this.enabled_ && window['console']) {
var logStr = 'Speak';
if (queueMode == cvox.QueueMode.FLUSH) {
logStr += ' (I)';
} else if (queueMode == cvox.QueueMode.CATEGORY_FLUSH) {
logStr += ' (C)';
} else {
logStr += ' (Q)';
}
if (properties && properties.category) {
logStr += ' category=' + properties.category;
}
logStr += ' "' + textString + '"';
LogStore.getInstance().writeTextLog(logStr, TextLog.LogType.SPEECH);
console.log(logStr);
}
return this;
},
/** @override */
isSpeaking: function() {
return false;
},
/** @override */
stop: function() {
if (this.enabled_) {
console.log('Stop');
}
},
/** @override */
addCapturingEventListener: function(listener) {},
/** @override */
increaseOrDecreaseProperty: function() {},
/** @override */
propertyToPercentage: function() {},
/**
* Sets the enabled bit.
* @param {boolean} enabled The new enabled bit.
*/
setEnabled: function(enabled) {
this.enabled_ = enabled;
},
/** @override */
getDefaultProperty: function(property) {},
/** @override */
toggleSpeechOnOrOff: function() {}
};
...@@ -1073,7 +1073,6 @@ Output.prototype = { ...@@ -1073,7 +1073,6 @@ Output.prototype = {
var output = new cvox.NavBraille( var output = new cvox.NavBraille(
{text: buff, startIndex: startIndex, endIndex: endIndex}); {text: buff, startIndex: startIndex, endIndex: endIndex});
output.brailleLogging();
cvox.ChromeVox.braille.write(output); cvox.ChromeVox.braille.write(output);
if (this.brailleRulesStr_.str) { if (this.brailleRulesStr_.str) {
......
...@@ -10,6 +10,7 @@ goog.provide('cvox.BrailleBackground'); ...@@ -10,6 +10,7 @@ goog.provide('cvox.BrailleBackground');
goog.require('BrailleKeyEventRewriter'); goog.require('BrailleKeyEventRewriter');
goog.require('ChromeVoxState'); goog.require('ChromeVoxState');
goog.require('LogStore');
goog.require('cvox.BrailleDisplayManager'); goog.require('cvox.BrailleDisplayManager');
goog.require('cvox.BrailleInputHandler'); goog.require('cvox.BrailleInputHandler');
goog.require('cvox.BrailleInterface'); goog.require('cvox.BrailleInterface');
...@@ -73,6 +74,13 @@ cvox.BrailleBackground.prototype.write = function(params) { ...@@ -73,6 +74,13 @@ cvox.BrailleBackground.prototype.write = function(params) {
if (this.frozen_) { if (this.frozen_) {
return; return;
} }
if (localStorage['enableBrailleLogging'] == 'true') {
var logStr = 'Braille "' + params.text.toString() + '"';
LogStore.getInstance().writeTextLog(logStr, TextLog.LogType.BRAILLE);
console.log(logStr);
}
this.setContent_(params, null); this.setContent_(params, null);
}; };
......
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