mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
Backed out changeset e1d1542ff35c (bug 949907) for robocop failures.
CLOSED TREE
This commit is contained in:
parent
f373429333
commit
e984c90001
@ -66,20 +66,19 @@ function getBrowserForWindow(aContentWindow) {
|
||||
|
||||
function handleRequest(aSubject, aTopic, aData) {
|
||||
let constraints = aSubject.getConstraints();
|
||||
let contentWindow = Services.wm.getOuterWindowWithId(aSubject.windowID);
|
||||
|
||||
contentWindow.navigator.mozGetUserMediaDevices(
|
||||
Services.wm.getMostRecentWindow(null).navigator.mozGetUserMediaDevices(
|
||||
constraints,
|
||||
function (devices) {
|
||||
prompt(contentWindow, aSubject.callID, constraints.audio,
|
||||
prompt(aSubject.windowID, aSubject.callID, constraints.audio,
|
||||
constraints.video || constraints.picture, devices);
|
||||
},
|
||||
function (error) {
|
||||
// bug 827146 -- In the future, the UI should catch NO_DEVICES_FOUND
|
||||
// and allow the user to plug in a device, instead of immediately failing.
|
||||
denyRequest(aSubject.callID, error);
|
||||
},
|
||||
aSubject.innerWindowID);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function denyRequest(aCallID, aError) {
|
||||
@ -91,7 +90,7 @@ function denyRequest(aCallID, aError) {
|
||||
Services.obs.notifyObservers(msg, "getUserMedia:response:deny", aCallID);
|
||||
}
|
||||
|
||||
function prompt(aContentWindow, aCallID, aAudioRequested, aVideoRequested, aDevices) {
|
||||
function prompt(aWindowID, aCallID, aAudioRequested, aVideoRequested, aDevices) {
|
||||
let audioDevices = [];
|
||||
let videoDevices = [];
|
||||
for (let device of aDevices) {
|
||||
@ -120,8 +119,9 @@ function prompt(aContentWindow, aCallID, aAudioRequested, aVideoRequested, aDevi
|
||||
return;
|
||||
}
|
||||
|
||||
let host = aContentWindow.document.documentURIObject.host;
|
||||
let browser = getBrowserForWindow(aContentWindow);
|
||||
let contentWindow = Services.wm.getOuterWindowWithId(aWindowID);
|
||||
let host = contentWindow.document.documentURIObject.host;
|
||||
let browser = getBrowserForWindow(contentWindow);
|
||||
let chromeDoc = browser.ownerDocument;
|
||||
let chromeWin = chromeDoc.defaultView;
|
||||
let stringBundle = chromeWin.gNavigatorBundle;
|
||||
|
@ -1022,7 +1022,6 @@ void
|
||||
Navigator::MozGetUserMediaDevices(const MediaStreamConstraintsInternal& aConstraints,
|
||||
MozGetUserMediaDevicesSuccessCallback& aOnSuccess,
|
||||
NavigatorUserMediaErrorCallback& aOnError,
|
||||
uint64_t aInnerWindowID,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
CallbackObjectHolder<MozGetUserMediaDevicesSuccessCallback,
|
||||
@ -1041,8 +1040,7 @@ Navigator::MozGetUserMediaDevices(const MediaStreamConstraintsInternal& aConstra
|
||||
}
|
||||
|
||||
MediaManager* manager = MediaManager::Get();
|
||||
aRv = manager->GetUserMediaDevices(mWindow, aConstraints, onsuccess, onerror,
|
||||
aInnerWindowID);
|
||||
aRv = manager->GetUserMediaDevices(mWindow, aConstraints, onsuccess, onerror);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -230,7 +230,6 @@ public:
|
||||
void MozGetUserMediaDevices(const MediaStreamConstraintsInternal& aConstraints,
|
||||
MozGetUserMediaDevicesSuccessCallback& aOnSuccess,
|
||||
NavigatorUserMediaErrorCallback& aOnError,
|
||||
uint64_t aInnerWindowID,
|
||||
ErrorResult& aRv);
|
||||
#endif // MOZ_MEDIA_NAVIGATOR
|
||||
bool DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
|
||||
|
@ -17,15 +17,15 @@ GetUserMediaRequest::GetUserMediaRequest(
|
||||
nsPIDOMWindow* aInnerWindow,
|
||||
const nsAString& aCallID,
|
||||
const MediaStreamConstraintsInternal& aConstraints)
|
||||
: mInnerWindowID(aInnerWindow->WindowID())
|
||||
, mOuterWindowID(aInnerWindow->GetOuterWindow()->WindowID())
|
||||
: mInnerWindow(aInnerWindow)
|
||||
, mWindowID(aInnerWindow->GetOuterWindow()->WindowID())
|
||||
, mCallID(aCallID)
|
||||
, mConstraints(aConstraints)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(GetUserMediaRequest)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(GetUserMediaRequest, mInnerWindow)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(GetUserMediaRequest)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(GetUserMediaRequest)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GetUserMediaRequest)
|
||||
@ -41,7 +41,7 @@ GetUserMediaRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
|
||||
nsISupports* GetUserMediaRequest::GetParentObject()
|
||||
{
|
||||
return nullptr;
|
||||
return mInnerWindow;
|
||||
}
|
||||
|
||||
void GetUserMediaRequest::GetCallID(nsString& retval)
|
||||
@ -51,12 +51,7 @@ void GetUserMediaRequest::GetCallID(nsString& retval)
|
||||
|
||||
uint64_t GetUserMediaRequest::WindowID()
|
||||
{
|
||||
return mOuterWindowID;
|
||||
}
|
||||
|
||||
uint64_t GetUserMediaRequest::InnerWindowID()
|
||||
{
|
||||
return mInnerWindowID;
|
||||
return mWindowID;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -20,8 +20,7 @@ class MediaStreamConstraintsInternal;
|
||||
class GetUserMediaRequest : public nsISupports, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
GetUserMediaRequest(nsPIDOMWindow* aInnerWindow,
|
||||
const nsAString& aCallID,
|
||||
GetUserMediaRequest(nsPIDOMWindow* aInnerWindow, const nsAString& aCallID,
|
||||
const MediaStreamConstraintsInternal& aConstraints);
|
||||
virtual ~GetUserMediaRequest() {};
|
||||
|
||||
@ -33,12 +32,12 @@ public:
|
||||
nsISupports* GetParentObject();
|
||||
|
||||
uint64_t WindowID();
|
||||
uint64_t InnerWindowID();
|
||||
void GetCallID(nsString& retval);
|
||||
void GetConstraints(MediaStreamConstraintsInternal &result);
|
||||
|
||||
private:
|
||||
uint64_t mInnerWindowID, mOuterWindowID;
|
||||
nsCOMPtr<nsPIDOMWindow> mInnerWindow;
|
||||
uint64_t mWindowID;
|
||||
const nsString mCallID;
|
||||
MediaStreamConstraintsInternal mConstraints;
|
||||
};
|
||||
|
@ -225,15 +225,12 @@ class DeviceSuccessCallbackRunnable: public nsRunnable
|
||||
{
|
||||
public:
|
||||
DeviceSuccessCallbackRunnable(
|
||||
uint64_t aWindowID,
|
||||
already_AddRefed<nsIGetUserMediaDevicesSuccessCallback> aSuccess,
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> aError,
|
||||
nsTArray<nsCOMPtr<nsIMediaDevice> >* aDevices)
|
||||
: mSuccess(aSuccess)
|
||||
, mError(aError)
|
||||
, mDevices(aDevices)
|
||||
, mWindowID(aWindowID)
|
||||
, mManager(MediaManager::GetInstance()) {}
|
||||
, mDevices(aDevices) {}
|
||||
|
||||
NS_IMETHOD
|
||||
Run()
|
||||
@ -243,11 +240,6 @@ public:
|
||||
nsCOMPtr<nsIGetUserMediaDevicesSuccessCallback> success(mSuccess);
|
||||
nsCOMPtr<nsIDOMGetUserMediaErrorCallback> error(mError);
|
||||
|
||||
// Only run if window is still on our active list.
|
||||
if (!mManager->IsWindowStillActive(mWindowID)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> devices =
|
||||
do_CreateInstance("@mozilla.org/variant;1");
|
||||
|
||||
@ -281,8 +273,6 @@ private:
|
||||
already_AddRefed<nsIGetUserMediaDevicesSuccessCallback> mSuccess;
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> mError;
|
||||
nsAutoPtr<nsTArray<nsCOMPtr<nsIMediaDevice> > > mDevices;
|
||||
uint64_t mWindowID;
|
||||
nsRefPtr<MediaManager> mManager;
|
||||
};
|
||||
|
||||
// Handle removing GetUserMediaCallbackMediaStreamListener from main thread
|
||||
@ -1086,8 +1076,7 @@ public:
|
||||
mLoopbackAudioDevice));
|
||||
final->MoveElementsFrom(*s);
|
||||
}
|
||||
NS_DispatchToMainThread(new DeviceSuccessCallbackRunnable(mWindowId,
|
||||
mSuccess, mError,
|
||||
NS_DispatchToMainThread(new DeviceSuccessCallbackRunnable(mSuccess, mError,
|
||||
final.forget()));
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1098,7 +1087,6 @@ private:
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> mError;
|
||||
nsRefPtr<MediaManager> mManager;
|
||||
uint64_t mWindowId;
|
||||
const nsString mCallId;
|
||||
// Audio & Video loopback devices to be used based on
|
||||
// the preference settings. This is currently used for
|
||||
// automated media tests only.
|
||||
@ -1461,8 +1449,7 @@ nsresult
|
||||
MediaManager::GetUserMediaDevices(nsPIDOMWindow* aWindow,
|
||||
const MediaStreamConstraintsInternal& aConstraints,
|
||||
nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
|
||||
nsIDOMGetUserMediaErrorCallback* aOnError,
|
||||
uint64_t aInnerWindowID)
|
||||
nsIDOMGetUserMediaErrorCallback* aOnError)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
@ -1487,9 +1474,9 @@ MediaManager::GetUserMediaDevices(nsPIDOMWindow* aWindow,
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIRunnable> gUMDRunnable = new GetUserMediaDevicesRunnable(
|
||||
aConstraints, onSuccess.forget(), onError.forget(),
|
||||
(aInnerWindowID ? aInnerWindowID : aWindow->WindowID()),
|
||||
loopbackAudioDevice, loopbackVideoDevice);
|
||||
aConstraints, onSuccess.forget(), onError.forget(), aWindow->WindowID(),
|
||||
loopbackAudioDevice, loopbackVideoDevice
|
||||
);
|
||||
|
||||
nsCOMPtr<nsIThread> deviceThread;
|
||||
rv = NS_NewThread(getter_AddRefs(deviceThread));
|
||||
|
@ -494,8 +494,7 @@ public:
|
||||
nsresult GetUserMediaDevices(nsPIDOMWindow* aWindow,
|
||||
const dom::MediaStreamConstraintsInternal& aConstraints,
|
||||
nsIGetUserMediaDevicesSuccessCallback* onSuccess,
|
||||
nsIDOMGetUserMediaErrorCallback* onError,
|
||||
uint64_t aInnerWindowID = 0);
|
||||
nsIDOMGetUserMediaErrorCallback* onError);
|
||||
void OnNavigation(uint64_t aWindowID);
|
||||
|
||||
MediaEnginePrefs mPrefs;
|
||||
|
@ -173,8 +173,7 @@ MediaPermissionRequest::GetPrincipal(nsIPrincipal **aRequestingPrincipal)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRequestingPrincipal);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = static_cast<nsPIDOMWindow*>
|
||||
(nsGlobalWindow::GetInnerWindowWithId(mRequest->InnerWindowID()));
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mRequest->GetParentObject());
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
|
||||
@ -188,8 +187,7 @@ NS_IMETHODIMP
|
||||
MediaPermissionRequest::GetWindow(nsIDOMWindow** aRequestingWindow)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRequestingWindow);
|
||||
nsCOMPtr<nsPIDOMWindow> window = static_cast<nsPIDOMWindow*>
|
||||
(nsGlobalWindow::GetInnerWindowWithId(mRequest->InnerWindowID()));
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mRequest->GetParentObject());
|
||||
window.forget(aRequestingWindow);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -223,8 +221,7 @@ MediaPermissionRequest::Allow()
|
||||
already_AddRefed<nsPIDOMWindow>
|
||||
MediaPermissionRequest::GetOwner()
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = static_cast<nsPIDOMWindow*>
|
||||
(nsGlobalWindow::GetInnerWindowWithId(mRequest->InnerWindowID()));
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mRequest->GetParentObject());
|
||||
return window.forget();
|
||||
}
|
||||
|
||||
@ -437,8 +434,7 @@ MediaPermissionManager::HandleRequest(nsRefPtr<dom::GetUserMediaRequest> &req)
|
||||
nsString callID;
|
||||
req->GetCallID(callID);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> innerWindow = static_cast<nsPIDOMWindow*>
|
||||
(nsGlobalWindow::GetInnerWindowWithId(req->InnerWindowID()));
|
||||
nsCOMPtr<nsPIDOMWindow> innerWindow = do_QueryInterface(req->GetParentObject());
|
||||
if (!innerWindow) {
|
||||
MOZ_ASSERT(false, "No inner window");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -9,7 +9,6 @@
|
||||
[NoInterfaceObject]
|
||||
interface GetUserMediaRequest {
|
||||
readonly attribute unsigned long long windowID;
|
||||
readonly attribute unsigned long long innerWindowID;
|
||||
readonly attribute DOMString callID;
|
||||
MediaStreamConstraintsInternal getConstraints();
|
||||
};
|
||||
|
@ -340,10 +340,6 @@ partial interface Navigator {
|
||||
[Throws, ChromeOnly]
|
||||
void mozGetUserMediaDevices(MediaStreamConstraintsInternal constraints,
|
||||
MozGetUserMediaDevicesSuccessCallback onsuccess,
|
||||
NavigatorUserMediaErrorCallback onerror,
|
||||
// The originating innerWindowID is needed to
|
||||
// avoid calling the callbacks if the window has
|
||||
// navigated away. It is optional only as legacy.
|
||||
optional unsigned long long innerWindowID = 0);
|
||||
NavigatorUserMediaErrorCallback onerror);
|
||||
};
|
||||
#endif // MOZ_MEDIA_NAVIGATOR
|
||||
|
@ -74,18 +74,17 @@ var WebrtcUI = {
|
||||
|
||||
handleRequest: function handleRequest(aSubject, aTopic, aData) {
|
||||
let constraints = aSubject.getConstraints();
|
||||
let contentWindow = Services.wm.getOuterWindowWithId(aSubject.windowID);
|
||||
|
||||
contentWindow.navigator.mozGetUserMediaDevices(
|
||||
Services.wm.getMostRecentWindow(null).navigator.mozGetUserMediaDevices(
|
||||
constraints,
|
||||
function (devices) {
|
||||
WebrtcUI.prompt(contentWindow, aSubject.callID, constraints.audio,
|
||||
WebrtcUI.prompt(aSubject.windowID, aSubject.callID, constraints.audio,
|
||||
constraints.video, devices);
|
||||
},
|
||||
function (error) {
|
||||
Cu.reportError(error);
|
||||
},
|
||||
aSubject.innerWindowID);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
getDeviceButtons: function(audioDevices, videoDevices, aCallID) {
|
||||
@ -154,8 +153,7 @@ var WebrtcUI = {
|
||||
}
|
||||
},
|
||||
|
||||
prompt: function prompt(contentWindow, aCallID, aAudioRequested,
|
||||
aVideoRequested, aDevices) {
|
||||
prompt: function prompt(aWindowID, aCallID, aAudioRequested, aVideoRequested, aDevices) {
|
||||
let audioDevices = [];
|
||||
let videoDevices = [];
|
||||
for (let device of aDevices) {
|
||||
@ -182,7 +180,8 @@ var WebrtcUI = {
|
||||
else
|
||||
return;
|
||||
|
||||
let host = aContentWindow.document.documentURIObject.host;
|
||||
let contentWindow = Services.wm.getOuterWindowWithId(aWindowID);
|
||||
let host = contentWindow.document.documentURIObject.host;
|
||||
let requestor = BrowserApp.manifest ? "'" + BrowserApp.manifest.name + "'" : host;
|
||||
let message = Strings.browser.formatStringFromName("getUserMedia.share" + requestType + ".message", [ requestor ], 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user