OLD | NEW |
---|---|
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 |
5 'use strict'; | 5 'use strict'; |
Dan Beam
2014/08/27 20:08:36
we generally scope 'use strict' just in case files
| |
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 */ | 14 */ |
15 | 15 |
16 // Hotwording state. | |
17 var stateManager = new hotword.StateManager(); | |
18 | |
19 // Detect Chrome startup and make sure we get a chance to run. | |
20 chrome.runtime.onStartup.addListener(function() { | |
21 stateManager.updateStatus(); | |
22 }.bind(this)); | |
Dan Beam
2014/08/26 18:40:51
remove .bind(this)
Anand Mistry (off Chromium)
2014/08/27 07:10:55
Done.
| |
23 | |
24 // Detect when hotword settings have changed. | |
25 chrome.hotwordPrivate.onEnabledChanged.addListener(function() { | |
26 stateManager.updateStatus(); | |
27 }.bind(this)); | |
Dan Beam
2014/08/26 18:40:51
remove .bind(this)
Anand Mistry (off Chromium)
2014/08/27 07:10:55
Done.
| |
28 | |
29 // Detect when the shared module containing the NaCL module and language model | |
30 // is installed. | |
31 chrome.management.onInstalled.addListener(function(info) { | |
32 if (info.id == hotword.constants.SHARED_MODULE_ID) { | |
Dan Beam
2014/08/26 18:40:51
nit: no curlies
Anand Mistry (off Chromium)
2014/08/27 07:10:55
Looking into this, the style guide gives no prefer
Dan Beam
2014/08/27 20:08:36
chrome is quite consistent on this rule.
Anand Mistry (off Chromium)
2014/08/28 00:59:25
Thanks. Both those pages point to the google style
| |
33 chrome.runtime.reload(); | |
34 } | |
35 }); | |
36 | |
37 // Detect when a session has requested to be started and stopped. | |
38 chrome.hotwordPrivate.onHotwordSessionRequested.addListener(function() { | |
39 // TODO(amistry): This event should change state depending on whether the user | |
40 // has enabled always-on hotwording. But for now, always signal the start of a | |
41 // hotwording session. This allows this extension to work with the app | |
42 // launcher in the current state. | |
43 chrome.hotwordPrivate.setHotwordSessionState(true, function() {}); | |
44 }); | |
45 | |
46 chrome.hotwordPrivate.onHotwordSessionStopped.addListener(function() { | |
47 chrome.hotwordPrivate.setHotwordSessionState(false, function() {}); | |
48 }); | |
49 | |
OLD | NEW |