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/chrome_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 : public ChromeAsyncExtensionFunction {
     22  private:
     23   virtual ~TtsSpeakFunction() {}
     24   virtual bool RunImpl() OVERRIDE;
     25   DECLARE_EXTENSION_FUNCTION("tts.speak", TTS_SPEAK)
     26 };
     27 
     28 class TtsStopSpeakingFunction : public ChromeSyncExtensionFunction {
     29  private:
     30   virtual ~TtsStopSpeakingFunction() {}
     31   virtual bool RunImpl() OVERRIDE;
     32   DECLARE_EXTENSION_FUNCTION("tts.stop", TTS_STOP)
     33 };
     34 
     35 class TtsPauseFunction : public ChromeSyncExtensionFunction {
     36  private:
     37   virtual ~TtsPauseFunction() {}
     38   virtual bool RunImpl() OVERRIDE;
     39   DECLARE_EXTENSION_FUNCTION("tts.pause", TTS_PAUSE)
     40 };
     41 
     42 class TtsResumeFunction : public ChromeSyncExtensionFunction {
     43  private:
     44   virtual ~TtsResumeFunction() {}
     45   virtual bool RunImpl() OVERRIDE;
     46   DECLARE_EXTENSION_FUNCTION("tts.resume", TTS_RESUME)
     47 };
     48 
     49 class TtsIsSpeakingFunction : public ChromeSyncExtensionFunction {
     50  private:
     51   virtual ~TtsIsSpeakingFunction() {}
     52   virtual bool RunImpl() OVERRIDE;
     53   DECLARE_EXTENSION_FUNCTION("tts.isSpeaking", TTS_ISSPEAKING)
     54 };
     55 
     56 class TtsGetVoicesFunction : public ChromeSyncExtensionFunction {
     57  private:
     58   virtual ~TtsGetVoicesFunction() {}
     59   virtual bool RunImpl() OVERRIDE;
     60   DECLARE_EXTENSION_FUNCTION("tts.getVoices", TTS_GETVOICES)
     61 };
     62 
     63 class TtsAPI : public ProfileKeyedAPI {
     64  public:
     65   explicit TtsAPI(Profile* profile);
     66   virtual ~TtsAPI();
     67 
     68   // Convenience method to get the TtsAPI for a profile.
     69   static TtsAPI* Get(Profile* profile);
     70 
     71   // ProfileKeyedAPI implementation.
     72   static ProfileKeyedAPIFactory<TtsAPI>* GetFactoryInstance();
     73 
     74  private:
     75   friend class ProfileKeyedAPIFactory<TtsAPI>;
     76 
     77   // ProfileKeyedAPI implementation.
     78   static const char* service_name() {
     79     return "TtsAPI";
     80   }
     81   static const bool kServiceIsNULLWhileTesting = true;
     82 };
     83 
     84 }  // namespace extensions
     85 
     86 #endif  // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_EXTENSION_API_H_
     87