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

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

Issue 528113003: Hotword Audio Verification App: Adds to hotwordPrivate API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@page-one
Patch Set: Created 6 years, 3 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/flow.js
diff --git a/chrome/browser/resources/hotword_audio_verification/flow.js b/chrome/browser/resources/hotword_audio_verification/flow.js
index 5a244e74aa43af5a204e5861dab083b847b3e59d..f2be7312ec1aa36379feae9ea628538fc1895b43 100644
--- a/chrome/browser/resources/hotword_audio_verification/flow.js
+++ b/chrome/browser/resources/hotword_audio_verification/flow.js
@@ -11,13 +11,6 @@
/** @const */ var SPEECH_TRAINING = 'speech-training-container';
/** @const */ var FINISHED = 'finished-container';
- /** @const */ var FLOWS = {
- HOTWORD_AND_AUDIO_HISTORY: [
- HOTWORD_AUDIO_HISTORY, SPEECH_TRAINING, FINISHED],
- HOTWORD_ONLY: [HOTWORD_ONLY_START, SPEECH_TRAINING, FINISHED],
- AUDIO_HISTORY_ONLY: [AUDIO_HISTORY_START]
- };
-
/**
* Class to control the page flow of the always-on hotword and
* Audio History opt-in process.
@@ -29,12 +22,15 @@
}
/**
- * Gets the appropriate flow and displays its first page.
+ * These flows correspond to the three LaunchModes as defined in
+ * chrome/browser/search/hotword_service.h and should be kept in sync
+ * with them.
*/
- Flow.prototype.startFlow = function() {
- this.currentFlow_ = getFlowForSetting_.apply(this);
- this.advanceStep();
- };
+ Flow.FLOWS_ = [
benwells 2014/09/09 20:57:30 Was there a reason to put this on Flow instead of
kcarattini 2014/09/10 08:14:28 No, it was done while I was debugging. Moved back
+ [AUDIO_HISTORY_START],
+ [HOTWORD_ONLY_START, SPEECH_TRAINING, FINISHED],
+ [HOTWORD_AUDIO_HISTORY, SPEECH_TRAINING, FINISHED]
+ ];
/**
* Advances the current step.
@@ -42,7 +38,15 @@
Flow.prototype.advanceStep = function() {
this.currentStepIndex_++;
if (this.currentStepIndex_ < this.currentFlow_.length)
- showStep_.apply(this);
+ this.showStep_.apply(this);
+ };
+
+ /**
+ * Gets the appropriate flow and displays its first page.
+ */
+ Flow.prototype.startFlow = function() {
+ chrome.hotwordAudioVerificationPrivate.getLaunchState(
+ this.getFlowForSetting_.bind(this));
};
// ---- private methods:
@@ -51,10 +55,9 @@
* Gets the appropriate flow for the current configuration of settings.
* @private
*/
- getFlowForSetting_ = function() {
- // TODO(kcarattini): This should eventually return the correct flow for
- // the current settings state.
- return FLOWS.HOTWORD_AND_AUDIO_HISTORY;
+ Flow.prototype.getFlowForSetting_ = function(state) {
benwells 2014/09/09 20:57:30 I think this function should be called startFlowFo
kcarattini 2014/09/10 08:14:28 Done.
+ this.currentFlow_ = Flow.FLOWS_[state.launchMode];
+ this.advanceStep();
};
/**
@@ -62,7 +65,7 @@
* also hides the previous step.
* @private
*/
- showStep_ = function() {
+ Flow.prototype.showStep_ = function() {
var currentStep = this.currentFlow_[this.currentStepIndex_];
var previousStep = null;
if (this.currentStepIndex_ > 0)

Powered by Google App Engine
This is Rietveld 408576698