| 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 (function() { | 5 (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * @fileoverview This extension provides hotword triggering capabilites to | 9 * @fileoverview This extension provides hotword triggering capabilites to |
| 10 * Chrome. | 10 * Chrome. |
| 11 * | 11 * |
| 12 * This extension contains all the JavaScript for loading and managing the | 12 * This extension contains all the JavaScript for loading and managing the |
| 13 * hotword detector. The hotword detector and language model data will be | 13 * hotword detector. The hotword detector and language model data will be |
| 14 * provided by a shared module loaded from the web store. | 14 * provided by a shared module loaded from the web store. |
| 15 * | 15 * |
| 16 * IMPORTANT! Whenever adding new events, the extension version number MUST be | 16 * IMPORTANT! Whenever adding new events, the extension version number MUST be |
| 17 * incremented. | 17 * incremented. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 // Hotwording state. | 20 // Hotwording state. |
| 21 var stateManager = new hotword.StateManager(); | 21 var stateManager = new hotword.StateManager(); |
| 22 var pageAudioManager = new hotword.PageAudioManager(stateManager); |
| 22 | 23 |
| 23 // Detect Chrome startup and make sure we get a chance to run. | 24 // Detect Chrome startup and make sure we get a chance to run. |
| 24 chrome.runtime.onStartup.addListener(function() { | 25 chrome.runtime.onStartup.addListener(function() { |
| 25 stateManager.updateStatus(); | 26 stateManager.updateStatus(); |
| 26 }); | 27 }); |
| 27 | 28 |
| 28 // Detect when hotword settings have changed. | 29 // Detect when hotword settings have changed. |
| 29 chrome.hotwordPrivate.onEnabledChanged.addListener(function() { | 30 chrome.hotwordPrivate.onEnabledChanged.addListener(function() { |
| 30 stateManager.updateStatus(); | 31 stateManager.updateStatus(); |
| 31 }); | 32 }); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 chrome.hotwordPrivate.onHotwordSessionRequested.addListener(function() { | 44 chrome.hotwordPrivate.onHotwordSessionRequested.addListener(function() { |
| 44 hotword.debug('hotwordPrivate.onHotwordSessionRequested'); | 45 hotword.debug('hotwordPrivate.onHotwordSessionRequested'); |
| 45 // TODO(amistry): This event should change state depending on whether the | 46 // TODO(amistry): This event should change state depending on whether the |
| 46 // user has enabled always-on hotwording. But for now, always signal the | 47 // user has enabled always-on hotwording. But for now, always signal the |
| 47 // start of a hotwording session. This allows this extension to work with | 48 // start of a hotwording session. This allows this extension to work with |
| 48 // the app launcher in the current state. | 49 // the app launcher in the current state. |
| 49 stateManager.startSession( | 50 stateManager.startSession( |
| 50 hotword.constants.SessionSource.LAUNCHER, | 51 hotword.constants.SessionSource.LAUNCHER, |
| 51 function() { | 52 function() { |
| 52 chrome.hotwordPrivate.setHotwordSessionState(true, function() {}); | 53 chrome.hotwordPrivate.setHotwordSessionState(true, function() {}); |
| 54 }, |
| 55 function() { |
| 56 chrome.hotwordPrivate.notifyHotwordRecognition('search', |
| 57 function() {}); |
| 53 }); | 58 }); |
| 54 }); | 59 }); |
| 55 | 60 |
| 56 chrome.hotwordPrivate.onHotwordSessionStopped.addListener(function() { | 61 chrome.hotwordPrivate.onHotwordSessionStopped.addListener(function() { |
| 57 hotword.debug('hotwordPrivate.onHotwordSessionStopped'); | 62 hotword.debug('hotwordPrivate.onHotwordSessionStopped'); |
| 58 stateManager.stopSession(hotword.constants.SessionSource.LAUNCHER); | 63 stateManager.stopSession(hotword.constants.SessionSource.LAUNCHER); |
| 59 chrome.hotwordPrivate.setHotwordSessionState(false, function() {}); | 64 chrome.hotwordPrivate.setHotwordSessionState(false, function() {}); |
| 60 }); | 65 }); |
| 61 }()); | 66 }()); |
| OLD | NEW |