Revert "[Lacros] Enable WebUSB, WebSerial, chrome.usb, chrome.serial API support."
This reverts commit 97e310612b
.
Reason for revert: Crashing on DUT.
Here's the stack trace:
#0 0x5b1fdc2d8989 base::debug::CollectStackTrace()
#1 0x5b1fdc1e9d53 base::debug::StackTrace::StackTrace()
#2 0x5b1fdc2d84e1 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7a7b96fd29f0 (/lib64/libpthread-2.32.so+0x129ef)
#4 0x5b1fdef55c2b _sys_cr_finisheddevice::UsbDeviceLinux::Open()
#5 0x5b1fdef50b0f device::UsbServiceLinux::OnDeviceAdded()
#6 0x5b1fdef52570 base::internal::FunctorTraits<>::Invoke<>()
#7 0x5b1fdc263e50 base::TaskAnnotator::RunTask()
#8 0x5b1fdc289291 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
#9 0x5b1fdc28ace2 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
#10 0x5b1fdc36060b base::MessagePumpLibevent::Run()
#11 0x5b1fdc28b226 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run()
#12 0x5b1fdc2427b0 base::RunLoop::Run()
#13 0x5b1fd94e4ce6 content::BrowserMainLoop::RunMainMessageLoop()
#14 0x5b1fd94e6b92 content::BrowserMainRunnerImpl::Run()
#15 0x5b1fd94e1df8 content::BrowserMain()
#16 0x5b1fdc1b6810 content::ContentMainRunnerImpl::RunBrowser()
#17 0x5b1fdc1b6173 content::ContentMainRunnerImpl::Run()
#18 0x5b1fdc1b3d94 content::RunContentProcess()
#19 0x5b1fdc1b3e6c content::ContentMain()
#20 0x5b1fd7dafa1f ChromeMain
#21 0x7a7b96861e05 __libc_start_main
#22 0x5b1fd7daf8aa _start
r8: 00007fffb9571db0 r9: 00007fffb9571dd8 r10: 0000000000000058 r11: 0000000000000293
r12: 00001de68aaf7460 r13: 00007fffb9571dd8 r14: 00007fffb9571db0 r15: 00007fffb9571d88
di: 0000000000000000 si: 00005b1fddf84260 bp: 00007fffb9571f50 bx: 00001de689a4ad20
dx: 00005b1fddf84210 ax: 00001de689f0cb00 cx: 00001de689f0cfc0 sp: 00007fffb9571d60
ip: 00005b1fdef55c2b efl: 0000000000010202 cgf: 002b000000000033 erf: 0000000000000004
trp: 000000000000000e msk: 0000000000000000 cr2: 0000000000000000
Original change's description:
> [Lacros] Enable WebUSB, WebSerial, chrome.usb, chrome.serial API support.
>
> This CL enables USB and Serial related API on Lacros, by applying the
> broad stroke of switching Lacros to use code that was previously
> Ash-only. More work might be needed later to iron out details.
>
> Bug: 1195247, 1195248
> Change-Id: I04579cf60ca263907407abdc12cf7a9d5f9d10c6
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2939830
> Commit-Queue: Samuel Huang <huangs@chromium.org>
> Reviewed-by: Theodore Olsauskas-Warren <sauski@google.com>
> Reviewed-by: Tom Sepez <tsepez@chromium.org>
> Reviewed-by: Reilly Grant <reillyg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#893539}
Bug: 1195247, 1195248
Change-Id: I57c7a0dabb64c1ac25a4569fea5559778fe3e547
Owners-Override: Theodore Olsauskas-Warren <sauski@google.com>
Owners-Override: Tom Sepez <tsepez@chromium.org>
Owners-Override: Reilly Grant <reillyg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2972361
Reviewed-by: Samuel Huang <huangs@chromium.org>
Reviewed-by: Theodore Olsauskas-Warren <sauski@google.com>
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Joshua Pawlicki <waffles@chromium.org>
Auto-Submit: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#894279}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1c8a9043b2
commit
5b439bf16d
chrome/browser
extensions
ui
webui
chromeos/dbus/permission_broker
device/gamepad
extensions/browser/api
services/device
@ -324,12 +324,9 @@ ChromeExtensionsAPIClient::CreateDevicePermissionsPrompt(
|
||||
return std::make_unique<ChromeDevicePermissionsPrompt>(web_contents);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
bool ChromeExtensionsAPIClient::ShouldAllowDetachingUsb(int vid,
|
||||
int pid) const {
|
||||
// TOOD(huangs): Figure out how to do the following in Lacros, which does not
|
||||
// have access to ash::CrosSettings (https://crbug.com/1219329).
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
const base::ListValue* policy_list;
|
||||
if (ash::CrosSettings::Get()->GetList(chromeos::kUsbDetachableAllowlist,
|
||||
&policy_list)) {
|
||||
@ -340,10 +337,10 @@ bool ChromeExtensionsAPIClient::ShouldAllowDetachingUsb(int vid,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
std::unique_ptr<VirtualKeyboardDelegate>
|
||||
ChromeExtensionsAPIClient::CreateVirtualKeyboardDelegate(
|
||||
|
@ -65,9 +65,9 @@ class ChromeExtensionsAPIClient : public ExtensionsAPIClient {
|
||||
RulesCacheDelegate* cache_delegate) const override;
|
||||
std::unique_ptr<DevicePermissionsPrompt> CreateDevicePermissionsPrompt(
|
||||
content::WebContents* web_contents) const override;
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
bool ShouldAllowDetachingUsb(int vid, int pid) const override;
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
std::unique_ptr<VirtualKeyboardDelegate> CreateVirtualKeyboardDelegate(
|
||||
content::BrowserContext* browser_context) const override;
|
||||
ManagementAPIDelegate* CreateManagementAPIDelegate() const override;
|
||||
|
@ -70,7 +70,7 @@
|
||||
#include "ui/base/text/bytes_formatting.h"
|
||||
#include "ui/webui/webui_allowlist.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "chrome/browser/ash/login/users/mock_user_manager.h"
|
||||
#include "components/user_manager/scoped_user_manager.h"
|
||||
#endif
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
import("//third_party/protobuf/proto_library.gni")
|
||||
|
||||
assert(is_chromeos_ash || is_chromeos_lacros,
|
||||
"Non-Chrome-OS or Lacros builds must not depend on //chromeos")
|
||||
assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos")
|
||||
|
||||
component("permission_broker") {
|
||||
defines = [ "IS_PERMISSION_BROKER_IMPL" ]
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "device/udev_linux/udev.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h" // nogncheck
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h"
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
namespace device {
|
||||
|
@ -72,7 +72,6 @@ source_set("api") {
|
||||
"clipboard/clipboard_api.h",
|
||||
]
|
||||
deps += [
|
||||
"//chromeos/dbus/permission_broker",
|
||||
"//components/prefs:prefs",
|
||||
"//ui/base/clipboard",
|
||||
]
|
||||
@ -104,6 +103,7 @@ source_set("api") {
|
||||
"//chromeos/dbus",
|
||||
"//chromeos/dbus/media_analytics",
|
||||
"//chromeos/dbus/media_analytics:media_perception_proto",
|
||||
"//chromeos/dbus/permission_broker",
|
||||
"//chromeos/dbus/upstart",
|
||||
"//chromeos/login/login_state",
|
||||
"//chromeos/services/media_perception/public/mojom",
|
||||
|
@ -29,9 +29,9 @@
|
||||
#include "services/device/public/mojom/usb_enumeration_options.mojom.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h" // nogncheck
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h"
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
using device::HidDeviceFilter;
|
||||
using device::mojom::UsbDeviceFilterPtr;
|
||||
@ -149,7 +149,7 @@ class UsbDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt,
|
||||
remaining_initial_devices_++;
|
||||
|
||||
auto device_info = std::make_unique<UsbDeviceInfo>(device.Clone());
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
auto* device_manager = UsbDeviceManager::Get(browser_context());
|
||||
DCHECK(device_manager);
|
||||
device_manager->CheckAccess(
|
||||
@ -159,7 +159,7 @@ class UsbDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt,
|
||||
#else
|
||||
AddCheckedDevice(std::move(device_info), initial_enumeration,
|
||||
/*allowed=*/true);
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
}
|
||||
|
||||
void AddCheckedDevice(std::unique_ptr<UsbDeviceInfo> device_info,
|
||||
@ -335,7 +335,6 @@ class HidDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt,
|
||||
remaining_initial_devices_++;
|
||||
|
||||
auto device_info = std::make_unique<HidDeviceInfo>(std::move(device));
|
||||
// TODO(huangs): Enable this for Lacros (crbug.com/1217124).
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
chromeos::PermissionBrokerClient::Get()->CheckPathAccess(
|
||||
device_info.get()->device()->device_node,
|
||||
|
@ -110,11 +110,11 @@ ExtensionsAPIClient::CreateDevicePermissionsPrompt(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
bool ExtensionsAPIClient::ShouldAllowDetachingUsb(int vid, int pid) const {
|
||||
return false;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
std::unique_ptr<VirtualKeyboardDelegate>
|
||||
ExtensionsAPIClient::CreateVirtualKeyboardDelegate(
|
||||
|
@ -161,10 +161,10 @@ class ExtensionsAPIClient {
|
||||
virtual std::unique_ptr<DevicePermissionsPrompt>
|
||||
CreateDevicePermissionsPrompt(content::WebContents* web_contents) const;
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// Returns true if device policy allows detaching a given USB device.
|
||||
virtual bool ShouldAllowDetachingUsb(int vid, int pid) const;
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
// Returns a delegate for some of VirtualKeyboardAPI's behavior.
|
||||
virtual std::unique_ptr<VirtualKeyboardDelegate>
|
||||
|
@ -114,11 +114,11 @@ class TestExtensionsAPIClient : public ShellExtensionsAPIClient {
|
||||
return std::make_unique<TestDevicePermissionsPrompt>(web_contents);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
bool ShouldAllowDetachingUsb(int vid, int pid) const override {
|
||||
return vid == 1 && pid == 2;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
};
|
||||
|
||||
class UsbApiTest : public ShellApiTest {
|
||||
@ -365,7 +365,7 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, GetUserSelectedDevices) {
|
||||
ASSERT_TRUE(result_listener.WaitUntilSatisfied());
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
IN_PROC_BROWSER_TEST_F(UsbApiTest, MassStorage) {
|
||||
ExtensionTestMessageListener ready_listener("ready", false);
|
||||
ready_listener.set_failure_message("failure");
|
||||
@ -397,6 +397,6 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, MassStorage) {
|
||||
|
||||
ASSERT_TRUE(result_listener.WaitUntilSatisfied());
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
} // namespace extensions
|
||||
|
@ -52,12 +52,12 @@ bool ShouldExposeDevice(const device::mojom::UsbDeviceInfo& device_info) {
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
if (ExtensionsAPIClient::Get()->ShouldAllowDetachingUsb(
|
||||
device_info.vendor_id, device_info.product_id)) {
|
||||
return true;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -212,14 +212,14 @@ bool UsbDeviceManager::UpdateActiveConfig(const std::string& guid,
|
||||
return true;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void UsbDeviceManager::CheckAccess(
|
||||
const std::string& guid,
|
||||
device::mojom::UsbDeviceManager::CheckAccessCallback callback) {
|
||||
EnsureConnectionWithDeviceManager();
|
||||
device_manager_->CheckAccess(guid, std::move(callback));
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void UsbDeviceManager::EnsureConnectionWithDeviceManager() {
|
||||
if (device_manager_)
|
||||
|
@ -70,11 +70,11 @@ class UsbDeviceManager : public BrowserContextKeyedAPI,
|
||||
const device::mojom::UsbDeviceInfo* GetDeviceInfo(const std::string& guid);
|
||||
bool UpdateActiveConfig(const std::string& guid, uint8_t config_value);
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void CheckAccess(
|
||||
const std::string& guid,
|
||||
device::mojom::UsbDeviceManager::CheckAccessCallback callback);
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void EnsureConnectionWithDeviceManager();
|
||||
|
||||
|
@ -36,11 +36,9 @@
|
||||
#include "device/udev_linux/udev_watcher.h"
|
||||
#include "services/device/hid/hid_connection_linux.h"
|
||||
|
||||
// TODO(huangs): Enable for IS_CHROMEOS_LACROS. This will simplify crosapi so
|
||||
// that it won't need to pass HidManager around (crbug.com/1109621).
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "base/system/sys_info.h"
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h" // nogncheck
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h"
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
namespace device {
|
||||
|
@ -84,7 +84,7 @@ void FakeUsbDeviceManager::RefreshDeviceInfo(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void FakeUsbDeviceManager::CheckAccess(const std::string& guid,
|
||||
CheckAccessCallback callback) {
|
||||
std::move(callback).Run(true);
|
||||
@ -99,7 +99,7 @@ void FakeUsbDeviceManager::OpenFileDescriptor(
|
||||
base::FilePath(FILE_PATH_LITERAL("/dev/null")),
|
||||
base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE));
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void FakeUsbDeviceManager::SetClient(
|
||||
mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient> client) {
|
||||
|
@ -86,7 +86,7 @@ class FakeUsbDeviceManager : public mojom::UsbDeviceManager {
|
||||
RefreshDeviceInfoCallback callback) override;
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void CheckAccess(const std::string& guid,
|
||||
CheckAccessCallback callback) override;
|
||||
|
||||
@ -94,7 +94,7 @@ class FakeUsbDeviceManager : public mojom::UsbDeviceManager {
|
||||
uint32_t drop_privileges_mask,
|
||||
mojo::PlatformHandle lifeline_fd,
|
||||
OpenFileDescriptorCallback callback) override;
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void SetClient(mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient>
|
||||
client) override;
|
||||
|
@ -41,7 +41,7 @@ interface UsbDeviceManager {
|
||||
|
||||
// Check whether permission_broker will allow a future Open call for
|
||||
// a given USB device to succeed.
|
||||
[EnableIf=is_chromeos]
|
||||
[EnableIf=is_chromeos_ash]
|
||||
CheckAccess(string guid) => (bool success);
|
||||
|
||||
// Attempt to open a USB device using permission_broker and return
|
||||
@ -49,7 +49,7 @@ interface UsbDeviceManager {
|
||||
// |allowed_interfaces_mask|. The |lifeline_fd| should be the remote end of
|
||||
// a pipe created locally, and when this pipe is closed permission_broker
|
||||
// reattaches any kernel drivers that may have been detached when opening.
|
||||
[EnableIf=is_chromeos]
|
||||
[EnableIf=is_chromeos_ash]
|
||||
OpenFileDescriptor(string guid, uint32 allowed_interfaces_mask,
|
||||
handle<platform> lifeline_fd)
|
||||
=> (mojo_base.mojom.File? fd);
|
||||
|
@ -19,9 +19,9 @@
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "components/device_event_log/device_event_log.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h" // nogncheck
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h"
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
namespace device {
|
||||
|
||||
@ -51,7 +51,7 @@ void SerialIoHandler::Open(const mojom::SerialConnectionOptions& options,
|
||||
DCHECK(ui_thread_task_runner_.get());
|
||||
MergeConnectionOptions(options);
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// Note: dbus clients are destroyed in PostDestroyThreads so passing |client|
|
||||
// as unretained is safe.
|
||||
auto* client = chromeos::PermissionBrokerClient::Get();
|
||||
@ -73,10 +73,10 @@ void SerialIoHandler::Open(const mojom::SerialConnectionOptions& options,
|
||||
{base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
|
||||
base::BindOnce(&SerialIoHandler::StartOpen, this,
|
||||
base::ThreadTaskRunnerHandle::Get()));
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void SerialIoHandler::OnPathOpened(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
|
||||
@ -105,7 +105,7 @@ void SerialIoHandler::ReportPathOpenError(const std::string& error_name,
|
||||
std::move(open_complete_).Run(false);
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif
|
||||
|
||||
void SerialIoHandler::MergeConnectionOptions(
|
||||
const mojom::SerialConnectionOptions& options) {
|
||||
|
@ -44,7 +44,7 @@ class SerialIoHandler : public base::RefCountedThreadSafe<SerialIoHandler> {
|
||||
virtual void Open(const mojom::SerialConnectionOptions& options,
|
||||
OpenCompleteCallback callback);
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// Signals that the port has been opened.
|
||||
void OnPathOpened(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
|
||||
@ -59,7 +59,7 @@ class SerialIoHandler : public base::RefCountedThreadSafe<SerialIoHandler> {
|
||||
// Reports the open error from the permission broker.
|
||||
void ReportPathOpenError(const std::string& error_name,
|
||||
const std::string& error_message);
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
// Performs an async read operation. Behavior is undefined if this is called
|
||||
// while a read is already pending. Otherwise, |callback| will eventually be
|
||||
|
@ -149,7 +149,7 @@ static_library("usb") {
|
||||
]
|
||||
}
|
||||
|
||||
if (is_chromeos_ash || is_chromeos_lacros) {
|
||||
if (is_chromeos_ash) {
|
||||
deps += [
|
||||
"//chromeos/dbus/permission_broker",
|
||||
"//dbus",
|
||||
|
@ -25,10 +25,10 @@
|
||||
#include "services/device/usb/usb_device.h"
|
||||
#include "services/device/usb/usb_service.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h" // nogncheck
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h"
|
||||
#include "services/device/usb/usb_device_linux.h"
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
namespace device {
|
||||
namespace usb {
|
||||
@ -118,7 +118,7 @@ void DeviceManagerImpl::OnPermissionGrantedToRefresh(
|
||||
}
|
||||
#endif // defined(OS_ANDROID)
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void DeviceManagerImpl::CheckAccess(const std::string& guid,
|
||||
CheckAccessCallback callback) {
|
||||
scoped_refptr<UsbDevice> device = usb_service_->GetDevice(guid);
|
||||
@ -172,7 +172,7 @@ void DeviceManagerImpl::OnOpenFileDescriptorError(
|
||||
<< message;
|
||||
std::move(callback).Run(base::File());
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void DeviceManagerImpl::SetClient(
|
||||
mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient> client) {
|
||||
|
@ -71,7 +71,7 @@ class DeviceManagerImpl : public mojom::UsbDeviceManager,
|
||||
bool granted);
|
||||
#endif // defined(OS_ANDROID)
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void CheckAccess(const std::string& guid,
|
||||
CheckAccessCallback callback) override;
|
||||
|
||||
@ -86,7 +86,7 @@ class DeviceManagerImpl : public mojom::UsbDeviceManager,
|
||||
void OnOpenFileDescriptorError(OpenFileDescriptorCallback callback,
|
||||
const std::string& error_name,
|
||||
const std::string& message);
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void SetClient(mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient>
|
||||
client) override;
|
||||
|
@ -23,13 +23,13 @@
|
||||
#include "services/device/usb/usb_device_handle_usbfs.h"
|
||||
#include "services/device/usb/usb_service.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "chromeos/dbus/permission_broker/permission_broker_client.h"
|
||||
|
||||
namespace {
|
||||
constexpr uint32_t kAllInterfacesMask = ~0U;
|
||||
} // namespace
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
namespace device {
|
||||
|
||||
@ -40,7 +40,7 @@ UsbDeviceLinux::UsbDeviceLinux(const std::string& device_path,
|
||||
|
||||
UsbDeviceLinux::~UsbDeviceLinux() = default;
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void UsbDeviceLinux::CheckUsbAccess(ResultCallback callback) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
@ -48,12 +48,12 @@ void UsbDeviceLinux::CheckUsbAccess(ResultCallback callback) {
|
||||
std::move(callback));
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void UsbDeviceLinux::Open(OpenCallback callback) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// create the pipe used as a lifetime to re-attach the original kernel driver
|
||||
// to the USB device in permission_broker.
|
||||
base::ScopedFD read_end, write_end;
|
||||
@ -78,10 +78,10 @@ void UsbDeviceLinux::Open(OpenCallback callback) {
|
||||
base::BindOnce(&UsbDeviceLinux::OpenOnBlockingThread, this,
|
||||
std::move(callback), base::ThreadTaskRunnerHandle::Get(),
|
||||
blocking_task_runner));
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void UsbDeviceLinux::OnOpenRequestComplete(OpenCallback callback,
|
||||
base::ScopedFD lifeline_fd,
|
||||
@ -122,7 +122,7 @@ void UsbDeviceLinux::OpenOnBlockingThread(
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
void UsbDeviceLinux::Opened(
|
||||
base::ScopedFD fd,
|
||||
|
@ -29,9 +29,9 @@ struct UsbDeviceDescriptor;
|
||||
class UsbDeviceLinux : public UsbDevice {
|
||||
public:
|
||||
// UsbDevice implementation:
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void CheckUsbAccess(ResultCallback callback) override;
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void Open(OpenCallback callback) override;
|
||||
|
||||
const std::string& device_path() const { return device_path_; }
|
||||
@ -52,7 +52,7 @@ class UsbDeviceLinux : public UsbDevice {
|
||||
~UsbDeviceLinux() override;
|
||||
|
||||
private:
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void OnOpenRequestComplete(OpenCallback callback,
|
||||
base::ScopedFD fd,
|
||||
base::ScopedFD lifeline_fd);
|
||||
@ -64,7 +64,7 @@ class UsbDeviceLinux : public UsbDevice {
|
||||
OpenCallback callback,
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner,
|
||||
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void Opened(base::ScopedFD fd,
|
||||
base::ScopedFD lifeline_fd,
|
||||
OpenCallback callback,
|
||||
|
Reference in New Issue
Block a user