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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_API_H_ 6#define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_API_H_ 7 8#include <vector> 9 10#include "base/memory/singleton.h" 11#include "chrome/browser/speech/tts_controller.h" 12#include "extensions/browser/extension_function.h" 13 14class Utterance; 15 16namespace base { 17class ListValue; 18} 19 20namespace content { 21class BrowserContext; 22} 23 24namespace extensions { 25class Extension; 26} 27 28namespace tts_engine_events { 29extern const char kOnSpeak[]; 30extern const char kOnStop[]; 31extern const char kOnPause[]; 32extern const char kOnResume[]; 33} 34 35// TtsEngineDelegate implementation used by TtsController. 36class TtsExtensionEngine : public TtsEngineDelegate { 37 public: 38 static TtsExtensionEngine* GetInstance(); 39 40 // Overridden from TtsEngineDelegate: 41 virtual void GetVoices(content::BrowserContext* browser_context, 42 std::vector<VoiceData>* out_voices) OVERRIDE; 43 virtual void Speak(Utterance* utterance, const VoiceData& voice) OVERRIDE; 44 virtual void Stop(Utterance* utterance) OVERRIDE; 45 virtual void Pause(Utterance* utterance) OVERRIDE; 46 virtual void Resume(Utterance* utterance) OVERRIDE; 47 virtual bool LoadBuiltInTtsExtension( 48 content::BrowserContext* browser_context) OVERRIDE; 49}; 50// Hidden/internal extension function used to allow TTS engine extensions 51// to send events back to the client that's calling tts.speak(). 52class ExtensionTtsEngineSendTtsEventFunction : public SyncExtensionFunction { 53 private: 54 virtual ~ExtensionTtsEngineSendTtsEventFunction() {} 55 virtual bool RunSync() OVERRIDE; 56 DECLARE_EXTENSION_FUNCTION("ttsEngine.sendTtsEvent", TTSENGINE_SENDTTSEVENT) 57}; 58 59#endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_API_H_ 60