| 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 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 chrome.tabs.onActivated.removeListener(this.tabActivatedListener_); | 409 chrome.tabs.onActivated.removeListener(this.tabActivatedListener_); |
| 410 chrome.windows.onFocusChanged.removeListener( | 410 chrome.windows.onFocusChanged.removeListener( |
| 411 this.windowFocusChangedListener_); | 411 this.windowFocusChangedListener_); |
| 412 }, | 412 }, |
| 413 | 413 |
| 414 /** | 414 /** |
| 415 * Update event listeners based on the current hotwording state. | 415 * Update event listeners based on the current hotwording state. |
| 416 * @private | 416 * @private |
| 417 */ | 417 */ |
| 418 updateListeners_: function() { | 418 updateListeners_: function() { |
| 419 var enabled = this.stateManager_.isEnabled() && | 419 if (this.stateManager_.isSometimesOnEnabled()) { |
| 420 !this.stateManager_.isAlwaysOnEnabled(); | |
| 421 if (enabled) { | |
| 422 this.setupListeners_(); | 420 this.setupListeners_(); |
| 423 } else { | 421 } else { |
| 424 this.removeListeners_(); | 422 this.removeListeners_(); |
| 425 this.stopHotwording_(); | 423 this.stopHotwording_(); |
| 426 this.disconnectAllClients_(); | 424 this.disconnectAllClients_(); |
| 427 } | 425 } |
| 428 } | 426 } |
| 429 }; | 427 }; |
| 430 | 428 |
| 431 return { | 429 return { |
| 432 PageAudioManager: PageAudioManager | 430 PageAudioManager: PageAudioManager |
| 433 }; | 431 }; |
| 434 }); | 432 }); |
| OLD | NEW |