tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SpeechSynthesisChild.h (3693B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef mozilla_dom_SpeechSynthesisChild_h
      6 #define mozilla_dom_SpeechSynthesisChild_h
      7 
      8 #include "mozilla/dom/PSpeechSynthesisChild.h"
      9 #include "mozilla/dom/PSpeechSynthesisRequestChild.h"
     10 #include "nsSpeechTask.h"
     11 
     12 namespace mozilla::dom {
     13 
     14 class nsSynthVoiceRegistry;
     15 class SpeechSynthesisRequestChild;
     16 class SpeechTaskChild;
     17 
     18 class SpeechSynthesisChild : public PSpeechSynthesisChild {
     19  friend class nsSynthVoiceRegistry;
     20  friend class PSpeechSynthesisChild;
     21 
     22 public:
     23  NS_INLINE_DECL_REFCOUNTING(SpeechSynthesisChild, override)
     24 
     25  mozilla::ipc::IPCResult RecvInitialVoicesAndState(
     26      nsTArray<RemoteVoice>&& aVoices, nsTArray<nsString>&& aDefaults,
     27      const bool& aIsSpeaking);
     28 
     29  mozilla::ipc::IPCResult RecvVoiceAdded(const RemoteVoice& aVoice);
     30 
     31  mozilla::ipc::IPCResult RecvVoiceRemoved(const nsAString& aUri);
     32 
     33  mozilla::ipc::IPCResult RecvSetDefaultVoice(const nsAString& aUri,
     34                                              const bool& aIsDefault);
     35 
     36  mozilla::ipc::IPCResult RecvIsSpeakingChanged(const bool& aIsSpeaking);
     37 
     38  mozilla::ipc::IPCResult RecvNotifyVoicesChanged();
     39 
     40  mozilla::ipc::IPCResult RecvNotifyVoicesError(const nsAString& aError);
     41 
     42 protected:
     43  SpeechSynthesisChild();
     44  virtual ~SpeechSynthesisChild();
     45 
     46  PSpeechSynthesisRequestChild* AllocPSpeechSynthesisRequestChild(
     47      const nsAString& aLang, const nsAString& aUri, const nsAString& aText,
     48      const float& aVolume, const float& aPitch, const float& aRate,
     49      const bool& aShouldResistFingerprinting);
     50  bool DeallocPSpeechSynthesisRequestChild(
     51      PSpeechSynthesisRequestChild* aActor);
     52 };
     53 
     54 class SpeechSynthesisRequestChild : public PSpeechSynthesisRequestChild {
     55 public:
     56  explicit SpeechSynthesisRequestChild(SpeechTaskChild* aTask);
     57  virtual ~SpeechSynthesisRequestChild();
     58 
     59 protected:
     60  mozilla::ipc::IPCResult RecvOnStart(const nsAString& aUri) override;
     61 
     62  mozilla::ipc::IPCResult RecvOnEnd(const bool& aIsError,
     63                                    const float& aElapsedTime,
     64                                    const uint32_t& aCharIndex) override;
     65 
     66  mozilla::ipc::IPCResult RecvOnPause(const float& aElapsedTime,
     67                                      const uint32_t& aCharIndex) override;
     68 
     69  mozilla::ipc::IPCResult RecvOnResume(const float& aElapsedTime,
     70                                       const uint32_t& aCharIndex) override;
     71 
     72  mozilla::ipc::IPCResult RecvOnBoundary(const nsAString& aName,
     73                                         const float& aElapsedTime,
     74                                         const uint32_t& aCharIndex,
     75                                         const uint32_t& aCharLength,
     76                                         const uint8_t& argc) override;
     77 
     78  mozilla::ipc::IPCResult RecvOnMark(const nsAString& aName,
     79                                     const float& aElapsedTime,
     80                                     const uint32_t& aCharIndex) override;
     81 
     82  RefPtr<SpeechTaskChild> mTask;
     83 };
     84 
     85 class SpeechTaskChild : public nsSpeechTask {
     86  friend class SpeechSynthesisRequestChild;
     87 
     88 public:
     89  explicit SpeechTaskChild(SpeechSynthesisUtterance* aUtterance,
     90                           bool aShouldResistFingerprinting);
     91 
     92  NS_IMETHOD Setup(nsISpeechTaskCallback* aCallback) override;
     93 
     94  void Pause() override;
     95 
     96  void Resume() override;
     97 
     98  void Cancel() override;
     99 
    100  void ForceEnd() override;
    101 
    102  void SetAudioOutputVolume(float aVolume) override;
    103 
    104 private:
    105  SpeechSynthesisRequestChild* mActor;
    106 };
    107 
    108 }  // namespace mozilla::dom
    109 
    110 #endif