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

Side by Side Diff: chrome/browser/speech/tts_controller.h

Issue 188633003: Revert of Eliminate the dependence of tts extension API for tts_controller.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_
6 #define CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ 6 #define CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // If true, the synthesis engine is a remote network resource. 70 // If true, the synthesis engine is a remote network resource.
71 // It may be higher latency and may incur bandwidth costs. 71 // It may be higher latency and may incur bandwidth costs.
72 bool remote; 72 bool remote;
73 73
74 // If true, this is implemented by this platform's subclass of 74 // If true, this is implemented by this platform's subclass of
75 // TtsPlatformImpl. If false, this is implemented by an extension. 75 // TtsPlatformImpl. If false, this is implemented by an extension.
76 bool native; 76 bool native;
77 std::string native_voice_identifier; 77 std::string native_voice_identifier;
78 }; 78 };
79 79
80 // Interface that delegates TTS requests to user-installed extensions.
81 class TtsEngineDelegate {
82 public:
83 virtual ~TtsEngineDelegate() {}
84
85 // Return a list of all available voices registered.
86 virtual void GetVoices(Profile* profile,
87 std::vector<VoiceData>* out_voices) = 0;
88
89 // Speak the given utterance by sending an event to the given TTS engine.
90 virtual void Speak(Utterance* utterance, const VoiceData& voice) = 0;
91
92 // Stop speaking the given utterance by sending an event to the target
93 // associated with this utterance.
94 virtual void Stop(Utterance* utterance) = 0;
95
96 // Pause in the middle of speaking this utterance.
97 virtual void Pause(Utterance* utterance) = 0;
98
99 // Resume speaking this utterance.
100 virtual void Resume(Utterance* utterance) = 0;
101 };
102
103 // Class that wants to receive events on utterances. 80 // Class that wants to receive events on utterances.
104 class UtteranceEventDelegate { 81 class UtteranceEventDelegate {
105 public: 82 public:
106 virtual ~UtteranceEventDelegate() {} 83 virtual ~UtteranceEventDelegate() {}
107 virtual void OnTtsEvent(Utterance* utterance, 84 virtual void OnTtsEvent(Utterance* utterance,
108 TtsEventType event_type, 85 TtsEventType event_type,
109 int char_index, 86 int char_index,
110 const std::string& error_message) = 0; 87 const std::string& error_message) = 0;
111 }; 88 };
112 89
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // Called by the extension system or platform implementation when the 290 // Called by the extension system or platform implementation when the
314 // list of voices may have changed and should be re-queried. 291 // list of voices may have changed and should be re-queried.
315 void VoicesChanged(); 292 void VoicesChanged();
316 293
317 // Add a delegate that wants to be notified when the set of voices changes. 294 // Add a delegate that wants to be notified when the set of voices changes.
318 void AddVoicesChangedDelegate(VoicesChangedDelegate* delegate); 295 void AddVoicesChangedDelegate(VoicesChangedDelegate* delegate);
319 296
320 // Remove delegate that wants to be notified when the set of voices changes. 297 // Remove delegate that wants to be notified when the set of voices changes.
321 void RemoveVoicesChangedDelegate(VoicesChangedDelegate* delegate); 298 void RemoveVoicesChangedDelegate(VoicesChangedDelegate* delegate);
322 299
323 // Set the delegate that processes TTS requests with user-installed
324 // extensions.
325 void SetTtsEngineDelegate(TtsEngineDelegate* delegate);
326
327 // For unit testing. 300 // For unit testing.
328 void SetPlatformImpl(TtsPlatformImpl* platform_impl); 301 void SetPlatformImpl(TtsPlatformImpl* platform_impl);
329 int QueueSize(); 302 int QueueSize();
330 303
331 protected: 304 protected:
332 TtsController(); 305 TtsController();
333 virtual ~TtsController(); 306 virtual ~TtsController();
334 307
335 private: 308 private:
336 // Get the platform TTS implementation (or injected mock). 309 // Get the platform TTS implementation (or injected mock).
(...skipping 29 matching lines...) Expand all
366 // A queue of utterances to speak after the current one finishes. 339 // A queue of utterances to speak after the current one finishes.
367 std::queue<Utterance*> utterance_queue_; 340 std::queue<Utterance*> utterance_queue_;
368 341
369 // A set of delegates that want to be notified when the voices change. 342 // A set of delegates that want to be notified when the voices change.
370 std::set<VoicesChangedDelegate*> voices_changed_delegates_; 343 std::set<VoicesChangedDelegate*> voices_changed_delegates_;
371 344
372 // A pointer to the platform implementation of text-to-speech, for 345 // A pointer to the platform implementation of text-to-speech, for
373 // dependency injection. 346 // dependency injection.
374 TtsPlatformImpl* platform_impl_; 347 TtsPlatformImpl* platform_impl_;
375 348
376 // The delegate that processes TTS requests with user-installed extensions.
377 TtsEngineDelegate* tts_engine_delegate_;
378
379 DISALLOW_COPY_AND_ASSIGN(TtsController); 349 DISALLOW_COPY_AND_ASSIGN(TtsController);
380 }; 350 };
381 351
382 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ 352 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/speech/extension_api/tts_engine_extension_api.cc ('k') | chrome/browser/speech/tts_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698