content/media/webspeech/synth/SpeechSynthesisVoice.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "SpeechSynthesis.h"
michael@0 8 #include "nsSynthVoiceRegistry.h"
michael@0 9 #include "mozilla/dom/SpeechSynthesisVoiceBinding.h"
michael@0 10
michael@0 11 namespace mozilla {
michael@0 12 namespace dom {
michael@0 13
michael@0 14 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(SpeechSynthesisVoice, mParent)
michael@0 15 NS_IMPL_CYCLE_COLLECTING_ADDREF(SpeechSynthesisVoice)
michael@0 16 NS_IMPL_CYCLE_COLLECTING_RELEASE(SpeechSynthesisVoice)
michael@0 17 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SpeechSynthesisVoice)
michael@0 18 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
michael@0 19 NS_INTERFACE_MAP_ENTRY(nsISupports)
michael@0 20 NS_INTERFACE_MAP_END
michael@0 21
michael@0 22 SpeechSynthesisVoice::SpeechSynthesisVoice(nsISupports* aParent,
michael@0 23 const nsAString& aUri)
michael@0 24 : mParent(aParent)
michael@0 25 , mUri(aUri)
michael@0 26 {
michael@0 27 SetIsDOMBinding();
michael@0 28 }
michael@0 29
michael@0 30 SpeechSynthesisVoice::~SpeechSynthesisVoice()
michael@0 31 {
michael@0 32 }
michael@0 33
michael@0 34 JSObject*
michael@0 35 SpeechSynthesisVoice::WrapObject(JSContext* aCx)
michael@0 36 {
michael@0 37 return SpeechSynthesisVoiceBinding::Wrap(aCx, this);
michael@0 38 }
michael@0 39
michael@0 40 nsISupports*
michael@0 41 SpeechSynthesisVoice::GetParentObject() const
michael@0 42 {
michael@0 43 return mParent;
michael@0 44 }
michael@0 45
michael@0 46 void
michael@0 47 SpeechSynthesisVoice::GetVoiceURI(nsString& aRetval) const
michael@0 48 {
michael@0 49 aRetval = mUri;
michael@0 50 }
michael@0 51
michael@0 52 void
michael@0 53 SpeechSynthesisVoice::GetName(nsString& aRetval) const
michael@0 54 {
michael@0 55 DebugOnly<nsresult> rv =
michael@0 56 nsSynthVoiceRegistry::GetInstance()->GetVoiceName(mUri, aRetval);
michael@0 57 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.name");
michael@0 58 }
michael@0 59
michael@0 60 void
michael@0 61 SpeechSynthesisVoice::GetLang(nsString& aRetval) const
michael@0 62 {
michael@0 63 DebugOnly<nsresult> rv =
michael@0 64 nsSynthVoiceRegistry::GetInstance()->GetVoiceLang(mUri, aRetval);
michael@0 65 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.lang");
michael@0 66 }
michael@0 67
michael@0 68 bool
michael@0 69 SpeechSynthesisVoice::LocalService() const
michael@0 70 {
michael@0 71 bool isLocal;
michael@0 72 DebugOnly<nsresult> rv =
michael@0 73 nsSynthVoiceRegistry::GetInstance()->IsLocalVoice(mUri, &isLocal);
michael@0 74 NS_WARN_IF_FALSE(
michael@0 75 NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.localService");
michael@0 76
michael@0 77 return isLocal;
michael@0 78 }
michael@0 79
michael@0 80 bool
michael@0 81 SpeechSynthesisVoice::Default() const
michael@0 82 {
michael@0 83 bool isDefault;
michael@0 84 DebugOnly<nsresult> rv =
michael@0 85 nsSynthVoiceRegistry::GetInstance()->IsDefaultVoice(mUri, &isDefault);
michael@0 86 NS_WARN_IF_FALSE(
michael@0 87 NS_SUCCEEDED(rv), "Failed to get SpeechSynthesisVoice.default");
michael@0 88
michael@0 89 return isDefault;
michael@0 90 }
michael@0 91
michael@0 92 } // namespace dom
michael@0 93 } // namespace mozilla

mercurial