Bug 1859643 - Remove nsSoundProxy. r=spohl,win-reviewers

nsISound is no longer used in content processes.

Differential Revision: https://phabricator.services.mozilla.com/D192115
This commit is contained in:
Andrew McCreight 2023-11-06 16:27:07 +00:00
parent 97b5a446c0
commit a3fd771d1d
11 changed files with 6 additions and 147 deletions

View File

@ -218,7 +218,6 @@
#include "nsIScriptSecurityManager.h"
#include "nsIServiceWorkerManager.h"
#include "nsISiteSecurityService.h"
#include "nsISound.h"
#include "nsIStringBundle.h"
#include "nsITimer.h"
#include "nsIURL.h"
@ -3631,47 +3630,6 @@ ContentParent::AllocPClipboardWriteRequestParent(
return request.forget();
}
mozilla::ipc::IPCResult ContentParent::RecvPlaySound(nsIURI* aURI) {
// If the check here fails, it can only mean that this message was spoofed.
if (!aURI || !aURI->SchemeIs("chrome")) {
// PlaySound only accepts a valid chrome URI.
return IPC_FAIL(this, "Invalid aURI passed.");
}
nsCOMPtr<nsIURL> soundURL(do_QueryInterface(aURI));
if (!soundURL) {
return IPC_OK();
}
nsresult rv;
nsCOMPtr<nsISound> sound(do_GetService(NS_SOUND_CID, &rv));
NS_ENSURE_SUCCESS(rv, IPC_OK());
sound->Play(soundURL);
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvBeep() {
nsresult rv;
nsCOMPtr<nsISound> sound(do_GetService(NS_SOUND_CID, &rv));
NS_ENSURE_SUCCESS(rv, IPC_OK());
sound->Beep();
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvPlayEventSound(
const uint32_t& aEventId) {
nsresult rv;
nsCOMPtr<nsISound> sound(do_GetService(NS_SOUND_CID, &rv));
NS_ENSURE_SUCCESS(rv, IPC_OK());
sound->PlayEventSound(aEventId);
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvGetIconForExtension(
const nsACString& aFileExt, const uint32_t& aIconSize,
nsTArray<uint8_t>* bits) {

View File

@ -1002,10 +1002,6 @@ class ContentParent final : public PContentParent,
already_AddRefed<PClipboardWriteRequestParent>
AllocPClipboardWriteRequestParent(const int32_t& aClipboardType);
mozilla::ipc::IPCResult RecvPlaySound(nsIURI* aURI);
mozilla::ipc::IPCResult RecvBeep();
mozilla::ipc::IPCResult RecvPlayEventSound(const uint32_t& aEventId);
mozilla::ipc::IPCResult RecvGetIconForExtension(const nsACString& aFileExt,
const uint32_t& aIconSize,
nsTArray<uint8_t>* bits);

View File

@ -1240,12 +1240,6 @@ parent:
*/
async PClipboardWriteRequest(int32_t aClipboardType);
// 'Play', 'Beep' and 'PlayEventSound' are the only nsISound methods used in
// the content process.
[Compress] async PlaySound(nullable nsIURI aURL);
[Compress] async Beep();
[Compress] async PlayEventSound(uint32_t aEventId);
sync GetIconForExtension(nsCString aFileExt, uint32_t aIconSize)
returns (uint8_t[] bits);

View File

@ -44,8 +44,8 @@ Classes = [
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_UTILITY_AND_GMPLUGIN_PROCESS,
},
{
'cid': '{15cc80a9-5329-4fcb-9a0b-c6cf1440ae51}',
'contract_ids': ['@mozilla.org/parent/sound;1'],
'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}',
'contract_ids': ['@mozilla.org/sound;1'],
'type': 'nsSound',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},

View File

@ -64,21 +64,6 @@ Classes = [
'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
},
{
'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}',
'contract_ids': ['@mozilla.org/sound;1'],
'singleton': True,
'constructor': 'nsSoundSelector',
'headers': ['/widget/nsContentProcessWidgetFactory.h'],
},
{
'cid': '{b02c2470-6e5a-4865-a202-8b5ebae52632}',
'type': 'nsSoundProxy',
'headers': ['/widget/nsSoundProxy.h'],
'contract_ids': ['@mozilla.org/content/sound;1'],
'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
},
{
'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}',
'contract_ids': ['@mozilla.org/gfx/screenmanager;1'],

View File

@ -55,8 +55,8 @@ Classes = [
'headers': ['/widget/nsHTMLFormatConverter.h'],
},
{
'cid': '{e711c28b-c1f1-4b87-8448-e1e0da0a7b7d}',
'contract_ids': ['@mozilla.org/parent/sound;1'],
'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}',
'contract_ids': ['@mozilla.org/sound;1'],
'singleton': True,
'type': 'nsISound',
'constructor': 'nsSound::GetInstance',

View File

@ -242,7 +242,6 @@ UNIFIED_SOURCES += [
"nsIWidgetListener.cpp",
"nsPrimitiveHelpers.cpp",
"nsPrintSettingsImpl.cpp",
"nsSoundProxy.cpp",
"nsTransferable.cpp",
"nsUserIdleService.cpp",
"nsXPLookAndFeel.cpp",

View File

@ -47,8 +47,6 @@ MAKE_COMPONENT_CHOOSER(nsScreenManagerSelector,
"@mozilla.org/gfx/parent/screenmanager;1",
"@mozilla.org/gfx/content/screenmanager;1",
do_GetService)
MAKE_COMPONENT_CHOOSER(nsSoundSelector, "@mozilla.org/parent/sound;1",
"@mozilla.org/content/sound;1", do_GetService)
MAKE_COMPONENT_CHOOSER(nsDragServiceSelector,
"@mozilla.org/widget/parent/dragservice;1",
"@mozilla.org/widget/content/dragservice;1",

View File

@ -1,49 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/ContentChild.h"
#include "mozilla/ipc/URIUtils.h"
#include "nsIURL.h"
#include "nsIURI.h"
#include "nsSoundProxy.h"
using namespace mozilla;
using namespace mozilla::dom;
NS_IMPL_ISUPPORTS(nsSoundProxy, nsISound)
NS_IMETHODIMP
nsSoundProxy::Play(nsIURL* aURL) {
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
// Only allow playing a chrome:// URL from the content process.
if (!aURL || !aURL->SchemeIs("chrome")) {
return NS_ERROR_FAILURE;
}
ContentChild::GetSingleton()->SendPlaySound(aURL);
return NS_OK;
}
NS_IMETHODIMP
nsSoundProxy::Beep() {
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
ContentChild::GetSingleton()->SendBeep();
return NS_OK;
}
NS_IMETHODIMP
nsSoundProxy::Init() {
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
MOZ_DIAGNOSTIC_ASSERT(false, "Only called by XUL in the parent process.");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsSoundProxy::PlayEventSound(uint32_t aEventId) {
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
ContentChild::GetSingleton()->SendPlayEventSound(aEventId);
return NS_OK;
}

View File

@ -1,22 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef NS_SOUND_PROXY_H
#define NS_SOUND_PROXY_H
#include "nsISound.h"
class nsSoundProxy final : public nsISound {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOUND
nsSoundProxy() = default;
private:
~nsSoundProxy() = default;
};
#endif

View File

@ -37,8 +37,8 @@ Classes = [
'headers': ['/widget/windows/nsUserIdleServiceWin.h', 'nsUserIdleService.h'],
},
{
'cid': '{919f1217-073a-4a14-b034-67d461eccacc}',
'contract_ids': ['@mozilla.org/parent/sound;1'],
'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}',
'contract_ids': ['@mozilla.org/sound;1'],
'singleton': True,
'type': 'nsISound',
'constructor': 'nsSound::GetInstance',