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

Unified Diff: chrome/browser/resources/app_list/speech_manager.js

Issue 158143002: Fine tuned availability of hotword plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 10 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/app_list/speech_manager.js
diff --git a/chrome/browser/resources/app_list/speech_manager.js b/chrome/browser/resources/app_list/speech_manager.js
index d58a53f4db78c7ccaaa57625660a816dd6f33e9f..ebb3afec9014604a8df9c24e7cbe5ab96f13bafa 100644
--- a/chrome/browser/resources/app_list/speech_manager.js
+++ b/chrome/browser/resources/app_list/speech_manager.js
@@ -127,8 +127,8 @@ cr.define('speech', function() {
this.setState_(SpeechState.HOTWORD_RECOGNIZING);
} else {
this.audioManager_.stop();
+ this.setState_(SpeechState.READY);
}
- chrome.send('setSpeechRecognitionState', ['off']);
};
/**
@@ -158,19 +158,30 @@ cr.define('speech', function() {
};
/**
- * Initialize the hotword plugin manager, or do nothing if already
- * initialization is on.
- */
- SpeechManager.prototype.maybeInitializePlugin = function() {
- if ($('recognizer'))
- return;
-
- var pluginManager = new speech.PluginManager(
- this.onHotwordRecognizerReady_.bind(this),
- this.onHotwordRecognized_.bind(this));
- pluginManager.scheduleInitialize(
- this.audioManager_.getSampleRate(),
- 'chrome://app-list/okgoogle_hotword.config');
+ * Changes the availability of the hotword plugin.
+ *
+ * @param {boolean} enabled Whether enabled or not.
+ */
+ SpeechManager.prototype.setHotwordEnabled = function(enabled) {
+ var recognizer = $('recognizer');
+ if (enabled) {
+ if (recognizer)
+ return;
+
+ var pluginManager = new speech.PluginManager(
+ this.onHotwordRecognizerReady_.bind(this),
+ this.onHotwordRecognized_.bind(this));
+ pluginManager.scheduleInitialize(
+ this.audioManager_.getSampleRate(),
+ 'chrome://app-list/okgoogle_hotword.config');
+ } else {
+ if (!recognizer)
+ return;
+ document.body.removeChild(recognizer);
+ this.pluginManager_ = null;
+ if (this.state == SpeechState.HOTWORD_RECOGNIZING)
+ this.setState(SpeechState.READY);
+ }
};
/**

Powered by Google App Engine
This is Rietveld 408576698