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#ifndef UI_APP_LIST_SPEECH_UI_MODEL_H_ 6#define UI_APP_LIST_SPEECH_UI_MODEL_H_ 7 8#include "base/basictypes.h" 9#include "base/observer_list.h" 10#include "base/strings/string16.h" 11#include "ui/app_list/app_list_export.h" 12#include "ui/app_list/speech_ui_model_observer.h" 13#include "ui/gfx/image/image_skia.h" 14 15namespace app_list { 16 17// SpeechUIModel provides the interface to update the UI for speech recognition. 18class APP_LIST_EXPORT SpeechUIModel { 19 public: 20 // Construct the model, initially in state SPEECH_RECOGNITION_OFF. 21 SpeechUIModel(); 22 virtual ~SpeechUIModel(); 23 24 void SetSpeechResult(const base::string16& result, bool is_final); 25 void UpdateSoundLevel(int16 level); 26 void SetSpeechRecognitionState(SpeechRecognitionState new_state); 27 28 void AddObserver(SpeechUIModelObserver* observer); 29 void RemoveObserver(SpeechUIModelObserver* observer); 30 31 const base::string16& result() const { return result_; } 32 bool is_final() const { return is_final_; } 33 int16 sound_level() const { return sound_level_; } 34 SpeechRecognitionState state() const { return state_; } 35 const gfx::ImageSkia& logo() const { return logo_; } 36 void set_logo(const gfx::ImageSkia& logo) { logo_ = logo; } 37 38 private: 39 base::string16 result_; 40 bool is_final_; 41 int16 sound_level_; 42 SpeechRecognitionState state_; 43 44 // The logo image which the speech UI will show at the top-left. 45 gfx::ImageSkia logo_; 46 47 // The sound level range to compute visible sound-level. 48 int16 minimum_sound_level_; 49 int16 maximum_sound_level_; 50 51 ObserverList<SpeechUIModelObserver> observers_; 52 53 DISALLOW_COPY_AND_ASSIGN(SpeechUIModel); 54}; 55 56} // namespace app_list 57 58#endif // UI_APP_LIST_SPEECH_UI_MODEL_H_ 59