nsSynthVoiceRegistry::nsSynthVoiceRegistry() : mSpeechSynthChild(nullptr) { if (XRE_GetProcessType() == GeckoProcessType_Content) { mSpeechSynthChild = new SpeechSynthesisChild(); ContentChild::GetSingleton()->SendPSpeechSynthesisConstructor(mSpeechSynthChild); InfallibleTArray<RemoteVoice> voices; InfallibleTArray<nsString> defaults; mSpeechSynthChild->SendReadVoiceList(&voices, &defaults); for (uint32_t i = 0; i < voices.Length(); ++i) { RemoteVoice voice = voices[i]; AddVoiceImpl(nullptr, voice.voiceURI(), voice.name(), voice.lang(), voice.localService()); } for (uint32_t i = 0; i < defaults.Length(); ++i) { SetDefaultVoice(defaults[i], true); } } }
NS_IMETHODIMP nsSynthVoiceRegistry::AddVoice(nsISpeechService* aService, const nsAString& aUri, const nsAString& aName, const nsAString& aLang, bool aLocalService) { LOG(PR_LOG_DEBUG, ("nsSynthVoiceRegistry::AddVoice uri='%s' name='%s' lang='%s' local=%s", NS_ConvertUTF16toUTF8(aUri).get(), NS_ConvertUTF16toUTF8(aName).get(), NS_ConvertUTF16toUTF8(aLang).get(), aLocalService ? "true" : "false")); NS_ENSURE_FALSE(XRE_GetProcessType() == GeckoProcessType_Content, NS_ERROR_NOT_AVAILABLE); return AddVoiceImpl(aService, aUri, aName, aLang, aLocalService); }
NS_IMETHODIMP nsSynthVoiceRegistry::AddVoice(nsISpeechService* aService, const nsAString& aUri, const nsAString& aName, const nsAString& aLang, bool aLocalService) { LOG(LogLevel::Debug, ("nsSynthVoiceRegistry::AddVoice uri='%s' name='%s' lang='%s' local=%s", NS_ConvertUTF16toUTF8(aUri).get(), NS_ConvertUTF16toUTF8(aName).get(), NS_ConvertUTF16toUTF8(aLang).get(), aLocalService ? "true" : "false")); if(NS_WARN_IF(XRE_IsContentProcess())) { return NS_ERROR_NOT_AVAILABLE; } return AddVoiceImpl(aService, aUri, aName, aLang, aLocalService); }