Suppression for crbug/241044.
[chromium-blink-merge.git] / chrome / renderer / tts_dispatcher.h
blobbbebe6d920a65da89401ca8f6caa1e191b8fca78
1 // Copyright (c) 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.
5 #ifndef CHROME_RENDERER_TTS_DISPATCHER_H_
6 #define CHROME_RENDERER_TTS_DISPATCHER_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/hash_tables.h"
13 #include "content/public/renderer/render_process_observer.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebSpeechSynthesizer.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSpeechSynthesizerClient.h"
17 namespace IPC {
18 class Message;
21 struct TtsVoice;
23 // TtsDispatcher is a delegate for methods used by WebKit for
24 // speech synthesis APIs. It's the complement of
25 // TtsDispatcherHost (owned by RenderViewHost).
26 class TtsDispatcher
27 : public WebKit::WebSpeechSynthesizer,
28 public content::RenderProcessObserver {
29 public:
30 explicit TtsDispatcher(WebKit::WebSpeechSynthesizerClient* client);
32 private:
33 virtual ~TtsDispatcher();
35 // RenderProcessObserver override.
36 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
38 // WebKit::WebSpeechSynthesizer implementation.
39 virtual void updateVoiceList() OVERRIDE;
40 virtual void speak(const WebKit::WebSpeechSynthesisUtterance& utterance)
41 OVERRIDE;
42 virtual void pause() OVERRIDE;
43 virtual void resume() OVERRIDE;
44 virtual void cancel() OVERRIDE;
46 WebKit::WebSpeechSynthesisUtterance FindUtterance(int utterance_id);
48 void OnSetVoiceList(const std::vector<TtsVoice>& voices);
49 void OnDidStartSpeaking(int utterance_id);
50 void OnDidFinishSpeaking(int utterance_id);
51 void OnDidPauseSpeaking(int utterance_id);
52 void OnDidResumeSpeaking(int utterance_id);
53 void OnWordBoundary(int utterance_id, int char_index);
54 void OnSentenceBoundary(int utterance_id, int char_index);
55 void OnMarkerEvent(int utterance_id, int char_index);
56 void OnWasInterrupted(int utterance_id);
57 void OnWasCancelled(int utterance_id);
58 void OnSpeakingErrorOccurred(int utterance_id,
59 const std::string& error_message);
61 // The WebKit client class that we use to send events back to the JS world.
62 // Weak reference, this will be valid as long as this object exists.
63 WebKit::WebSpeechSynthesizerClient* synthesizer_client_;
65 // Next utterance id, used to map response IPCs to utterance objects.
66 static int next_utterance_id_;
68 // Map from id to utterance objects.
69 base::hash_map<int, WebKit::WebSpeechSynthesisUtterance> utterance_id_map_;
71 DISALLOW_COPY_AND_ASSIGN(TtsDispatcher);
74 #endif // CHROME_RENDERER_TTS_DISPATCHER_H_