Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/renderer/tts_dispatcher.h

Issue 12589005: Implement web speech synthesis. (Closed) Base URL: http://git.chromium.org/chromium/src.git@webtts
Patch Set: Fix android build Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | chrome/renderer/tts_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_RENDERER_TTS_DISPATCHER_H_
6 #define CHROME_RENDERER_TTS_DISPATCHER_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/hash_tables.h"
12 #include "content/public/renderer/render_view.h"
13 #include "ipc/ipc_channel_proxy.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebSpeechSynthesize r.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSpeechSynthesize rClient.h"
16
17 class RenderViewImpl;
18 struct TtsVoice;
19
20 // TtsDispatcher is a delegate for methods used by WebKit for
21 // speech synthesis APIs. It's the complement of
22 // TtsDispatcherHost (owned by RenderViewHost).
23 class TtsDispatcher
24 : public WebKit::WebSpeechSynthesizer,
25 public IPC::ChannelProxy::MessageFilter {
26 public:
27 explicit TtsDispatcher(WebKit::WebSpeechSynthesizerClient* client);
28
29 private:
30 virtual ~TtsDispatcher();
31
32 // IPC::ChannelProxy::MessageFilter override.
33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
34
35 // WebKit::WebSpeechSynthesizer implementation.
36 virtual void updateVoiceList() OVERRIDE;
37 virtual void speak(const WebKit::WebSpeechSynthesisUtterance& utterance)
38 OVERRIDE;
39 virtual void pause() OVERRIDE;
40 virtual void resume() OVERRIDE;
41 virtual void cancel() OVERRIDE;
42
43 WebKit::WebSpeechSynthesisUtterance FindUtterance(int utterance_id);
44
45 void OnSetVoiceList(const std::vector<TtsVoice>& voices);
46 void OnDidStartSpeaking(int utterance_id);
47 void OnDidFinishSpeaking(int utterance_id);
48 void OnDidPauseSpeaking(int utterance_id);
49 void OnDidResumeSpeaking(int utterance_id);
50 void OnWordBoundary(int utterance_id, int char_index);
51 void OnSentenceBoundary(int utterance_id, int char_index);
52 void OnMarkerEvent(int utterance_id, int char_index);
53 void OnWasInterrupted(int utterance_id);
54 void OnWasCancelled(int utterance_id);
55 void OnSpeakingErrorOccurred(int utterance_id,
56 const std::string& error_message);
57
58 // The WebKit client class that we use to send events back to the JS world.
59 // Weak reference, this will be valid as long as this object exists.
60 WebKit::WebSpeechSynthesizerClient* synthesizer_client_;
61
62 // Message loop for the main render thread. Utilized to
63 // ensure that callbacks into WebKit happen on the main thread
64 // instead of the originating IO thread.
65 scoped_refptr<base::MessageLoopProxy> main_loop_;
66
67 // Next utterance id, used to map response IPCs to utterance objects.
68 static int next_utterance_id_;
69
70 // Map from id to utterance objects.
71 base::hash_map<int, WebKit::WebSpeechSynthesisUtterance> utterance_id_map_;
72
73 DISALLOW_COPY_AND_ASSIGN(TtsDispatcher);
74 };
75
76 #endif // CHROME_RENDERER_TTS_DISPATCHER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | chrome/renderer/tts_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698