summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/hotword/always_on_manager.js
blob: 042a8d2d7e1a095c0486c95dfec7d935e0799325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

cr.define('hotword', function() {
  'use strict';

  /**
   * Class used to manage always-on hotwording. Automatically starts hotwording
   * on startup, if always-on is enabled, and starts/stops hotwording at
   * appropriate times.
   * @param {!hotword.StateManager} stateManager
   * @constructor
   * @extends {hotword.BaseSessionManager}
   */
  function AlwaysOnManager(stateManager) {
    hotword.BaseSessionManager.call(this,
                                    stateManager,
                                    hotword.constants.SessionSource.ALWAYS);
  }

  AlwaysOnManager.prototype = {
    __proto__: hotword.BaseSessionManager.prototype,

    /** @override */
     enabled: function() {
       return this.stateManager.isAlwaysOnEnabled();
     },

    /** @override */
    updateListeners: function() {
      hotword.BaseSessionManager.prototype.updateListeners.call(this);
      if (this.enabled())
        this.startSession();
    }
  };

  return {
    AlwaysOnManager: AlwaysOnManager
  };
});