Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: remoting/host/curtain_mode_linux.cc

Issue 1954623005: Add Xorg+dummy as alternative for Xvfb (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/curtain_mode.h" 5 #include "remoting/host/curtain_mode.h"
6 6
7 #include <X11/extensions/XInput.h> 7 #include <X11/extensions/XInput.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 27 matching lines...) Expand all
38 // attached to the physical console (i.e. impossible to curtain). 38 // attached to the physical console (i.e. impossible to curtain).
39 bool activated = IsXvfbSession(); 39 bool activated = IsXvfbSession();
40 if (!activated) { 40 if (!activated) {
41 LOG(ERROR) << "Curtain-mode is not supported when running on non-Xvfb " 41 LOG(ERROR) << "Curtain-mode is not supported when running on non-Xvfb "
42 "X server"; 42 "X server";
43 } 43 }
44 44
45 return activated; 45 return activated;
46 } 46 }
47 47
48 bool CurtainModeLinux::IsXvfbSession() { 48 bool CurtainModeLinux::IsXvfbSession() {
Lambros 2016/05/09 23:24:24 Rename this to avoid mentioning Xvfb, maybe IsVirt
49 // Try to identify an Xvfb session. There's no way to query what X server we 49 // Try to identify an Xvfb session. There's no way to query what X server we
50 // are running under, so we check for the Xvfb input devices. 50 // are running under, so we check for the Xvfb input devices.
51 // TODO(rmsousa): Find a similar way to determine that the *output* is secure. 51 // TODO(rmsousa): Find a similar way to determine that the *output* is secure.
52 Display* display = XOpenDisplay(nullptr); 52 Display* display = XOpenDisplay(nullptr);
53 int opcode, event, error; 53 int opcode, event, error;
54 if (!XQueryExtension(display, "XInputExtension", &opcode, &event, &error)) { 54 if (!XQueryExtension(display, "XInputExtension", &opcode, &event, &error)) {
55 // If XInput is not available, assume it is not an Xvfb session. 55 // If XInput is not available, assume it is not an Xvfb session.
56 LOG(ERROR) << "X Input extension not available: " << error; 56 LOG(ERROR) << "X Input extension not available: " << error;
57 XCloseDisplay(display); 57 XCloseDisplay(display);
58 return false; 58 return false;
59 } 59 }
60 int num_devices; 60 int num_devices;
61 XDeviceInfo* devices; 61 XDeviceInfo* devices;
62 bool found_xvfb_mouse = false; 62 bool found_xvfb_mouse = false;
63 bool found_xvfb_keyboard = false; 63 bool found_xvfb_keyboard = false;
64 bool found_crd_void_input = false;
64 bool found_other_devices = false; 65 bool found_other_devices = false;
65 devices = XListInputDevices(display, &num_devices); 66 devices = XListInputDevices(display, &num_devices);
66 for (int i = 0; i < num_devices; i++) { 67 for (int i = 0; i < num_devices; i++) {
67 XDeviceInfo* device_info = &devices[i]; 68 XDeviceInfo* device_info = &devices[i];
68 if (device_info->use == IsXExtensionPointer) { 69 if (device_info->use == IsXExtensionPointer) {
69 if (strcmp(device_info->name, "Xvfb mouse") == 0) { 70 if (strcmp(device_info->name, "Xvfb mouse") == 0) {
70 found_xvfb_mouse = true; 71 found_xvfb_mouse = true;
72 } else if (strcmp(device_info->name,
73 "Chrome Remote Desktop Input") == 0) {
74 found_crd_void_input = true;
71 } else if (strcmp(device_info->name, "Virtual core XTEST pointer") != 0) { 75 } else if (strcmp(device_info->name, "Virtual core XTEST pointer") != 0) {
72 found_other_devices = true; 76 found_other_devices = true;
73 HOST_LOG << "Non Xvfb mouse found: " << device_info->name; 77 HOST_LOG << "Non Xvfb mouse found: " << device_info->name;
74 } 78 }
75 } else if (device_info->use == IsXExtensionKeyboard) { 79 } else if (device_info->use == IsXExtensionKeyboard) {
76 if (strcmp(device_info->name, "Xvfb keyboard") == 0) { 80 if (strcmp(device_info->name, "Xvfb keyboard") == 0) {
77 found_xvfb_keyboard = true; 81 found_xvfb_keyboard = true;
78 } else if (strcmp(device_info->name, 82 } else if (strcmp(device_info->name,
79 "Virtual core XTEST keyboard") != 0) { 83 "Virtual core XTEST keyboard") != 0) {
80 found_other_devices = true; 84 found_other_devices = true;
81 HOST_LOG << "Non Xvfb keyboard found: " << device_info->name; 85 HOST_LOG << "Non Xvfb keyboard found: " << device_info->name;
82 } 86 }
83 } else if (device_info->use == IsXPointer) { 87 } else if (device_info->use == IsXPointer) {
84 if (strcmp(device_info->name, "Virtual core pointer") != 0) { 88 if (strcmp(device_info->name, "Virtual core pointer") != 0) {
85 found_other_devices = true; 89 found_other_devices = true;
86 HOST_LOG << "Non Xvfb mouse found: " << device_info->name; 90 HOST_LOG << "Non Xvfb mouse found: " << device_info->name;
87 } 91 }
88 } else if (device_info->use == IsXKeyboard) { 92 } else if (device_info->use == IsXKeyboard) {
89 if (strcmp(device_info->name, "Virtual core keyboard") != 0) { 93 if (strcmp(device_info->name, "Virtual core keyboard") != 0) {
90 found_other_devices = true; 94 found_other_devices = true;
91 HOST_LOG << "Non Xvfb keyboard found: " << device_info->name; 95 HOST_LOG << "Non Xvfb keyboard found: " << device_info->name;
92 } 96 }
93 } else { 97 } else {
94 found_other_devices = true; 98 found_other_devices = true;
95 HOST_LOG << "Non Xvfb device found: " << device_info->name; 99 HOST_LOG << "Non Xvfb device found: " << device_info->name;
96 } 100 }
97 } 101 }
98 XFreeDeviceList(devices); 102 XFreeDeviceList(devices);
99 XCloseDisplay(display); 103 XCloseDisplay(display);
100 return found_xvfb_mouse && found_xvfb_keyboard && !found_other_devices; 104 return (found_xvfb_mouse && found_xvfb_keyboard) != found_crd_void_input
Jamie 2016/05/07 00:05:47 Why are you using != here instead of ||? It makes
rkjnsn 2016/05/09 16:58:33 My initial thought was that it should be xor since
Jamie 2016/05/09 17:08:43 Xor is unusual enough that it's not immediately cl
105 && !found_other_devices;
101 } 106 }
102 107
103 // static 108 // static
104 std::unique_ptr<CurtainMode> CurtainMode::Create( 109 std::unique_ptr<CurtainMode> CurtainMode::Create(
105 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 110 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
106 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 111 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
107 base::WeakPtr<ClientSessionControl> client_session_control) { 112 base::WeakPtr<ClientSessionControl> client_session_control) {
108 return base::WrapUnique(new CurtainModeLinux()); 113 return base::WrapUnique(new CurtainModeLinux());
109 } 114 }
110 115
111 } // namespace remoting 116 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/linux/linux_me2me_host.py » ('j') | remoting/host/linux/linux_me2me_host.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698