Chromium Code Reviews| Index: ui/app_list/speech_ui_model.h |
| diff --git a/ui/app_list/speech_ui_model.h b/ui/app_list/speech_ui_model.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d0b473d33e4a42b0e226aced7a10a52f27d9958a |
| --- /dev/null |
| +++ b/ui/app_list/speech_ui_model.h |
| @@ -0,0 +1,68 @@ |
| +// 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. |
| + |
| +#ifndef UI_APP_LIST_SPEECH_UI_MODEL_H_ |
| +#define UI_APP_LIST_SPEECH_UI_MODEL_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/observer_list.h" |
| +#include "base/strings/string16.h" |
| +#include "ui/app_list/app_list_export.h" |
| + |
| +namespace app_list { |
| + |
| +class SearchBoxModel; |
| + |
| +enum SpeechRecognitionState { |
| + SPEECH_RECOGNITION_NOT_STARTED = 0, |
| + SPEECH_RECOGNITION_ON, |
| + SPEECH_RECOGNITION_IN_SPEECH, |
| +}; |
| + |
| +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_
|
| + public: |
| + // Invoked when sound level for the speech recognition has changed. |
| + virtual void OnSpeechSoundLevelChanged(int16 level) {} |
| + |
| + // Invoked when a speech result arrives. |is_final| is true only when the |
| + // speech result is final. |
| + virtual void OnSpeechResult(const base::string16& result, bool is_final) {} |
| + |
| + // Invoked when the state of speech recognition is changed. |
| + virtual void OnSpeechRecognitionStateChanged( |
| + SpeechRecognitionState new_state) {} |
| +}; |
|
xiyuan
2013/12/05 22:06:30
nit: add
protected:
virtual ~SpeechUIModelObser
Jun Mukai
2013/12/06 00:31:10
Done.
|
| + |
| +// SpeechUIModel provides the interface to update the UI for speech recognition. |
| +class APP_LIST_EXPORT SpeechUIModel { |
| + public: |
| + SpeechUIModel(SearchBoxModel* search_box); |
|
xiyuan
2013/12/05 22:06:30
nit: explicit
Jun Mukai
2013/12/06 00:31:10
removed the parameter.
|
| + virtual ~SpeechUIModel(); |
| + |
| + const base::string16& result() const { return result_; } |
| + bool is_final() const { return is_final_; } |
| + int16 sound_level() const { return sound_level_; } |
| + 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.
|
| + |
| + void SetSpeechResult(const base::string16& result, bool is_final); |
| + void UpdateSoundLevel(int16 level); |
| + void SetSpeechRecognitionState(SpeechRecognitionState new_state); |
| + |
| + void AddObserver(SpeechUIModelObserver* observer); |
| + void RemoveObserver(SpeechUIModelObserver* observer); |
| + |
| + private: |
| + base::string16 result_; |
| + bool is_final_; |
| + int16 sound_level_; |
| + SpeechRecognitionState state_; |
| + |
| + 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.
|
| + |
| + ObserverList<SpeechUIModelObserver> observers_; |
| +}; |
| + |
| +} // namespace app_list |
| + |
| +#endif // UI_APP_LIST_SPEECH_UI_MODEL_H_ |