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

Unified Diff: chrome/browser/resources/hotword/manager.js

Issue 493203004: Add a StateManager for managing hotwording state based on various factors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hotword-nacl-manager
Patch Set: Rebase. 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/manager.js
diff --git a/chrome/browser/resources/hotword/manager.js b/chrome/browser/resources/hotword/manager.js
index 7315bbe7af58cc5aa2728dc62a6b466cc1e13e84..43a7bb9e976f7b09b0bb783ed892182f64ea8c0d 100644
--- a/chrome/browser/resources/hotword/manager.js
+++ b/chrome/browser/resources/hotword/manager.js
@@ -2,14 +2,51 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-'use strict';
+(function() {
+ 'use strict';
-/**
- * @fileoverview This extension provides hotword triggering capabilites to
- * Chrome.
- *
- * This extension contains all the JavaScript for loading and managing the
- * hotword detector. The hotword detector and language model data will be
- * provided by a shared module loaded from the web store.
- */
+ /**
+ * @fileoverview This extension provides hotword triggering capabilites to
+ * Chrome.
+ *
+ * This extension contains all the JavaScript for loading and managing the
+ * hotword detector. The hotword detector and language model data will be
+ * provided by a shared module loaded from the web store.
+ *
+ * IMPORTANT! Whenever adding new events, the extension version number MUST be
+ * incremented.
+ */
+ // Hotwording state.
+ var stateManager = new hotword.StateManager();
+
+ // Detect Chrome startup and make sure we get a chance to run.
+ chrome.runtime.onStartup.addListener(function() {
+ stateManager.updateStatus();
+ });
+
+ // Detect when hotword settings have changed.
+ chrome.hotwordPrivate.onEnabledChanged.addListener(function() {
+ stateManager.updateStatus();
+ });
+
+ // Detect when the shared module containing the NaCL module and language model
+ // is installed.
+ chrome.management.onInstalled.addListener(function(info) {
+ if (info.id == hotword.constants.SHARED_MODULE_ID)
+ chrome.runtime.reload();
+ });
+
+ // Detect when a session has requested to be started and stopped.
+ chrome.hotwordPrivate.onHotwordSessionRequested.addListener(function() {
+ // TODO(amistry): This event should change state depending on whether the
+ // user has enabled always-on hotwording. But for now, always signal the
+ // start of a hotwording session. This allows this extension to work with
+ // the app launcher in the current state.
+ chrome.hotwordPrivate.setHotwordSessionState(true, function() {});
+ });
+
+ chrome.hotwordPrivate.onHotwordSessionStopped.addListener(function() {
+ chrome.hotwordPrivate.setHotwordSessionState(false, function() {});
+ });
+}());
« no previous file with comments | « chrome/browser/resources/component_extension_resources.grd ('k') | chrome/browser/resources/hotword/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698