Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2774)

Unified Diff: chrome/browser/resources/hotword_audio_verification/main.js

Issue 693433002: Hotword Audio Verification App: update training UI on hotword trigger. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tp3-api
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/hotword_audio_verification/main.js
diff --git a/chrome/browser/resources/hotword_audio_verification/main.js b/chrome/browser/resources/hotword_audio_verification/main.js
index eab99c8655cb96bb1640fba399f3808c3d1a42ef..78838e3c8c1d615171d309e339e11436b79f8226 100644
--- a/chrome/browser/resources/hotword_audio_verification/main.js
+++ b/chrome/browser/resources/hotword_audio_verification/main.js
@@ -11,17 +11,17 @@ document.addEventListener('DOMContentLoaded', function() {
var closeAppWindow = function(e) {
var classes = e.target.classList;
if (classes.contains('close') || classes.contains('finish-button')) {
+ flow.stopTraining();
appWindow.close();
e.preventDefault();
}
};
- // TODO(kcarattini): Cancel training in NaCl module for hotword-only and
- // speech-training close and cancel buttons.
$('steps').addEventListener('click', closeAppWindow);
$('hw-agree-button').addEventListener('click', function(e) {
flow.advanceStep();
+ flow.startTraining();
e.preventDefault();
});
@@ -29,65 +29,4 @@ document.addEventListener('DOMContentLoaded', function() {
chrome.browser.openTab({'url': 'chrome://settings'}, function() {});
e.preventDefault();
});
-
- /**
- * Updates steps of the training UI.
- * @param {string} pagePrefix Prefix of the element ids for this page.
- * @param {Event} e The click event.
- */
- function doTraining(pagePrefix, e) {
- // TODO(kcarattini): Update this to respond to a hotword trigger once
- // speech training is implemented.
- var steps = $(pagePrefix + '-training').querySelectorAll('.train');
- var index = Array.prototype.indexOf.call(steps, e.currentTarget);
- if (!steps[index])
- return;
-
- // TODO(kcarattini): Localize this string.
- steps[index].querySelector('.text').textContent = 'Recorded';
- steps[index].classList.remove('listening');
- steps[index].classList.add('recorded');
-
- if (steps[index + 1]) {
- steps[index + 1].classList.remove('not-started');
- steps[index + 1].classList.add('listening');
- }
- }
-
- /**
- * Adds event listeners to the training UI.
- * @param {string} pagePrefix Prefix of the element ids for this page.
- */
- function addTrainingEventListeners(pagePrefix) {
- var steps = $(pagePrefix + '-training').querySelectorAll('.train');
- for (var i = 0; i < steps.length; ++i) {
- steps[i].addEventListener('click', function(e) {
- doTraining(pagePrefix, e);
- e.preventDefault();
-
- if (e.currentTarget != steps[steps.length - 1])
- return;
-
- // Update the 'Cancel' button.
- var buttonElem = $(pagePrefix + '-cancel-button');
- // TODO(kcarattini): Localize this string.
- buttonElem.textContent = 'Please wait ...';
- buttonElem.classList.add('grayed-out');
- buttonElem.classList.remove('finish-button');
-
- setTimeout(function() {
- if (chrome.hotwordPrivate.setAudioLoggingEnabled)
- chrome.hotwordPrivate.setAudioLoggingEnabled(true, function() {});
-
- if (chrome.hotwordPrivate.setHotwordAlwaysOnSearchEnabled) {
- chrome.hotwordPrivate.setHotwordAlwaysOnSearchEnabled(true,
- flow.advanceStep.bind(flow));
- }
- }, 2000);
- });
- }
- }
-
- addTrainingEventListeners('speech-training');
- addTrainingEventListeners('hotword-only');
});

Powered by Google App Engine
This is Rietveld 408576698