зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1372073 - Spoof navigator.mediaDevices.enumerateDevices. r=arthuredelstein,jib,smaug
MozReview-Commit-ID: HubfB6M4UM0 --HG-- extra : rebase_source : 050065e484bdae32bf6cfcd730a6bfb626ad0508
This commit is contained in:
Родитель
81344fe444
Коммит
03debed820
|
@ -197,7 +197,7 @@ MediaDevices::GetUserMedia(const MediaStreamConstraints& aConstraints,
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Promise>
|
already_AddRefed<Promise>
|
||||||
MediaDevices::EnumerateDevices(ErrorResult &aRv)
|
MediaDevices::EnumerateDevices(CallerType aCallerType, ErrorResult &aRv)
|
||||||
{
|
{
|
||||||
nsPIDOMWindowInner* window = GetOwner();
|
nsPIDOMWindowInner* window = GetOwner();
|
||||||
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(window);
|
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(window);
|
||||||
|
@ -207,7 +207,7 @@ MediaDevices::EnumerateDevices(ErrorResult &aRv)
|
||||||
RefPtr<EnumDevResolver> resolver = new EnumDevResolver(p, window->WindowID());
|
RefPtr<EnumDevResolver> resolver = new EnumDevResolver(p, window->WindowID());
|
||||||
RefPtr<GumRejecter> rejecter = new GumRejecter(p);
|
RefPtr<GumRejecter> rejecter = new GumRejecter(p);
|
||||||
|
|
||||||
aRv = MediaManager::Get()->EnumerateDevices(window, resolver, rejecter);
|
aRv = MediaManager::Get()->EnumerateDevices(window, resolver, rejecter, aCallerType);
|
||||||
return p.forget();
|
return p.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
CallerType aCallerType, ErrorResult &aRv);
|
CallerType aCallerType, ErrorResult &aRv);
|
||||||
|
|
||||||
already_AddRefed<Promise>
|
already_AddRefed<Promise>
|
||||||
EnumerateDevices(ErrorResult &aRv);
|
EnumerateDevices(CallerType aCallerType, ErrorResult &aRv);
|
||||||
|
|
||||||
virtual void OnDeviceChange() override;
|
virtual void OnDeviceChange() override;
|
||||||
|
|
||||||
|
|
|
@ -2791,7 +2791,8 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
|
||||||
nsresult
|
nsresult
|
||||||
MediaManager::EnumerateDevices(nsPIDOMWindowInner* aWindow,
|
MediaManager::EnumerateDevices(nsPIDOMWindowInner* aWindow,
|
||||||
nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
|
nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
|
||||||
nsIDOMGetUserMediaErrorCallback* aOnFailure)
|
nsIDOMGetUserMediaErrorCallback* aOnFailure,
|
||||||
|
dom::CallerType aCallerType)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
NS_ENSURE_TRUE(!sInShutdown, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(!sInShutdown, NS_ERROR_FAILURE);
|
||||||
|
@ -2818,7 +2819,8 @@ MediaManager::EnumerateDevices(nsPIDOMWindowInner* aWindow,
|
||||||
RefPtr<SourceListener> sourceListener = new SourceListener();
|
RefPtr<SourceListener> sourceListener = new SourceListener();
|
||||||
windowListener->Register(sourceListener);
|
windowListener->Register(sourceListener);
|
||||||
|
|
||||||
bool fake = Preferences::GetBool("media.navigator.streams.fake");
|
bool fake = Preferences::GetBool("media.navigator.streams.fake") ||
|
||||||
|
nsContentUtils::ResistFingerprinting(aCallerType);
|
||||||
|
|
||||||
RefPtr<PledgeSourceSet> p = EnumerateDevicesImpl(windowId,
|
RefPtr<PledgeSourceSet> p = EnumerateDevicesImpl(windowId,
|
||||||
MediaSourceEnum::Camera,
|
MediaSourceEnum::Camera,
|
||||||
|
|
|
@ -257,7 +257,8 @@ public:
|
||||||
|
|
||||||
nsresult EnumerateDevices(nsPIDOMWindowInner* aWindow,
|
nsresult EnumerateDevices(nsPIDOMWindowInner* aWindow,
|
||||||
nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
|
nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
|
||||||
nsIDOMGetUserMediaErrorCallback* aOnFailure);
|
nsIDOMGetUserMediaErrorCallback* aOnFailure,
|
||||||
|
dom::CallerType aCallerType);
|
||||||
|
|
||||||
nsresult EnumerateDevices(nsPIDOMWindowInner* aWindow, dom::Promise& aPromise);
|
nsresult EnumerateDevices(nsPIDOMWindowInner* aWindow, dom::Promise& aPromise);
|
||||||
void OnNavigation(uint64_t aWindowID);
|
void OnNavigation(uint64_t aWindowID);
|
||||||
|
|
|
@ -16,7 +16,7 @@ interface MediaDevices : EventTarget {
|
||||||
attribute EventHandler ondevicechange;
|
attribute EventHandler ondevicechange;
|
||||||
MediaTrackSupportedConstraints getSupportedConstraints();
|
MediaTrackSupportedConstraints getSupportedConstraints();
|
||||||
|
|
||||||
[Throws]
|
[Throws, NeedsCallerType]
|
||||||
Promise<sequence<MediaDeviceInfo>> enumerateDevices();
|
Promise<sequence<MediaDeviceInfo>> enumerateDevices();
|
||||||
|
|
||||||
[Throws, NeedsCallerType]
|
[Throws, NeedsCallerType]
|
||||||
|
|
Загрузка…
Ссылка в новой задаче