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

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

Issue 374243004: Eliminate the dependence of tts extension API form tts_controller.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Skip the instantiation of TtsExtensionEngine for android. Created 6 years, 5 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
80 // Class that wants to receive events on utterances. 103 // Class that wants to receive events on utterances.
81 class UtteranceEventDelegate { 104 class UtteranceEventDelegate {
82 public: 105 public:
83 virtual ~UtteranceEventDelegate() {} 106 virtual ~UtteranceEventDelegate() {}
84 virtual void OnTtsEvent(Utterance* utterance, 107 virtual void OnTtsEvent(Utterance* utterance,
85 TtsEventType event_type, 108 TtsEventType event_type,
86 int char_index, 109 int char_index,
87 const std::string& error_message) = 0; 110 const std::string& error_message) = 0;
88 }; 111 };
89 112
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // Called by the extension system or platform implementation when the 313 // Called by the extension system or platform implementation when the
291 // list of voices may have changed and should be re-queried. 314 // list of voices may have changed and should be re-queried.
292 void VoicesChanged(); 315 void VoicesChanged();
293 316
294 // Add a delegate that wants to be notified when the set of voices changes. 317 // Add a delegate that wants to be notified when the set of voices changes.
295 void AddVoicesChangedDelegate(VoicesChangedDelegate* delegate); 318 void AddVoicesChangedDelegate(VoicesChangedDelegate* delegate);
296 319
297 // Remove delegate that wants to be notified when the set of voices changes. 320 // Remove delegate that wants to be notified when the set of voices changes.
298 void RemoveVoicesChangedDelegate(VoicesChangedDelegate* delegate); 321 void RemoveVoicesChangedDelegate(VoicesChangedDelegate* delegate);
299 322
323 // Set the delegate that processes TTS requests with user-installed
324 // extensions.
325 void SetTtsEngineDelegate(TtsEngineDelegate* delegate);
326
300 // For unit testing. 327 // For unit testing.
301 void SetPlatformImpl(TtsPlatformImpl* platform_impl); 328 void SetPlatformImpl(TtsPlatformImpl* platform_impl);
302 int QueueSize(); 329 int QueueSize();
303 330
304 protected: 331 protected:
305 TtsController(); 332 TtsController();
306 virtual ~TtsController(); 333 virtual ~TtsController();
307 334
308 private: 335 private:
309 // Get the platform TTS implementation (or injected mock). 336 // Get the platform TTS implementation (or injected mock).
(...skipping 29 matching lines...) Expand all
339 // A queue of utterances to speak after the current one finishes. 366 // A queue of utterances to speak after the current one finishes.
340 std::queue<Utterance*> utterance_queue_; 367 std::queue<Utterance*> utterance_queue_;
341 368
342 // A set of delegates that want to be notified when the voices change. 369 // A set of delegates that want to be notified when the voices change.
343 std::set<VoicesChangedDelegate*> voices_changed_delegates_; 370 std::set<VoicesChangedDelegate*> voices_changed_delegates_;
344 371
345 // A pointer to the platform implementation of text-to-speech, for 372 // A pointer to the platform implementation of text-to-speech, for
346 // dependency injection. 373 // dependency injection.
347 TtsPlatformImpl* platform_impl_; 374 TtsPlatformImpl* platform_impl_;
348 375
376 // The delegate that processes TTS requests with user-installed extensions.
377 TtsEngineDelegate* tts_engine_delegate_;
378
349 DISALLOW_COPY_AND_ASSIGN(TtsController); 379 DISALLOW_COPY_AND_ASSIGN(TtsController);
350 }; 380 };
351 381
352 #endif // CHROME_BROWSER_SPEECH_TTS_CONTROLLER_H_ 382 #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