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_EXTENSION_API_H_
      6 #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_
      7 
      8 #include <string>
      9 
     10 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
     11 #include "chrome/browser/extensions/extension_function.h"
     12 #include "chrome/browser/speech/tts_controller.h"
     13 
     14 class Profile;
     15 
     16 const char *TtsEventTypeToString(TtsEventType event_type);
     17 TtsEventType TtsEventTypeFromString(const std::string& str);
     18 
     19 namespace extensions {
     20 
     21 class TtsSpeakFunction
     22     : public AsyncExtensionFunction {
     23  private:
     24   virtual ~TtsSpeakFunction() {}
     25   virtual bool RunImpl() OVERRIDE;
     26   DECLARE_EXTENSION_FUNCTION("tts.speak", TTS_SPEAK)
     27 };
     28 
     29 class TtsStopSpeakingFunction : public SyncExtensionFunction {
     30  private:
     31   virtual ~TtsStopSpeakingFunction() {}
     32   virtual bool RunImpl() OVERRIDE;
     33   DECLARE_EXTENSION_FUNCTION("tts.stop", TTS_STOP)
     34 };
     35 
     36 class TtsPauseFunction : public SyncExtensionFunction {
     37  private:
     38   virtual ~TtsPauseFunction() {}
     39   virtual bool RunImpl() OVERRIDE;
     40   DECLARE_EXTENSION_FUNCTION("tts.pause", TTS_PAUSE)
     41 };
     42 
     43 class TtsResumeFunction : public SyncExtensionFunction {
     44  private:
     45   virtual ~TtsResumeFunction() {}
     46   virtual bool RunImpl() OVERRIDE;
     47   DECLARE_EXTENSION_FUNCTION("tts.resume", TTS_RESUME)
     48 };
     49 
     50 class TtsIsSpeakingFunction : public SyncExtensionFunction {
     51  private:
     52   virtual ~TtsIsSpeakingFunction() {}
     53   virtual bool RunImpl() OVERRIDE;
     54   DECLARE_EXTENSION_FUNCTION("tts.isSpeaking", TTS_ISSPEAKING)
     55 };
     56 
     57 class TtsGetVoicesFunction : public SyncExtensionFunction {
     58  private:
     59   virtual ~TtsGetVoicesFunction() {}
     60   virtual bool RunImpl() OVERRIDE;
     61   DECLARE_EXTENSION_FUNCTION("tts.getVoices", TTS_GETVOICES)
     62 };
     63 
     64 class TtsAPI : public ProfileKeyedAPI {
     65  public:
     66   explicit TtsAPI(Profile* profile);
     67   virtual ~TtsAPI();
     68 
     69   // Convenience method to get the TtsAPI for a profile.
     70   static TtsAPI* Get(Profile* profile);
     71 
     72   // ProfileKeyedAPI implementation.
     73   static ProfileKeyedAPIFactory<TtsAPI>* GetFactoryInstance();
     74 
     75  private:
     76   friend class ProfileKeyedAPIFactory<TtsAPI>;
     77 
     78   // ProfileKeyedAPI implementation.
     79   static const char* service_name() {
     80     return "TtsAPI";
     81   }
     82   static const bool kServiceIsNULLWhileTesting = true;
     83 };
     84 
     85 }  // namespace extensions
     86 
     87 #endif  // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_
     88