| 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 the interaction between hotwording and the | 9 * Class used to manage the interaction between hotwording and the |
| 10 * NTP/google.com. Injects a content script to interact with NTP/google.com | 10 * NTP/google.com. Injects a content script to interact with NTP/google.com |
| 11 * and updates the global hotwording state based on interaction with those | 11 * and updates the global hotwording state based on interaction with those |
| 12 * pages. | 12 * pages. |
| 13 * @param {!hotword.StateManager} stateManager | 13 * @param {!hotword.StateManager} stateManager |
| 14 * @constructor | 14 * @constructor |
| 15 */ | 15 */ |
| 16 function PageAudioManager(stateManager) { | 16 function PageAudioManager(stateManager) { |
| 17 /** | 17 /** |
| 18 * Manager of global hotwording state. | 18 * Manager of global hotwording state. |
| 19 * @private {!hotword.StateManager} | 19 * @private {!hotword.StateManager} |
| 20 */ | 20 */ |
| 21 this.stateManager_ = stateManager; | 21 this.stateManager_ = stateManager; |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Mapping between tab ID and port that is connected from the injected | 24 * Mapping between tab ID and port that is connected from the injected |
| 25 * content script. | 25 * content script. |
| 26 * @private {!Object.<number, Port>} | 26 * @private {!Object<number, Port>} |
| 27 */ | 27 */ |
| 28 this.portMap_ = {}; | 28 this.portMap_ = {}; |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * Chrome event listeners. Saved so that they can be de-registered when | 31 * Chrome event listeners. Saved so that they can be de-registered when |
| 32 * hotwording is disabled. | 32 * hotwording is disabled. |
| 33 */ | 33 */ |
| 34 this.connectListener_ = this.handleConnect_.bind(this); | 34 this.connectListener_ = this.handleConnect_.bind(this); |
| 35 this.tabCreatedListener_ = this.handleCreatedTab_.bind(this); | 35 this.tabCreatedListener_ = this.handleCreatedTab_.bind(this); |
| 36 this.tabUpdatedListener_ = this.handleUpdatedTab_.bind(this); | 36 this.tabUpdatedListener_ = this.handleUpdatedTab_.bind(this); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 this.stopHotwording_(); | 438 this.stopHotwording_(); |
| 439 this.disconnectAllClients_(); | 439 this.disconnectAllClients_(); |
| 440 } | 440 } |
| 441 } | 441 } |
| 442 }; | 442 }; |
| 443 | 443 |
| 444 return { | 444 return { |
| 445 PageAudioManager: PageAudioManager | 445 PageAudioManager: PageAudioManager |
| 446 }; | 446 }; |
| 447 }); | 447 }); |
| OLD | NEW |