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

Side by Side 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: Address review comments. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
Dan Beam 2014/08/27 20:08:36 (function() {
Anand Mistry (off Chromium) 2014/08/28 00:59:25 Done. But as a JS noob, why? Is it avoid leaking v
Dan Beam 2014/09/03 19:08:19 http://jslinterrors.com/use-the-function-form-of-u
5 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @fileoverview This extension provides hotword triggering capabilites to 8 * @fileoverview This extension provides hotword triggering capabilites to
9 * Chrome. 9 * Chrome.
10 * 10 *
11 * This extension contains all the JavaScript for loading and managing the 11 * This extension contains all the JavaScript for loading and managing the
12 * hotword detector. The hotword detector and language model data will be 12 * hotword detector. The hotword detector and language model data will be
13 * provided by a shared module loaded from the web store. 13 * provided by a shared module loaded from the web store.
14 *
15 * IMPORTANT! Whenever adding new events, the extension version number MUST be
16 * incremented.
14 */ 17 */
15 18
19 // Hotwording state.
20 var stateManager = new hotword.StateManager();
21
22 // Detect Chrome startup and make sure we get a chance to run.
23 chrome.runtime.onStartup.addListener(function() {
24 stateManager.updateStatus();
25 });
26
27 // Detect when hotword settings have changed.
28 chrome.hotwordPrivate.onEnabledChanged.addListener(function() {
29 stateManager.updateStatus();
30 });
31
32 // Detect when the shared module containing the NaCL module and language model
33 // is installed.
34 chrome.management.onInstalled.addListener(function(info) {
35 if (info.id == hotword.constants.SHARED_MODULE_ID) {
Dan Beam 2014/08/27 20:08:36 no curlies
Anand Mistry (off Chromium) 2014/08/28 00:59:25 Done.
36 chrome.runtime.reload();
37 }
38 });
39
40 // Detect when a session has requested to be started and stopped.
41 chrome.hotwordPrivate.onHotwordSessionRequested.addListener(function() {
42 // TODO(amistry): This event should change state depending on whether the user
43 // has enabled always-on hotwording. But for now, always signal the start of a
44 // hotwording session. This allows this extension to work with the app
45 // launcher in the current state.
46 chrome.hotwordPrivate.setHotwordSessionState(true, function() {});
47 });
48
49 chrome.hotwordPrivate.onHotwordSessionStopped.addListener(function() {
50 chrome.hotwordPrivate.setHotwordSessionState(false, function() {});
51 });
52
Dan Beam 2014/08/27 20:08:36 }());
Anand Mistry (off Chromium) 2014/08/28 00:59:25 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698