2014-09-20 10:20:41 +04:00
|
|
|
/* 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/MediaDevices.h"
|
|
|
|
#include "mozilla/dom/MediaStreamBinding.h"
|
2016-02-17 00:55:33 +03:00
|
|
|
#include "mozilla/dom/MediaDeviceInfo.h"
|
2014-09-20 10:20:41 +04:00
|
|
|
#include "mozilla/dom/MediaDevicesBinding.h"
|
2018-07-28 07:40:26 +03:00
|
|
|
#include "mozilla/dom/NavigatorBinding.h"
|
2014-09-20 10:20:41 +04:00
|
|
|
#include "mozilla/dom/Promise.h"
|
|
|
|
#include "mozilla/MediaManager.h"
|
2015-07-02 21:21:49 +03:00
|
|
|
#include "MediaTrackConstraints.h"
|
2017-09-19 04:56:48 +03:00
|
|
|
#include "nsContentUtils.h"
|
2014-09-20 10:20:41 +04:00
|
|
|
#include "nsIEventTarget.h"
|
2017-07-26 21:18:20 +03:00
|
|
|
#include "nsINamed.h"
|
2014-09-20 10:20:41 +04:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
2015-03-03 17:51:05 +03:00
|
|
|
#include "nsIPermissionManager.h"
|
2014-09-20 10:20:41 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2015-04-15 19:47:03 +03:00
|
|
|
#include "nsQueryObject.h"
|
2014-09-20 10:20:41 +04:00
|
|
|
|
2017-01-26 19:08:06 +03:00
|
|
|
#define DEVICECHANGE_HOLD_TIME_IN_MS 1000
|
|
|
|
|
2014-09-20 10:20:41 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2017-07-26 21:18:20 +03:00
|
|
|
class FuzzTimerCallBack final : public nsITimerCallback, public nsINamed {
|
2017-01-26 19:08:06 +03:00
|
|
|
~FuzzTimerCallBack() {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit FuzzTimerCallBack(MediaDevices* aMediaDevices)
|
|
|
|
: mMediaDevices(aMediaDevices) {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2018-02-06 09:46:57 +03:00
|
|
|
NS_IMETHOD Notify(nsITimer* aTimer) final {
|
2017-01-26 19:08:06 +03:00
|
|
|
mMediaDevices->DispatchTrustedEvent(NS_LITERAL_STRING("devicechange"));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-26 21:18:20 +03:00
|
|
|
NS_IMETHOD GetName(nsACString& aName) override {
|
|
|
|
aName.AssignLiteral("FuzzTimerCallBack");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-01-26 19:08:06 +03:00
|
|
|
private:
|
|
|
|
nsCOMPtr<MediaDevices> mMediaDevices;
|
|
|
|
};
|
|
|
|
|
2017-07-26 21:18:20 +03:00
|
|
|
NS_IMPL_ISUPPORTS(FuzzTimerCallBack, nsITimerCallback, nsINamed)
|
2017-01-26 19:08:06 +03:00
|
|
|
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 16:01:43 +03:00
|
|
|
MediaDevices::~MediaDevices() { mDeviceChangeListener.DisconnectIfExists(); }
|
2016-11-21 09:59:51 +03:00
|
|
|
|
2019-05-04 02:50:22 +03:00
|
|
|
static bool IsSameOriginWithAllParentDocs(nsINode* aDoc) {
|
|
|
|
MOZ_ASSERT(aDoc);
|
|
|
|
nsINode* node = aDoc;
|
|
|
|
while ((node = nsContentUtils::GetCrossDocParentNode(node))) {
|
|
|
|
if (NS_FAILED(nsContentUtils::CheckSameOrigin(aDoc, node))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-20 10:20:41 +04:00
|
|
|
already_AddRefed<Promise> MediaDevices::GetUserMedia(
|
|
|
|
const MediaStreamConstraints& aConstraints, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) {
|
2019-05-22 22:02:37 +03:00
|
|
|
if (RefPtr<nsPIDOMWindowInner> owner = GetOwner()) {
|
|
|
|
if (Document* doc = owner->GetExtantDoc()) {
|
|
|
|
if (!owner->IsSecureContext()) {
|
2019-09-05 02:36:21 +03:00
|
|
|
doc->SetUseCounter(eUseCounter_custom_GetUserMediaInsec);
|
2019-05-22 22:02:37 +03:00
|
|
|
}
|
|
|
|
if (!IsSameOriginWithAllParentDocs(doc)) {
|
2019-09-05 02:36:21 +03:00
|
|
|
doc->SetUseCounter(eUseCounter_custom_GetUserMediaXOrigin);
|
2019-05-22 22:02:37 +03:00
|
|
|
}
|
|
|
|
Document* topDoc = doc->GetTopLevelContentDocument();
|
|
|
|
IgnoredErrorResult ignored;
|
|
|
|
if (topDoc && !topDoc->HasFocus(ignored)) {
|
2019-09-05 02:36:21 +03:00
|
|
|
doc->SetUseCounter(eUseCounter_custom_GetUserMediaUnfocused);
|
2019-05-22 22:02:37 +03:00
|
|
|
}
|
2019-05-04 02:50:22 +03:00
|
|
|
}
|
|
|
|
}
|
2018-02-23 01:28:39 +03:00
|
|
|
RefPtr<Promise> p = Promise::Create(GetParentObject(), aRv);
|
2018-11-30 08:13:58 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
RefPtr<MediaDevices> self(this);
|
|
|
|
MediaManager::Get()
|
|
|
|
->GetUserMedia(GetOwner(), aConstraints, aCallerType)
|
|
|
|
->Then(
|
|
|
|
GetCurrentThreadSerialEventTarget(), __func__,
|
|
|
|
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
|
2018-11-30 08:15:54 +03:00
|
|
|
if (!GetWindowIfCurrent()) {
|
2018-11-30 08:13:58 +03:00
|
|
|
return; // Leave Promise pending after navigation by design.
|
|
|
|
}
|
|
|
|
p->MaybeResolve(std::move(aStream));
|
|
|
|
},
|
2018-11-30 08:15:54 +03:00
|
|
|
[this, self, p](const RefPtr<MediaMgrError>& error) {
|
|
|
|
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
|
|
|
if (!window) {
|
2018-11-30 08:13:58 +03:00
|
|
|
return; // Leave Promise pending after navigation by design.
|
|
|
|
}
|
2018-11-30 08:15:54 +03:00
|
|
|
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
|
2018-11-30 08:13:58 +03:00
|
|
|
});
|
2014-09-20 10:20:41 +04:00
|
|
|
return p.forget();
|
|
|
|
}
|
|
|
|
|
2017-09-18 04:52:06 +03:00
|
|
|
already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) {
|
2018-11-30 08:14:05 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2019-05-04 02:50:22 +03:00
|
|
|
|
2019-05-22 22:02:37 +03:00
|
|
|
if (RefPtr<nsPIDOMWindowInner> owner = GetOwner()) {
|
|
|
|
if (Document* doc = owner->GetExtantDoc()) {
|
|
|
|
if (!owner->IsSecureContext()) {
|
2019-09-05 02:36:21 +03:00
|
|
|
doc->SetUseCounter(eUseCounter_custom_EnumerateDevicesInsec);
|
2019-05-22 22:02:37 +03:00
|
|
|
}
|
|
|
|
Document* topDoc = doc->GetTopLevelContentDocument();
|
|
|
|
IgnoredErrorResult ignored;
|
|
|
|
if (topDoc && !topDoc->HasFocus(ignored)) {
|
2019-09-05 02:36:21 +03:00
|
|
|
doc->SetUseCounter(eUseCounter_custom_EnumerateDevicesUnfocused);
|
2019-05-22 22:02:37 +03:00
|
|
|
}
|
2019-05-04 02:50:22 +03:00
|
|
|
}
|
|
|
|
}
|
2018-02-23 01:28:39 +03:00
|
|
|
RefPtr<Promise> p = Promise::Create(GetParentObject(), aRv);
|
2018-11-30 08:14:05 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
RefPtr<MediaDevices> self(this);
|
|
|
|
MediaManager::Get()
|
|
|
|
->EnumerateDevices(GetOwner(), aCallerType)
|
|
|
|
->Then(
|
|
|
|
GetCurrentThreadSerialEventTarget(), __func__,
|
|
|
|
[this, self,
|
|
|
|
p](RefPtr<MediaManager::MediaDeviceSetRefCnt>&& aDevices) {
|
2018-11-30 08:15:54 +03:00
|
|
|
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
|
|
|
if (!window) {
|
2018-11-30 08:14:05 +03:00
|
|
|
return; // Leave Promise pending after navigation by design.
|
|
|
|
}
|
2018-11-30 08:15:54 +03:00
|
|
|
auto windowId = window->WindowID();
|
2018-11-30 08:14:05 +03:00
|
|
|
nsTArray<RefPtr<MediaDeviceInfo>> infos;
|
2019-09-05 20:04:48 +03:00
|
|
|
bool allowLabel =
|
|
|
|
aDevices->Length() == 0 ||
|
|
|
|
MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
|
|
|
|
windowId);
|
2018-11-30 08:15:34 +03:00
|
|
|
for (auto& device : *aDevices) {
|
2018-11-30 08:14:05 +03:00
|
|
|
MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput ||
|
|
|
|
device->mKind == dom::MediaDeviceKind::Videoinput ||
|
|
|
|
device->mKind == dom::MediaDeviceKind::Audiooutput);
|
|
|
|
// Include name only if page currently has a gUM stream active
|
|
|
|
// or persistent permissions (audio or video) have been granted
|
|
|
|
nsString label;
|
2019-09-05 20:04:48 +03:00
|
|
|
if (allowLabel ||
|
2018-11-30 08:14:05 +03:00
|
|
|
Preferences::GetBool("media.navigator.permission.disabled",
|
|
|
|
false)) {
|
|
|
|
label = device->mName;
|
|
|
|
}
|
|
|
|
infos.AppendElement(MakeRefPtr<MediaDeviceInfo>(
|
2019-03-08 14:51:45 +03:00
|
|
|
device->mID, device->mKind, label, device->mGroupID));
|
2018-11-30 08:14:05 +03:00
|
|
|
}
|
|
|
|
p->MaybeResolve(std::move(infos));
|
|
|
|
},
|
2018-11-30 08:15:54 +03:00
|
|
|
[this, self, p](const RefPtr<MediaMgrError>& error) {
|
|
|
|
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
|
|
|
if (!window) {
|
2018-11-30 08:14:05 +03:00
|
|
|
return; // Leave Promise pending after navigation by design.
|
|
|
|
}
|
2018-11-30 08:15:54 +03:00
|
|
|
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
|
2018-11-30 08:14:05 +03:00
|
|
|
});
|
2015-03-03 17:51:05 +03:00
|
|
|
return p.forget();
|
|
|
|
}
|
|
|
|
|
2018-12-28 06:12:57 +03:00
|
|
|
already_AddRefed<Promise> MediaDevices::GetDisplayMedia(
|
|
|
|
const DisplayMediaStreamConstraints& aConstraints, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) {
|
2019-05-22 22:02:37 +03:00
|
|
|
if (RefPtr<nsPIDOMWindowInner> owner = GetOwner()) {
|
|
|
|
if (Document* doc = owner->GetExtantDoc()) {
|
|
|
|
if (!IsSameOriginWithAllParentDocs(doc)) {
|
2019-09-05 02:36:21 +03:00
|
|
|
doc->SetUseCounter(eUseCounter_custom_GetDisplayMediaXOrigin);
|
2019-05-22 22:02:37 +03:00
|
|
|
}
|
2019-05-04 02:50:22 +03:00
|
|
|
}
|
|
|
|
}
|
2018-12-28 06:12:57 +03:00
|
|
|
RefPtr<Promise> p = Promise::Create(GetParentObject(), aRv);
|
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
RefPtr<MediaDevices> self(this);
|
|
|
|
MediaManager::Get()
|
|
|
|
->GetDisplayMedia(GetOwner(), aConstraints, aCallerType)
|
|
|
|
->Then(
|
|
|
|
GetCurrentThreadSerialEventTarget(), __func__,
|
|
|
|
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
|
|
|
|
if (!GetWindowIfCurrent()) {
|
|
|
|
return; // leave promise pending after navigation.
|
|
|
|
}
|
|
|
|
p->MaybeResolve(std::move(aStream));
|
|
|
|
},
|
|
|
|
[this, self, p](RefPtr<MediaMgrError>&& error) {
|
|
|
|
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
|
|
|
if (!window) {
|
|
|
|
return; // leave promise pending after navigation.
|
|
|
|
}
|
|
|
|
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
|
|
|
|
});
|
|
|
|
return p.forget();
|
|
|
|
}
|
|
|
|
|
2014-09-20 10:20:41 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(MediaDevices, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(MediaDevices, DOMEventTargetHelper)
|
|
|
|
NS_INTERFACE_MAP_BEGIN(MediaDevices)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(MediaDevices)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
|
|
|
|
2016-08-11 20:04:49 +03:00
|
|
|
void MediaDevices::OnDeviceChange() {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2019-04-01 19:46:46 +03:00
|
|
|
nsresult rv = CheckCurrentGlobalCorrectness();
|
2017-01-26 19:08:06 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
MOZ_ASSERT(false);
|
2016-08-11 20:04:49 +03:00
|
|
|
return;
|
2017-01-26 19:08:06 +03:00
|
|
|
}
|
2016-08-11 20:04:49 +03:00
|
|
|
|
|
|
|
if (!(MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
|
|
|
|
GetOwner()->WindowID()) ||
|
|
|
|
Preferences::GetBool("media.navigator.permission.disabled", false))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-19 04:56:48 +03:00
|
|
|
// Do not fire event to content script when
|
|
|
|
// privacy.resistFingerprinting is true.
|
|
|
|
if (nsContentUtils::ShouldResistFingerprinting()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-26 19:08:06 +03:00
|
|
|
if (!mFuzzTimer) {
|
2017-10-16 09:15:40 +03:00
|
|
|
mFuzzTimer = NS_NewTimer();
|
2017-01-26 19:08:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mFuzzTimer) {
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFuzzTimer->Cancel();
|
|
|
|
RefPtr<FuzzTimerCallBack> cb = new FuzzTimerCallBack(this);
|
|
|
|
mFuzzTimer->InitWithCallback(cb, DEVICECHANGE_HOLD_TIME_IN_MS,
|
|
|
|
nsITimer::TYPE_ONE_SHOT);
|
2016-08-11 20:04:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::dom::EventHandlerNonNull* MediaDevices::GetOndevicechange() {
|
2018-07-25 01:15:19 +03:00
|
|
|
return GetEventHandler(nsGkAtoms::ondevicechange);
|
2016-08-11 20:04:49 +03:00
|
|
|
}
|
|
|
|
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 16:01:43 +03:00
|
|
|
void MediaDevices::SetupDeviceChangeListener() {
|
|
|
|
if (mIsDeviceChangeListenerSetUp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPIDOMWindowInner* window = GetOwner();
|
|
|
|
if (!window) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISerialEventTarget* mainThread =
|
|
|
|
window->EventTargetFor(TaskCategory::Other);
|
|
|
|
if (!mainThread) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mDeviceChangeListener = MediaManager::Get()->DeviceListChangeEvent().Connect(
|
|
|
|
mainThread, this, &MediaDevices::OnDeviceChange);
|
|
|
|
mIsDeviceChangeListenerSetUp = true;
|
|
|
|
}
|
|
|
|
|
2016-08-11 20:04:49 +03:00
|
|
|
void MediaDevices::SetOndevicechange(
|
|
|
|
mozilla::dom::EventHandlerNonNull* aCallback) {
|
2018-07-25 01:15:19 +03:00
|
|
|
SetEventHandler(nsGkAtoms::ondevicechange, aCallback);
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 16:01:43 +03:00
|
|
|
SetupDeviceChangeListener();
|
2016-08-11 20:04:49 +03:00
|
|
|
}
|
|
|
|
|
2018-04-05 20:42:42 +03:00
|
|
|
void MediaDevices::EventListenerAdded(nsAtom* aType) {
|
|
|
|
DOMEventTargetHelper::EventListenerAdded(aType);
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 16:01:43 +03:00
|
|
|
SetupDeviceChangeListener();
|
2016-08-11 20:04:49 +03:00
|
|
|
}
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* MediaDevices::WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return MediaDevices_Binding::Wrap(aCx, this, aGivenProto);
|
2014-09-20 10:20:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|