Commit 0f2b9d8e authored by Katie Dektar's avatar Katie Dektar Committed by Commit Bot

Add settings and start and stop speech metrics to Select-to-Speak.

Bug: 790045
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I438b266980762eff52a81968ae9fb53d8acc4f04
Reviewed-on: https://chromium-review.googlesource.com/801335Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Katie D <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520702}
parent 748a0f54
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
'<(EXTERNS_GYP):accessibility_private', '<(EXTERNS_GYP):accessibility_private',
'<(EXTERNS_GYP):automation', '<(EXTERNS_GYP):automation',
'<(EXTERNS_GYP):chrome_extensions', '<(EXTERNS_GYP):chrome_extensions',
'<(EXTERNS_GYP):metrics_private',
], ],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
}, },
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
'<(EXTERNS_GYP):accessibility_private', '<(EXTERNS_GYP):accessibility_private',
'<(EXTERNS_GYP):automation', '<(EXTERNS_GYP):automation',
'<(EXTERNS_GYP):chrome_extensions', '<(EXTERNS_GYP):chrome_extensions',
'<(EXTERNS_GYP):metrics_private',
], ],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
}, },
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
}, },
"permissions": [ "permissions": [
"accessibilityPrivate", "accessibilityPrivate",
"metricsPrivate",
"storage", "storage",
"tts" "tts"
], ],
......
...@@ -110,8 +110,6 @@ function getNodeState(node) { ...@@ -110,8 +110,6 @@ function getNodeState(node) {
* Regular expression to find the start of the next word after a word boundary. * Regular expression to find the start of the next word after a word boundary.
* We cannot use \b\W to find the next word because it does not match many * We cannot use \b\W to find the next word because it does not match many
* unicode characters. * unicode characters.
* TODO: Extract word boundaries from the Accessibility node and use that
* instead.
* @type {RegExp} * @type {RegExp}
*/ */
const WORD_START_REGEXP = /\b\S/; const WORD_START_REGEXP = /\b\S/;
...@@ -120,8 +118,6 @@ const WORD_START_REGEXP = /\b\S/; ...@@ -120,8 +118,6 @@ const WORD_START_REGEXP = /\b\S/;
* Regular expression to find the end of the next word, which is followed by * Regular expression to find the end of the next word, which is followed by
* whitespace. We cannot use \w\b to find the end of the previous word because * whitespace. We cannot use \w\b to find the end of the previous word because
* \w does not know about many unicode characters. * \w does not know about many unicode characters.
* TODO: Extract word boundaries from the Accessibility node and use that
* instead.
* @type {RegExp} * @type {RegExp}
*/ */
const WORD_END_REGEXP = /\S\s/; const WORD_END_REGEXP = /\S\s/;
...@@ -447,6 +443,7 @@ SelectToSpeak.prototype = { ...@@ -447,6 +443,7 @@ SelectToSpeak.prototype = {
if (!findAllMatching(root, rect, nodes) && focusedNode) if (!findAllMatching(root, rect, nodes) && focusedNode)
findAllMatching(focusedNode.root, rect, nodes); findAllMatching(focusedNode.root, rect, nodes);
this.startSpeechQueue_(nodes); this.startSpeechQueue_(nodes);
this.recordStartEvent_();
}.bind(this)); }.bind(this));
}, },
...@@ -487,7 +484,7 @@ SelectToSpeak.prototype = { ...@@ -487,7 +484,7 @@ SelectToSpeak.prototype = {
this.keysPressedTogether_.has(evt.keyCode) && this.keysPressedTogether_.has(evt.keyCode) &&
this.keysPressedTogether_.size == 1) { this.keysPressedTogether_.size == 1) {
this.trackingMouse_ = false; this.trackingMouse_ = false;
this.stopAll_(); chrome.tts.isSpeaking(this.cancelIfSpeaking_.bind(this));
} }
this.keysCurrentlyDown_.delete(evt.keyCode); this.keysCurrentlyDown_.delete(evt.keyCode);
...@@ -663,6 +660,34 @@ SelectToSpeak.prototype = { ...@@ -663,6 +660,34 @@ SelectToSpeak.prototype = {
} }
}, },
/**
* Cancels the current speech queue if speech is in progress.
*/
cancelIfSpeaking_: function(speaking) {
if (speaking) {
this.stopAll_();
this.recordCancelEvent_();
}
},
/**
* Records an event that Select-to-Speak has begun speaking.
*/
recordStartEvent_: function() {
// TODO(katie): Add tracking for speech rate, how STS was activated,
// whether word highlighting is on or off (as histograms?).
chrome.metricsPrivate.recordUserAction(
'Accessibility.CrosSelectToSpeak.StartSpeech');
},
/**
* Records an event that Select-to-Speak speech has been canceled.
*/
recordCancelEvent_: function() {
chrome.metricsPrivate.recordUserAction(
'Accessibility.CrosSelectToSpeak.CancelSpeech');
},
/** /**
* Loads preferences from chrome.storage, sets default values if * Loads preferences from chrome.storage, sets default values if
* necessary, and registers a listener to update prefs when they * necessary, and registers a listener to update prefs when they
......
...@@ -24,6 +24,8 @@ SelectToSpeakOptionsPage.prototype = { ...@@ -24,6 +24,8 @@ SelectToSpeakOptionsPage.prototype = {
this.syncSelectControlToPref_('rate', 'rate'); this.syncSelectControlToPref_('rate', 'rate');
this.syncCheckboxControlToPref_('wordHighlight', 'wordHighlight'); this.syncCheckboxControlToPref_('wordHighlight', 'wordHighlight');
this.setUpHighlightListener_(); this.setUpHighlightListener_();
chrome.metricsPrivate.recordUserAction(
'Accessibility.CrosSelectToSpeak.LoadSettings');
}, },
/** /**
......
...@@ -24,6 +24,11 @@ chrome.automation.RoleType = { ...@@ -24,6 +24,11 @@ chrome.automation.RoleType = {
INLINE_TEXT_BOX: 'inlineTextBox', INLINE_TEXT_BOX: 'inlineTextBox',
PARAGRAPH: 'paragraph' PARAGRAPH: 'paragraph'
}; };
chrome.automation.StateType = { chrome.automation.StateType = {
INVISIBLE: 'invisible' INVISIBLE: 'invisible'
}; };
chrome.metricsPrivate = {
recordUserAction: function() {}
};
...@@ -1125,6 +1125,25 @@ should be able to be added at any place in this file. ...@@ -1125,6 +1125,25 @@ should be able to be added at any place in this file.
</description> </description>
</action> </action>
<action name="Accessibility.CrosSelectToSpeak.CancelSpeech">
<owner>katie@chromium.org</owner>
<description>
A Chrome OS user manually cancels Select To Speak while it is speaking.
</description>
</action>
<action name="Accessibility.CrosSelectToSpeak.LoadSettings">
<owner>katie@chromium.org</owner>
<description>
A Chrome OS user loads the Select To Speak settings page.
</description>
</action>
<action name="Accessibility.CrosSelectToSpeak.StartSpeech">
<owner>katie@chromium.org</owner>
<description>A Chrome OS user manually starts Select To Speak.</description>
</action>
<action name="Accessibility.TwoFingersHeldGeneratedSpokenFeedbackCountdown"> <action name="Accessibility.TwoFingersHeldGeneratedSpokenFeedbackCountdown">
<owner>dmazzoni@chromium.org</owner> <owner>dmazzoni@chromium.org</owner>
<description> <description>
......
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