1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_
6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_
10 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/speech/tts_platform.h"
12 #include "content/public/test/test_utils.h"
16 // For testing purpose installs itself as the platform speech synthesis engine,
17 // allowing it to intercept all speech calls, and then provides a method to
18 // block until the next utterance is spoken.
19 class SpeechMonitor
: public TtsPlatformImpl
{
22 virtual ~SpeechMonitor();
24 // Blocks until the next utterance is spoken, and returns its text.
25 std::string
GetNextUtterance();
27 // Wait for next utterance and return true if next utterance is ChromeVox
29 bool SkipChromeVoxEnabledMessage();
31 // TtsPlatformImpl implementation.
32 virtual bool PlatformImplAvailable() OVERRIDE
;
35 const std::string
& utterance
,
36 const std::string
& lang
,
37 const VoiceData
& voice
,
38 const UtteranceContinuousParameters
& params
) OVERRIDE
;
39 virtual bool StopSpeaking() OVERRIDE
;
40 virtual bool IsSpeaking() OVERRIDE
;
41 virtual void GetVoices(std::vector
<VoiceData
>* out_voices
) OVERRIDE
;
42 virtual void Pause() OVERRIDE
{}
43 virtual void Resume() OVERRIDE
{}
44 virtual std::string
error() OVERRIDE
;
45 virtual void clear_error() OVERRIDE
{}
46 virtual void set_error(const std::string
& error
) OVERRIDE
{}
47 virtual void WillSpeakUtteranceWithVoice(
48 const Utterance
* utterance
, const VoiceData
& voice_data
) OVERRIDE
;
51 scoped_refptr
<content::MessageLoopRunner
> loop_runner_
;
52 std::deque
<std::string
> utterance_queue_
;
54 DISALLOW_COPY_AND_ASSIGN(SpeechMonitor
);
57 } // namespace chromeos
59 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_