| 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 | 45 * @class |
| 46 */ | 46 */ |
| 47 function StateManager() { | 47 function StateManager() { |
| 48 /** | 48 /** |
| 49 * Current state. | 49 * Current state. |
| 50 * @private {hotword.StateManager.State_} | 50 * @private {hotword.StateManager.State_} |
| 51 */ | 51 */ |
| 52 this.state_ = State_.STOPPED; | 52 this.state_ = State_.STOPPED; |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Current hotwording status. | 55 * Current hotwording status. |
| 56 * @private {?chrome.hotwordPrivate.StatusDetails} | 56 * @private {?chrome.hotwordPrivate.StatusDetails} |
| 57 */ | 57 */ |
| 58 this.hotwordStatus_ = null; | 58 this.hotwordStatus_ = null; |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * NaCl plugin manager. | 61 * NaCl plugin manager. |
| 62 * @private {?hotword.NaClManager} | 62 * @private {?hotword.NaClManager} |
| 63 */ | 63 */ |
| 64 this.pluginManager_ = null; | 64 this.pluginManager_ = null; |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * Currently active hotwording sessions. | 67 * Currently active hotwording sessions. |
| 68 * @private {!Array.<hotword.Session_>} | 68 * @private {!Array.<Session_>} |
| 69 */ | 69 */ |
| 70 this.sessions_ = []; | 70 this.sessions_ = []; |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * Event that fires when the hotwording status has changed. | 73 * Event that fires when the hotwording status has changed. |
| 74 * @type {!chrome.Event} | 74 * @type {!ChromeEvent} |
| 75 */ | 75 */ |
| 76 this.onStatusChanged = new chrome.Event(); | 76 this.onStatusChanged = new chrome.Event(); |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Hotword trigger audio notification... a.k.a The Chime (tm). | 79 * Hotword trigger audio notification... a.k.a The Chime (tm). |
| 80 * @private {!Audio} | 80 * @private {!HTMLAudioElement} |
| 81 */ | 81 */ |
| 82 this.chime_ = document.createElement('audio'); | 82 this.chime_ = |
| 83 /** @type {!HTMLAudioElement} */(document.createElement('audio')); |
| 83 | 84 |
| 84 // Get the initial status. | 85 // Get the initial status. |
| 85 chrome.hotwordPrivate.getStatus(this.handleStatus_.bind(this)); | 86 chrome.hotwordPrivate.getStatus(this.handleStatus_.bind(this)); |
| 86 | 87 |
| 87 // Setup the chime and insert into the page. | 88 // Setup the chime and insert into the page. |
| 88 this.chime_.src = chrome.extension.getURL( | 89 this.chime_.src = chrome.extension.getURL( |
| 89 hotword.constants.SHARED_MODULE_ROOT + '/audio/chime.wav'); | 90 hotword.constants.SHARED_MODULE_ROOT + '/audio/chime.wav'); |
| 90 document.body.appendChild(this.chime_); | 91 document.body.appendChild(this.chime_); |
| 91 } | 92 } |
| 92 | 93 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 hotword.debug('Stopping session for source: ' + source); | 342 hotword.debug('Stopping session for source: ' + source); |
| 342 this.removeSession_(source); | 343 this.removeSession_(source); |
| 343 this.updateStateFromStatus_(); | 344 this.updateStateFromStatus_(); |
| 344 } | 345 } |
| 345 }; | 346 }; |
| 346 | 347 |
| 347 return { | 348 return { |
| 348 StateManager: StateManager | 349 StateManager: StateManager |
| 349 }; | 350 }; |
| 350 }); | 351 }); |
| OLD | NEW |