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 * Trivial container class for session information. | 9 * Trivial container class for session information. |
10 * @param {!hotword.constants.SessionSource} source Source of the hotword | 10 * @param {!hotword.constants.SessionSource} source Source of the hotword |
(...skipping 24 matching lines...) Expand all Loading... |
35 * @private {?function()} | 35 * @private {?function()} |
36 */ | 36 */ |
37 this.startedCb_ = startedCb; | 37 this.startedCb_ = startedCb; |
38 } | 38 } |
39 | 39 |
40 /** | 40 /** |
41 * Class to manage hotwording state. Starts/stops the hotword detector based | 41 * Class to manage hotwording state. Starts/stops the hotword detector based |
42 * on user settings, session requests, and any other factors that play into | 42 * on user settings, session requests, and any other factors that play into |
43 * whether or not hotwording should be running. | 43 * whether or not hotwording should be running. |
44 * @constructor | 44 * @constructor |
45 * @struct | |
46 */ | 45 */ |
47 function StateManager() { | 46 function StateManager() { |
48 /** | 47 /** |
49 * Current state. | 48 * Current state. |
50 * @private {hotword.StateManager.State_} | 49 * @private {hotword.StateManager.State_} |
51 */ | 50 */ |
52 this.state_ = State_.STOPPED; | 51 this.state_ = State_.STOPPED; |
53 | 52 |
54 /** | 53 /** |
55 * Current hotwording status. | 54 * Current hotwording status. |
56 * @private {?chrome.hotwordPrivate.StatusDetails} | 55 * @private {?chrome.hotwordPrivate.StatusDetails} |
57 */ | 56 */ |
58 this.hotwordStatus_ = null; | 57 this.hotwordStatus_ = null; |
59 | 58 |
60 /** | 59 /** |
61 * NaCl plugin manager. | 60 * NaCl plugin manager. |
62 * @private {?hotword.NaClManager} | 61 * @private {?hotword.NaClManager} |
63 */ | 62 */ |
64 this.pluginManager_ = null; | 63 this.pluginManager_ = null; |
65 | 64 |
66 /** | 65 /** |
67 * Currently active hotwording sessions. | 66 * Currently active hotwording sessions. |
68 * @private {!Array.<hotword.Session_>} | 67 * @private {!Array.<Session_>} |
69 */ | 68 */ |
70 this.sessions_ = []; | 69 this.sessions_ = []; |
71 | 70 |
72 /** | 71 /** |
73 * Event that fires when the hotwording status has changed. | 72 * Event that fires when the hotwording status has changed. |
74 * @type {!chrome.Event} | 73 * @type {!ChromeEvent} |
75 */ | 74 */ |
76 this.onStatusChanged = new chrome.Event(); | 75 this.onStatusChanged = new chrome.Event(); |
77 | 76 |
78 /** | 77 /** |
79 * Hotword trigger audio notification... a.k.a The Chime (tm). | 78 * Hotword trigger audio notification... a.k.a The Chime (tm). |
80 * @private {!Audio} | 79 * @private {!HTMLAudioElement} |
81 */ | 80 */ |
82 this.chime_ = document.createElement('audio'); | 81 this.chime_ = |
| 82 /** @type {!HTMLAudioElement} */(document.createElement('audio')); |
83 | 83 |
84 // Get the initial status. | 84 // Get the initial status. |
85 chrome.hotwordPrivate.getStatus(this.handleStatus_.bind(this)); | 85 chrome.hotwordPrivate.getStatus(this.handleStatus_.bind(this)); |
86 | 86 |
87 // Setup the chime and insert into the page. | 87 // Setup the chime and insert into the page. |
88 this.chime_.src = chrome.extension.getURL( | 88 this.chime_.src = chrome.extension.getURL( |
89 hotword.constants.SHARED_MODULE_ROOT + '/audio/chime.wav'); | 89 hotword.constants.SHARED_MODULE_ROOT + '/audio/chime.wav'); |
90 document.body.appendChild(this.chime_); | 90 document.body.appendChild(this.chime_); |
91 } | 91 } |
92 | 92 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 hotword.debug('Stopping session for source: ' + source); | 341 hotword.debug('Stopping session for source: ' + source); |
342 this.removeSession_(source); | 342 this.removeSession_(source); |
343 this.updateStateFromStatus_(); | 343 this.updateStateFromStatus_(); |
344 } | 344 } |
345 }; | 345 }; |
346 | 346 |
347 return { | 347 return { |
348 StateManager: StateManager | 348 StateManager: StateManager |
349 }; | 349 }; |
350 }); | 350 }); |
OLD | NEW |