Home | History | Annotate | Download | only in extension_api
      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 
     14 class Utterance;
     15 
     16 namespace base {
     17 class ListValue;
     18 }
     19 
     20 namespace content {
     21 class BrowserContext;
     22 }
     23 
     24 namespace extensions {
     25 class Extension;
     26 }
     27 
     28 namespace tts_engine_events {
     29 extern const char kOnSpeak[];
     30 extern const char kOnStop[];
     31 extern const char kOnPause[];
     32 extern const char kOnResume[];
     33 }
     34 
     35 // TtsEngineDelegate implementation used by TtsController.
     36 class 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().
     52 class 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