Bug 1311048 - Pick out Firefox windows as scary by pid on Linux. r=jesup

MozReview-Commit-ID: CjkfnZWjCTl

--HG--
extra : rebase_source : 54efcf2da32fc3a673903765b3e888d49a745c24
This commit is contained in:
Jan-Ivar Bruaroey 2016-11-04 23:56:48 -04:00
parent 695cfd5856
commit f6022d3538
3 changed files with 18 additions and 2 deletions

View File

@ -66,6 +66,9 @@ class WindowCapturerLinux : public WindowCapturer,
// Returns window title for the specified X |window|.
bool GetWindowTitle(::Window window, std::string* title);
// Returns the id of the owning process.
int GetWindowProcessID(::Window window);
Callback* callback_;
scoped_refptr<SharedXDisplay> x_display_;
@ -136,6 +139,9 @@ bool WindowCapturerLinux::GetWindowList(WindowList* windows) {
Window w;
w.id = app_window;
unsigned int processId = GetWindowProcessID(app_window);
w.pid = (pid_t)processId;
XWindowAttributes window_attr;
if(!XGetWindowAttributes(display(),w.id,&window_attr)){
LOG(LS_ERROR)<<"Bad request for attributes for window ID:"<<w.id;
@ -387,6 +393,14 @@ bool WindowCapturerLinux::GetWindowTitle(::Window window, std::string* title) {
return result;
}
int WindowCapturerLinux::GetWindowProcessID(::Window window) {
// Get _NET_WM_PID property of the window.
Atom process_atom = XInternAtom(display(), "_NET_WM_PID", True);
XWindowProperty<uint32_t> process_id(display(), window, process_atom);
return process_id.is_valid() ? *process_id.data() : 0;
}
} // namespace
// static

View File

@ -227,7 +227,8 @@ int32_t DeviceInfoLinux::GetDeviceName(
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* /*productUniqueIdUTF8*/,
uint32_t /*productUniqueIdUTF8Length*/)
uint32_t /*productUniqueIdUTF8Length*/,
pid_t* pid)
{
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideoCapture, _id, "%s", __FUNCTION__);

View File

@ -36,7 +36,8 @@ public:
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8=0,
uint32_t productUniqueIdUTF8Length=0);
uint32_t productUniqueIdUTF8Length=0,
pid_t* pid=0);
/*
* Fills the membervariable _captureCapabilities with capabilites for the given device name.
*/