Bug 1839316: part 5) Guard the "fetchpriority" attribute behind a pref. r=kershaw...
[gecko.git] / widget / nsSoundProxy.cpp
blobe991fa240ecf4373394dc8f638361f6239c60158
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
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "mozilla/dom/ContentChild.h"
6 #include "mozilla/ipc/URIUtils.h"
7 #include "nsIURL.h"
8 #include "nsIURI.h"
9 #include "nsSoundProxy.h"
11 using namespace mozilla;
12 using namespace mozilla::dom;
14 NS_IMPL_ISUPPORTS(nsSoundProxy, nsISound)
16 NS_IMETHODIMP
17 nsSoundProxy::Play(nsIURL* aURL) {
18 MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
19 // Only allow playing a chrome:// URL from the content process.
20 if (!aURL || !aURL->SchemeIs("chrome")) {
21 return NS_ERROR_FAILURE;
24 ContentChild::GetSingleton()->SendPlaySound(aURL);
25 return NS_OK;
28 NS_IMETHODIMP
29 nsSoundProxy::Beep() {
30 MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
32 ContentChild::GetSingleton()->SendBeep();
33 return NS_OK;
36 NS_IMETHODIMP
37 nsSoundProxy::Init() {
38 MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
39 MOZ_DIAGNOSTIC_ASSERT(false, "Only called by XUL in the parent process.");
40 return NS_ERROR_NOT_IMPLEMENTED;
43 NS_IMETHODIMP
44 nsSoundProxy::PlayEventSound(uint32_t aEventId) {
45 MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
47 ContentChild::GetSingleton()->SendPlayEventSound(aEventId);
48 return NS_OK;