Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 28 matching lines...) Expand all Loading... | |
| 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() { |
| 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 |
|
Lambros
2016/05/10 00:30:15
Should probably remove all "Xvfb" references (as w
rkjnsn
2016/05/10 20:04:07
Done.
| |
| 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; |
|
Lambros
2016/05/10 00:30:15
Maybe "Non-virtual.." or "External.." or "Physical
rkjnsn
2016/05/10 20:04:07
Done.
| |
| 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) |
| 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 |
| OLD | NEW |