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 (function() { |
| 6 'use strict'; |
6 | 7 |
7 /** | 8 /** |
8 * @fileoverview This extension provides hotword triggering capabilites to | 9 * @fileoverview This extension provides hotword triggering capabilites to |
9 * Chrome. | 10 * Chrome. |
10 * | 11 * |
11 * This extension contains all the JavaScript for loading and managing the | 12 * This extension contains all the JavaScript for loading and managing the |
12 * hotword detector. The hotword detector and language model data will be | 13 * hotword detector. The hotword detector and language model data will be |
13 * provided by a shared module loaded from the web store. | 14 * provided by a shared module loaded from the web store. |
14 */ | 15 * |
| 16 * IMPORTANT! Whenever adding new events, the extension version number MUST be |
| 17 * incremented. |
| 18 */ |
15 | 19 |
| 20 // Hotwording state. |
| 21 var stateManager = new hotword.StateManager(); |
| 22 |
| 23 // Detect Chrome startup and make sure we get a chance to run. |
| 24 chrome.runtime.onStartup.addListener(function() { |
| 25 stateManager.updateStatus(); |
| 26 }); |
| 27 |
| 28 // Detect when hotword settings have changed. |
| 29 chrome.hotwordPrivate.onEnabledChanged.addListener(function() { |
| 30 stateManager.updateStatus(); |
| 31 }); |
| 32 |
| 33 // Detect when the shared module containing the NaCL module and language model |
| 34 // is installed. |
| 35 chrome.management.onInstalled.addListener(function(info) { |
| 36 if (info.id == hotword.constants.SHARED_MODULE_ID) |
| 37 chrome.runtime.reload(); |
| 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 |
| 43 // user has enabled always-on hotwording. But for now, always signal the |
| 44 // start of a hotwording session. This allows this extension to work with |
| 45 // the app 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 }()); |
OLD | NEW |