зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1284910 - Add scary boolean to mediaDeviceInfo. r=jesup
MozReview-Commit-ID: 2A7QZgUQH8l --HG-- extra : rebase_source : 15f534bd11d1b8bb4e85de7bc8cac45c99654ce4
This commit is contained in:
Родитель
85a0bfc34d
Коммит
fb49e07898
|
@ -743,7 +743,8 @@ protected:
|
|||
NS_IMPL_ISUPPORTS(MediaDevice, nsIMediaDevice)
|
||||
|
||||
MediaDevice::MediaDevice(MediaEngineSource* aSource, bool aIsVideo)
|
||||
: mMediaSource(aSource->GetMediaSource())
|
||||
: mScary(aSource->GetScary())
|
||||
, mMediaSource(aSource->GetMediaSource())
|
||||
, mSource(aSource)
|
||||
, mIsVideo(aIsVideo)
|
||||
{
|
||||
|
@ -881,6 +882,13 @@ MediaDevice::GetRawId(nsAString& aID)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaDevice::GetScary(bool* aScary)
|
||||
{
|
||||
*aScary = mScary;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
MediaDevice::SetId(const nsAString& aID)
|
||||
{
|
||||
|
|
|
@ -94,6 +94,7 @@ protected:
|
|||
nsString mName;
|
||||
nsString mID;
|
||||
nsString mRawID;
|
||||
bool mScary;
|
||||
dom::MediaSourceEnum mMediaSource;
|
||||
RefPtr<MediaEngineSource> mSource;
|
||||
RefPtr<MediaEngineSource::AllocationHandle> mAllocationHandle;
|
||||
|
|
|
@ -13,6 +13,7 @@ interface nsIMediaDevice : nsISupports
|
|||
readonly attribute DOMString id;
|
||||
readonly attribute DOMString mediaSource;
|
||||
readonly attribute DOMString rawId;
|
||||
readonly attribute boolean scary;
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(24544878-d35e-4962-8c5f-fb84e97bdfee)]
|
||||
|
|
|
@ -214,6 +214,9 @@ public:
|
|||
/* Populate the UUID of this device in the nsACString */
|
||||
virtual void GetUUID(nsACString&) const = 0;
|
||||
|
||||
/* Override w/true if source does end-run around cross origin restrictions. */
|
||||
virtual bool GetScary() const { return false; };
|
||||
|
||||
class AllocationHandle
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -29,10 +29,11 @@ NS_IMPL_ISUPPORTS0(MediaEngineRemoteVideoSource)
|
|||
|
||||
MediaEngineRemoteVideoSource::MediaEngineRemoteVideoSource(
|
||||
int aIndex, mozilla::camera::CaptureEngine aCapEngine,
|
||||
dom::MediaSourceEnum aMediaSource, const char* aMonitorName)
|
||||
dom::MediaSourceEnum aMediaSource, bool aScary, const char* aMonitorName)
|
||||
: MediaEngineCameraVideoSource(aIndex, aMonitorName),
|
||||
mMediaSource(aMediaSource),
|
||||
mCapEngine(aCapEngine)
|
||||
mCapEngine(aCapEngine),
|
||||
mScary(aScary)
|
||||
{
|
||||
MOZ_ASSERT(aMediaSource != dom::MediaSourceEnum::Other);
|
||||
mSettings.mWidth.Construct(0);
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
// MediaEngineCameraVideoSource
|
||||
MediaEngineRemoteVideoSource(int aIndex, mozilla::camera::CaptureEngine aCapEngine,
|
||||
dom::MediaSourceEnum aMediaSource,
|
||||
bool aScary = false,
|
||||
const char* aMonitorName = "RemoteVideo.Monitor");
|
||||
|
||||
nsresult Allocate(const dom::MediaTrackConstraints& aConstraints,
|
||||
|
@ -103,6 +104,8 @@ public:
|
|||
|
||||
void Shutdown() override;
|
||||
|
||||
bool GetScary() const override { return mScary; }
|
||||
|
||||
protected:
|
||||
~MediaEngineRemoteVideoSource() { }
|
||||
|
||||
|
@ -125,6 +128,7 @@ private:
|
|||
|
||||
// To only restart camera when needed, we keep track previous settings.
|
||||
webrtc::CaptureCapability mLastCapability;
|
||||
bool mScary;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,11 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList
|
|||
|
||||
void GetName(nsAString_internal&) const override;
|
||||
void GetUUID(nsACString_internal&) const override;
|
||||
|
||||
bool GetScary() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult Allocate(const dom::MediaTrackConstraints &,
|
||||
const mozilla::MediaEnginePrefs&,
|
||||
const nsString& aDeviceId,
|
||||
|
|
|
@ -157,6 +157,7 @@ MediaEngineWebRTC::EnumerateVideoDevices(dom::MediaSourceEnum aMediaSource,
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
bool scaryKind = false; // flag sources with cross-origin exploit potential
|
||||
|
||||
switch (aMediaSource) {
|
||||
case dom::MediaSourceEnum::Window:
|
||||
|
@ -167,9 +168,11 @@ MediaEngineWebRTC::EnumerateVideoDevices(dom::MediaSourceEnum aMediaSource,
|
|||
break;
|
||||
case dom::MediaSourceEnum::Screen:
|
||||
capEngine = mozilla::camera::ScreenEngine;
|
||||
scaryKind = true;
|
||||
break;
|
||||
case dom::MediaSourceEnum::Browser:
|
||||
capEngine = mozilla::camera::BrowserEngine;
|
||||
scaryKind = true;
|
||||
break;
|
||||
case dom::MediaSourceEnum::Camera:
|
||||
capEngine = mozilla::camera::CameraEngine;
|
||||
|
@ -196,6 +199,7 @@ MediaEngineWebRTC::EnumerateVideoDevices(dom::MediaSourceEnum aMediaSource,
|
|||
for (int i = 0; i < num; i++) {
|
||||
char deviceName[MediaEngineSource::kMaxDeviceNameLength];
|
||||
char uniqueId[MediaEngineSource::kMaxUniqueIdLength];
|
||||
bool scaryWindow = false;
|
||||
|
||||
// paranoia
|
||||
deviceName[0] = '\0';
|
||||
|
@ -215,6 +219,16 @@ MediaEngineWebRTC::EnumerateVideoDevices(dom::MediaSourceEnum aMediaSource,
|
|||
#ifdef DEBUG
|
||||
LOG((" Capture Device Index %d, Name %s", i, deviceName));
|
||||
|
||||
if (aMediaSource == dom::MediaSourceEnum::Window) {
|
||||
// TODO: Detect firefox windows
|
||||
//scaryWindow = true;
|
||||
}
|
||||
|
||||
if (aMediaSource == dom::MediaSourceEnum::Application) {
|
||||
// TODO: Detect firefox application windows
|
||||
//scaryWindow = true;
|
||||
}
|
||||
|
||||
webrtc::CaptureCapability cap;
|
||||
int numCaps = mozilla::camera::GetChildAndCall(
|
||||
&mozilla::camera::CamerasChild::NumberOfCapabilities,
|
||||
|
@ -247,7 +261,8 @@ MediaEngineWebRTC::EnumerateVideoDevices(dom::MediaSourceEnum aMediaSource,
|
|||
static_cast<MediaEngineRemoteVideoSource*>(vSource.get())->Refresh(i);
|
||||
aVSources->AppendElement(vSource.get());
|
||||
} else {
|
||||
vSource = new MediaEngineRemoteVideoSource(i, capEngine, aMediaSource);
|
||||
vSource = new MediaEngineRemoteVideoSource(i, capEngine, aMediaSource,
|
||||
scaryKind || scaryWindow);
|
||||
mVideoSources.Put(uuid, vSource); // Hashtable takes ownership.
|
||||
aVSources->AppendElement(vSource);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче