/src/mozilla-central/widget/nsSoundProxy.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
4 | | |
5 | | #include "mozilla/dom/ContentChild.h" |
6 | | #include "mozilla/ipc/URIUtils.h" |
7 | | #include "nsIURL.h" |
8 | | #include "nsIURI.h" |
9 | | #include "nsSoundProxy.h" |
10 | | |
11 | | using namespace mozilla; |
12 | | using namespace mozilla::dom; |
13 | | |
14 | | NS_IMPL_ISUPPORTS(nsSoundProxy, nsISound) |
15 | | |
16 | | NS_IMETHODIMP |
17 | | nsSoundProxy::Play(nsIURL *aURL) |
18 | 0 | { |
19 | 0 | MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content); |
20 | 0 |
|
21 | 0 | nsCOMPtr<nsIURI> soundURI(do_QueryInterface(aURL)); |
22 | 0 | bool isChrome = false; |
23 | 0 | // Only allow playing a chrome:// URL from the content process. |
24 | 0 | if (!soundURI || NS_FAILED(soundURI->SchemeIs("chrome", &isChrome)) || !isChrome) { |
25 | 0 | return NS_ERROR_FAILURE; |
26 | 0 | } |
27 | 0 | |
28 | 0 | mozilla::ipc::URIParams soundParams; |
29 | 0 | mozilla::ipc::SerializeURI(soundURI, soundParams); |
30 | 0 | ContentChild::GetSingleton()->SendPlaySound(soundParams); |
31 | 0 | return NS_OK; |
32 | 0 | } |
33 | | |
34 | | NS_IMETHODIMP |
35 | | nsSoundProxy::Beep() |
36 | 0 | { |
37 | 0 | MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content); |
38 | 0 |
|
39 | 0 | ContentChild::GetSingleton()->SendBeep(); |
40 | 0 | return NS_OK; |
41 | 0 | } |
42 | | |
43 | | NS_IMETHODIMP |
44 | | nsSoundProxy::Init() |
45 | 0 | { |
46 | 0 | MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content); |
47 | 0 | MOZ_DIAGNOSTIC_ASSERT(false, "Only called by XUL in the parent process."); |
48 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
49 | 0 | } |
50 | | |
51 | | NS_IMETHODIMP |
52 | | nsSoundProxy::PlayEventSound(uint32_t aEventId) |
53 | 0 | { |
54 | 0 | MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content); |
55 | 0 |
|
56 | 0 | ContentChild::GetSingleton()->SendPlayEventSound(aEventId); |
57 | 0 | return NS_OK; |
58 | 0 | } |