Chromium Code Reviews| 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 #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 | |
| 13 namespace app_list { | |
| 14 | |
| 15 class SearchBoxModel; | |
| 16 | |
| 17 enum SpeechRecognitionState { | |
| 18 SPEECH_RECOGNITION_NOT_STARTED = 0, | |
| 19 SPEECH_RECOGNITION_ON, | |
| 20 SPEECH_RECOGNITION_IN_SPEECH, | |
| 21 }; | |
| 22 | |
| 23 class SpeechUIModelObserver { | |
|
xiyuan
2013/12/05 22:06:30
nit: Separate header file for observer interface i
xiyuan
2013/12/05 22:06:30
nit: Does this need APP_LIST_EXPORT as well?
Jun Mukai
2013/12/06 00:31:10
Done.
Jun Mukai
2013/12/06 00:31:10
Done. Right now this isn't used outside of ui/app_
| |
| 24 public: | |
| 25 // Invoked when sound level for the speech recognition has changed. | |
| 26 virtual void OnSpeechSoundLevelChanged(int16 level) {} | |
| 27 | |
| 28 // Invoked when a speech result arrives. |is_final| is true only when the | |
| 29 // speech result is final. | |
| 30 virtual void OnSpeechResult(const base::string16& result, bool is_final) {} | |
| 31 | |
| 32 // Invoked when the state of speech recognition is changed. | |
| 33 virtual void OnSpeechRecognitionStateChanged( | |
| 34 SpeechRecognitionState new_state) {} | |
| 35 }; | |
|
xiyuan
2013/12/05 22:06:30
nit: add
protected:
virtual ~SpeechUIModelObser
Jun Mukai
2013/12/06 00:31:10
Done.
| |
| 36 | |
| 37 // SpeechUIModel provides the interface to update the UI for speech recognition. | |
| 38 class APP_LIST_EXPORT SpeechUIModel { | |
| 39 public: | |
| 40 SpeechUIModel(SearchBoxModel* search_box); | |
|
xiyuan
2013/12/05 22:06:30
nit: explicit
Jun Mukai
2013/12/06 00:31:10
removed the parameter.
| |
| 41 virtual ~SpeechUIModel(); | |
| 42 | |
| 43 const base::string16& result() const { return result_; } | |
| 44 bool is_final() const { return is_final_; } | |
| 45 int16 sound_level() const { return sound_level_; } | |
| 46 SpeechRecognitionState state() const { return state_; } | |
|
xiyuan
2013/12/05 22:06:30
nit: accessors after other functions per style gui
Jun Mukai
2013/12/06 00:31:10
Done.
| |
| 47 | |
| 48 void SetSpeechResult(const base::string16& result, bool is_final); | |
| 49 void UpdateSoundLevel(int16 level); | |
| 50 void SetSpeechRecognitionState(SpeechRecognitionState new_state); | |
| 51 | |
| 52 void AddObserver(SpeechUIModelObserver* observer); | |
| 53 void RemoveObserver(SpeechUIModelObserver* observer); | |
| 54 | |
| 55 private: | |
| 56 base::string16 result_; | |
| 57 bool is_final_; | |
| 58 int16 sound_level_; | |
| 59 SpeechRecognitionState state_; | |
| 60 | |
| 61 SearchBoxModel* search_box_; // Weak | |
|
xiyuan
2013/12/05 22:06:30
Could we get rid of this reference by updating the
Jun Mukai
2013/12/06 00:31:10
Done.
| |
| 62 | |
| 63 ObserverList<SpeechUIModelObserver> observers_; | |
| 64 }; | |
| 65 | |
| 66 } // namespace app_list | |
| 67 | |
| 68 #endif // UI_APP_LIST_SPEECH_UI_MODEL_H_ | |
| OLD | NEW |