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'); |
}); |