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 var pageAudioManager = new hotword.PageAudioManager(stateManager); |
23 var alwaysOnManager = new hotword.AlwaysOnManager(stateManager); | 23 var alwaysOnManager = new hotword.AlwaysOnManager(stateManager); |
24 var launcherManager = new hotword.LauncherManager(stateManager); | 24 var launcherManager = new hotword.LauncherManager(stateManager); |
25 var trainingManager = new hotword.TrainingManager(stateManager); | 25 var trainingManager = new hotword.TrainingManager(stateManager); |
26 | 26 |
27 // Detect Chrome startup and make sure we get a chance to run. | |
28 chrome.runtime.onStartup.addListener(function() { | |
29 stateManager.updateStatus(); | |
30 }); | |
31 | |
32 // Detect when hotword settings have changed. | 27 // Detect when hotword settings have changed. |
33 chrome.hotwordPrivate.onEnabledChanged.addListener(function() { | 28 chrome.hotwordPrivate.onEnabledChanged.addListener(function() { |
34 stateManager.updateStatus(); | 29 stateManager.updateStatus(); |
35 }); | 30 }); |
36 | 31 |
37 // Detect a request to delete the speaker model. | 32 // Detect a request to delete the speaker model. |
38 chrome.hotwordPrivate.onDeleteSpeakerModel.addListener(function() { | 33 chrome.hotwordPrivate.onDeleteSpeakerModel.addListener(function() { |
39 hotword.TrainingManager.handleDeleteSpeakerModel(); | 34 hotword.TrainingManager.handleDeleteSpeakerModel(); |
40 }); | 35 }); |
41 | 36 |
42 // Detect a request for the speaker model existence. | 37 // Detect a request for the speaker model existence. |
43 chrome.hotwordPrivate.onSpeakerModelExists.addListener(function() { | 38 chrome.hotwordPrivate.onSpeakerModelExists.addListener(function() { |
44 hotword.TrainingManager.handleSpeakerModelExists(); | 39 hotword.TrainingManager.handleSpeakerModelExists(); |
45 }); | 40 }); |
46 | 41 |
47 // Detect when the shared module containing the NaCL module and language model | 42 // Detect when the shared module containing the NaCL module and language model |
48 // is installed. | 43 // is installed. |
49 chrome.management.onInstalled.addListener(function(info) { | 44 chrome.management.onInstalled.addListener(function(info) { |
50 if (info.id == hotword.constants.SHARED_MODULE_ID) { | 45 if (info.id == hotword.constants.SHARED_MODULE_ID) { |
51 hotword.debug('Shared module installed, reloading extension.'); | 46 hotword.debug('Shared module installed, reloading extension.'); |
52 chrome.runtime.reload(); | 47 chrome.runtime.reload(); |
53 } | 48 } |
54 }); | 49 }); |
55 }()); | 50 }()); |
OLD | NEW |