Bug 1634703 - Add a parent-process-only method to nsIDOMWindowUtils to get the native window ID from a window. r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D73481
This commit is contained in:
Mike Conley 2020-05-08 22:31:19 +00:00
Родитель 3c136db2d3
Коммит 364a058417
3 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -4342,3 +4342,26 @@ nsDOMWindowUtils::GetPaintCount(uint64_t* aPaintCount) {
*aPaintCount = presShell ? presShell->GetPaintCount() : 0;
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetWebrtcRawDeviceId(nsAString& aRawDeviceId) {
if (!XRE_IsParentProcess()) {
MOZ_CRASH(
"GetWebrtcRawDeviceId is only available in the parent "
"process");
}
nsIWidget* widget = GetWidget();
if (!widget) {
return NS_ERROR_FAILURE;
}
int64_t rawDeviceId =
(int64_t)(widget->GetNativeData(NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID));
if (!rawDeviceId) {
return NS_ERROR_FAILURE;
}
aRawDeviceId.AppendInt(rawDeviceId);
return NS_OK;
}

Просмотреть файл

@ -2054,6 +2054,15 @@ interface nsIDOMWindowUtils : nsISupports {
// Returns true if we are using overlay scrollbars.
readonly attribute bool usesOverlayScrollbars;
// Returns the ID for the underlying window widget, which can
// be compared against the rawId from a nsIMediaDevice to determine
// if the window is being shared.
//
// Using this only makes sense in the parent process, and the function
// will intentionally crash any non-parent process that tries to access
// it.
readonly attribute AString webrtcRawDeviceId;
};
[scriptable, uuid(c694e359-7227-4392-a138-33c0cc1f15a6)]

Просмотреть файл

@ -131,6 +131,7 @@ typedef void* nsNativeWidget;
// IME context. Note that the result is only valid in the process. So,
// XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
#define NS_RAW_NATIVE_IME_CONTEXT 14
#define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
#ifdef XP_MACOSX
# define NS_NATIVE_PLUGIN_PORT_QD 100
# define NS_NATIVE_PLUGIN_PORT_CG 101