OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/app_list/speech_ui_model.h" |
| 6 |
| 7 #include "ui/app_list/search_box_model.h" |
| 8 |
| 9 namespace app_list { |
| 10 |
| 11 SpeechUIModel::SpeechUIModel(SearchBoxModel* search_box) |
| 12 : search_box_(search_box) {} |
| 13 |
| 14 SpeechUIModel::~SpeechUIModel() {} |
| 15 |
| 16 void SpeechUIModel::SetSpeechResult(const base::string16& result, |
| 17 bool is_final) { |
| 18 if (result_ == result && is_final_ == is_final) |
| 19 return; |
| 20 |
| 21 result_ = result; |
| 22 is_final_ = is_final; |
| 23 FOR_EACH_OBSERVER(SpeechUIModelObserver, |
| 24 observers_, |
| 25 OnSpeechResult(result, is_final)); |
| 26 if (is_final_) |
| 27 search_box_->SetText(result); |
| 28 } |
| 29 |
| 30 void SpeechUIModel::UpdateSoundLevel(int16 level) { |
| 31 if (sound_level_ == level) |
| 32 return; |
| 33 |
| 34 sound_level_ = level; |
| 35 FOR_EACH_OBSERVER(SpeechUIModelObserver, |
| 36 observers_, |
| 37 OnSpeechSoundLevelChanged(level)); |
| 38 } |
| 39 |
| 40 void SpeechUIModel::SetSpeechRecognitionState( |
| 41 SpeechRecognitionState new_state) { |
| 42 if (state_ == new_state) |
| 43 return; |
| 44 |
| 45 state_ = new_state; |
| 46 FOR_EACH_OBSERVER(SpeechUIModelObserver, |
| 47 observers_, |
| 48 OnSpeechRecognitionStateChanged(new_state)); |
| 49 } |
| 50 |
| 51 void SpeechUIModel::AddObserver(SpeechUIModelObserver* observer) { |
| 52 observers_.AddObserver(observer); |
| 53 } |
| 54 |
| 55 void SpeechUIModel::RemoveObserver(SpeechUIModelObserver* observer) { |
| 56 observers_.RemoveObserver(observer); |
| 57 } |
| 58 |
| 59 } // namespace app_list |
OLD | NEW |