summaryrefslogtreecommitdiff
path: root/chromium/ui/app_list/speech_ui_model.cc
blob: 86955511930a8c3be69c983c6501d78784516bea (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
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2013 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.

#include "ui/app_list/speech_ui_model.h"

namespace app_list {

SpeechUIModel::SpeechUIModel() {}

SpeechUIModel::~SpeechUIModel() {}

void SpeechUIModel::SetSpeechResult(const base::string16& result,
                                    bool is_final) {
  if (result_ == result && is_final_ == is_final)
    return;

  result_ = result;
  is_final_ = is_final;
  FOR_EACH_OBSERVER(SpeechUIModelObserver,
                    observers_,
                    OnSpeechResult(result, is_final));
}

void SpeechUIModel::UpdateSoundLevel(int16 level) {
  if (sound_level_ == level)
    return;

  sound_level_ = level;
  FOR_EACH_OBSERVER(SpeechUIModelObserver,
                    observers_,
                    OnSpeechSoundLevelChanged(level));
}

void SpeechUIModel::SetSpeechRecognitionState(
    SpeechRecognitionState new_state) {
  if (state_ == new_state)
    return;

  state_ = new_state;
  FOR_EACH_OBSERVER(SpeechUIModelObserver,
                    observers_,
                    OnSpeechRecognitionStateChanged(new_state));
}

void SpeechUIModel::AddObserver(SpeechUIModelObserver* observer) {
  observers_.AddObserver(observer);
}

void SpeechUIModel::RemoveObserver(SpeechUIModelObserver* observer) {
  observers_.RemoveObserver(observer);
}

}  // namespace app_list