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 cr.define('hotword', function() { | 5 cr.define('hotword', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Class used to manage always-on hotwording. Automatically starts hotwording | 9 * Class used to manage always-on hotwording. Automatically starts hotwording |
10 * on startup, if always-on is enabled, and starts/stops hotwording at | 10 * on startup, if always-on is enabled, and starts/stops hotwording at |
11 * appropriate times. | 11 * appropriate times. |
12 * @param {!hotword.StateManager} stateManager | 12 * @param {!hotword.StateManager} stateManager |
13 * @constructor | 13 * @constructor |
14 * @extends {hotword.BaseSessionManager} | 14 * @extends {hotword.BaseSessionManager} |
15 * @struct | |
16 */ | 15 */ |
17 function AlwaysOnManager(stateManager) { | 16 function AlwaysOnManager(stateManager) { |
18 hotword.BaseSessionManager.call(this, | 17 hotword.BaseSessionManager.call(this, |
19 stateManager, | 18 stateManager, |
20 hotword.constants.SessionSource.ALWAYS); | 19 hotword.constants.SessionSource.ALWAYS); |
21 } | 20 } |
22 | 21 |
23 AlwaysOnManager.prototype = { | 22 AlwaysOnManager.prototype = { |
24 __proto__: hotword.BaseSessionManager.prototype, | 23 __proto__: hotword.BaseSessionManager.prototype, |
25 | 24 |
26 /** override */ | 25 /** @override */ |
27 enabled: function() { | 26 enabled: function() { |
28 return this.stateManager.isAlwaysOnEnabled(); | 27 return this.stateManager.isAlwaysOnEnabled(); |
29 }, | 28 }, |
30 | 29 |
31 /** override */ | 30 /** @override */ |
32 updateListeners: function() { | 31 updateListeners: function() { |
33 hotword.BaseSessionManager.prototype.updateListeners.call(this); | 32 hotword.BaseSessionManager.prototype.updateListeners.call(this); |
34 if (this.enabled()) | 33 if (this.enabled()) |
35 this.startSession_(); | 34 this.startSession_(); |
36 } | 35 } |
37 }; | 36 }; |
38 | 37 |
39 return { | 38 return { |
40 AlwaysOnManager: AlwaysOnManager | 39 AlwaysOnManager: AlwaysOnManager |
41 }; | 40 }; |
42 }); | 41 }); |
OLD | NEW |