0

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:

 0x5b1fdc2d8989 base::debug::CollectStackTrace()
 0x5b1fdc1e9d53 base::debug::StackTrace::StackTrace()
 0x5b1fdc2d84e1 base::debug::(anonymous namespace)::StackDumpSignalHandler()
 0x7a7b96fd29f0 (/lib64/libpthread-2.32.so+0x129ef)
 0x5b1fdef55c2b _sys_cr_finisheddevice::UsbDeviceLinux::Open()
 0x5b1fdef50b0f device::UsbServiceLinux::OnDeviceAdded()
 0x5b1fdef52570 base::internal::FunctorTraits<>::Invoke<>()
 0x5b1fdc263e50 base::TaskAnnotator::RunTask()
 0x5b1fdc289291 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
 0x5b1fdc28ace2 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
 0x5b1fdc36060b base::MessagePumpLibevent::Run()
 0x5b1fdc28b226 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run()
 0x5b1fdc2427b0 base::RunLoop::Run()
 0x5b1fd94e4ce6 content::BrowserMainLoop::RunMainMessageLoop()
 0x5b1fd94e6b92 content::BrowserMainRunnerImpl::Run()
 0x5b1fd94e1df8 content::BrowserMain()
 0x5b1fdc1b6810 content::ContentMainRunnerImpl::RunBrowser()
 0x5b1fdc1b6173 content::ContentMainRunnerImpl::Run()
 0x5b1fdc1b3d94 content::RunContentProcess()
 0x5b1fdc1b3e6c content::ContentMain()
 0x5b1fd7dafa1f ChromeMain
 0x7a7b96861e05 __libc_start_main
 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:
Hidehiko Abe
2021-06-21 17:06:59 +00:00
committed by Chromium LUCI CQ
parent 1c8a9043b2
commit 5b439bf16d
23 changed files with 64 additions and 71 deletions

@ -324,12 +324,9 @@ ChromeExtensionsAPIClient::CreateDevicePermissionsPrompt(
return std::make_unique<ChromeDevicePermissionsPrompt>(web_contents); 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, bool ChromeExtensionsAPIClient::ShouldAllowDetachingUsb(int vid,
int pid) const { 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; const base::ListValue* policy_list;
if (ash::CrosSettings::Get()->GetList(chromeos::kUsbDetachableAllowlist, if (ash::CrosSettings::Get()->GetList(chromeos::kUsbDetachableAllowlist,
&policy_list)) { &policy_list)) {
@ -340,10 +337,10 @@ bool ChromeExtensionsAPIClient::ShouldAllowDetachingUsb(int vid,
} }
} }
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return false; return false;
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<VirtualKeyboardDelegate> std::unique_ptr<VirtualKeyboardDelegate>
ChromeExtensionsAPIClient::CreateVirtualKeyboardDelegate( ChromeExtensionsAPIClient::CreateVirtualKeyboardDelegate(

@ -65,9 +65,9 @@ class ChromeExtensionsAPIClient : public ExtensionsAPIClient {
RulesCacheDelegate* cache_delegate) const override; RulesCacheDelegate* cache_delegate) const override;
std::unique_ptr<DevicePermissionsPrompt> CreateDevicePermissionsPrompt( std::unique_ptr<DevicePermissionsPrompt> CreateDevicePermissionsPrompt(
content::WebContents* web_contents) const override; 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; 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( std::unique_ptr<VirtualKeyboardDelegate> CreateVirtualKeyboardDelegate(
content::BrowserContext* browser_context) const override; content::BrowserContext* browser_context) const override;
ManagementAPIDelegate* CreateManagementAPIDelegate() const override; ManagementAPIDelegate* CreateManagementAPIDelegate() const override;

@ -70,7 +70,7 @@
#include "ui/base/text/bytes_formatting.h" #include "ui/base/text/bytes_formatting.h"
#include "ui/webui/webui_allowlist.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 "chrome/browser/ash/login/users/mock_user_manager.h"
#include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/scoped_user_manager.h"
#endif #endif

@ -4,8 +4,7 @@
import("//third_party/protobuf/proto_library.gni") import("//third_party/protobuf/proto_library.gni")
assert(is_chromeos_ash || is_chromeos_lacros, assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos")
"Non-Chrome-OS or Lacros builds must not depend on //chromeos")
component("permission_broker") { component("permission_broker") {
defines = [ "IS_PERMISSION_BROKER_IMPL" ] defines = [ "IS_PERMISSION_BROKER_IMPL" ]

@ -27,7 +27,7 @@
#include "device/udev_linux/udev.h" #include "device/udev_linux/udev.h"
#if BUILDFLAG(IS_CHROMEOS_ASH) #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) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace device { namespace device {

@ -72,7 +72,6 @@ source_set("api") {
"clipboard/clipboard_api.h", "clipboard/clipboard_api.h",
] ]
deps += [ deps += [
"//chromeos/dbus/permission_broker",
"//components/prefs:prefs", "//components/prefs:prefs",
"//ui/base/clipboard", "//ui/base/clipboard",
] ]
@ -104,6 +103,7 @@ source_set("api") {
"//chromeos/dbus", "//chromeos/dbus",
"//chromeos/dbus/media_analytics", "//chromeos/dbus/media_analytics",
"//chromeos/dbus/media_analytics:media_perception_proto", "//chromeos/dbus/media_analytics:media_perception_proto",
"//chromeos/dbus/permission_broker",
"//chromeos/dbus/upstart", "//chromeos/dbus/upstart",
"//chromeos/login/login_state", "//chromeos/login/login_state",
"//chromeos/services/media_perception/public/mojom", "//chromeos/services/media_perception/public/mojom",

@ -29,9 +29,9 @@
#include "services/device/public/mojom/usb_enumeration_options.mojom.h" #include "services/device/public/mojom/usb_enumeration_options.mojom.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #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) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
using device::HidDeviceFilter; using device::HidDeviceFilter;
using device::mojom::UsbDeviceFilterPtr; using device::mojom::UsbDeviceFilterPtr;
@ -149,7 +149,7 @@ class UsbDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt,
remaining_initial_devices_++; remaining_initial_devices_++;
auto device_info = std::make_unique<UsbDeviceInfo>(device.Clone()); 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()); auto* device_manager = UsbDeviceManager::Get(browser_context());
DCHECK(device_manager); DCHECK(device_manager);
device_manager->CheckAccess( device_manager->CheckAccess(
@ -159,7 +159,7 @@ class UsbDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt,
#else #else
AddCheckedDevice(std::move(device_info), initial_enumeration, AddCheckedDevice(std::move(device_info), initial_enumeration,
/*allowed=*/true); /*allowed=*/true);
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
} }
void AddCheckedDevice(std::unique_ptr<UsbDeviceInfo> device_info, void AddCheckedDevice(std::unique_ptr<UsbDeviceInfo> device_info,
@ -335,7 +335,6 @@ class HidDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt,
remaining_initial_devices_++; remaining_initial_devices_++;
auto device_info = std::make_unique<HidDeviceInfo>(std::move(device)); auto device_info = std::make_unique<HidDeviceInfo>(std::move(device));
// TODO(huangs): Enable this for Lacros (crbug.com/1217124).
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
chromeos::PermissionBrokerClient::Get()->CheckPathAccess( chromeos::PermissionBrokerClient::Get()->CheckPathAccess(
device_info.get()->device()->device_node, device_info.get()->device()->device_node,

@ -110,11 +110,11 @@ ExtensionsAPIClient::CreateDevicePermissionsPrompt(
return nullptr; return nullptr;
} }
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_ASH)
bool ExtensionsAPIClient::ShouldAllowDetachingUsb(int vid, int pid) const { bool ExtensionsAPIClient::ShouldAllowDetachingUsb(int vid, int pid) const {
return false; return false;
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<VirtualKeyboardDelegate> std::unique_ptr<VirtualKeyboardDelegate>
ExtensionsAPIClient::CreateVirtualKeyboardDelegate( ExtensionsAPIClient::CreateVirtualKeyboardDelegate(

@ -161,10 +161,10 @@ class ExtensionsAPIClient {
virtual std::unique_ptr<DevicePermissionsPrompt> virtual std::unique_ptr<DevicePermissionsPrompt>
CreateDevicePermissionsPrompt(content::WebContents* web_contents) const; 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. // Returns true if device policy allows detaching a given USB device.
virtual bool ShouldAllowDetachingUsb(int vid, int pid) const; 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. // Returns a delegate for some of VirtualKeyboardAPI's behavior.
virtual std::unique_ptr<VirtualKeyboardDelegate> virtual std::unique_ptr<VirtualKeyboardDelegate>

@ -114,11 +114,11 @@ class TestExtensionsAPIClient : public ShellExtensionsAPIClient {
return std::make_unique<TestDevicePermissionsPrompt>(web_contents); 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 { bool ShouldAllowDetachingUsb(int vid, int pid) const override {
return vid == 1 && pid == 2; return vid == 1 && pid == 2;
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
}; };
class UsbApiTest : public ShellApiTest { class UsbApiTest : public ShellApiTest {
@ -365,7 +365,7 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, GetUserSelectedDevices) {
ASSERT_TRUE(result_listener.WaitUntilSatisfied()); 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) { IN_PROC_BROWSER_TEST_F(UsbApiTest, MassStorage) {
ExtensionTestMessageListener ready_listener("ready", false); ExtensionTestMessageListener ready_listener("ready", false);
ready_listener.set_failure_message("failure"); ready_listener.set_failure_message("failure");
@ -397,6 +397,6 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, MassStorage) {
ASSERT_TRUE(result_listener.WaitUntilSatisfied()); ASSERT_TRUE(result_listener.WaitUntilSatisfied());
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace extensions } // 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( if (ExtensionsAPIClient::Get()->ShouldAllowDetachingUsb(
device_info.vendor_id, device_info.product_id)) { device_info.vendor_id, device_info.product_id)) {
return true; return true;
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
return false; return false;
} }
@ -212,14 +212,14 @@ bool UsbDeviceManager::UpdateActiveConfig(const std::string& guid,
return true; return true;
} }
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_ASH)
void UsbDeviceManager::CheckAccess( void UsbDeviceManager::CheckAccess(
const std::string& guid, const std::string& guid,
device::mojom::UsbDeviceManager::CheckAccessCallback callback) { device::mojom::UsbDeviceManager::CheckAccessCallback callback) {
EnsureConnectionWithDeviceManager(); EnsureConnectionWithDeviceManager();
device_manager_->CheckAccess(guid, std::move(callback)); device_manager_->CheckAccess(guid, std::move(callback));
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
void UsbDeviceManager::EnsureConnectionWithDeviceManager() { void UsbDeviceManager::EnsureConnectionWithDeviceManager() {
if (device_manager_) if (device_manager_)

@ -70,11 +70,11 @@ class UsbDeviceManager : public BrowserContextKeyedAPI,
const device::mojom::UsbDeviceInfo* GetDeviceInfo(const std::string& guid); const device::mojom::UsbDeviceInfo* GetDeviceInfo(const std::string& guid);
bool UpdateActiveConfig(const std::string& guid, uint8_t config_value); 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( void CheckAccess(
const std::string& guid, const std::string& guid,
device::mojom::UsbDeviceManager::CheckAccessCallback callback); device::mojom::UsbDeviceManager::CheckAccessCallback callback);
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
void EnsureConnectionWithDeviceManager(); void EnsureConnectionWithDeviceManager();

@ -36,11 +36,9 @@
#include "device/udev_linux/udev_watcher.h" #include "device/udev_linux/udev_watcher.h"
#include "services/device/hid/hid_connection_linux.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) #if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/system/sys_info.h" #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) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace device { namespace device {

@ -84,7 +84,7 @@ void FakeUsbDeviceManager::RefreshDeviceInfo(
} }
#endif #endif
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_ASH)
void FakeUsbDeviceManager::CheckAccess(const std::string& guid, void FakeUsbDeviceManager::CheckAccess(const std::string& guid,
CheckAccessCallback callback) { CheckAccessCallback callback) {
std::move(callback).Run(true); std::move(callback).Run(true);
@ -99,7 +99,7 @@ void FakeUsbDeviceManager::OpenFileDescriptor(
base::FilePath(FILE_PATH_LITERAL("/dev/null")), base::FilePath(FILE_PATH_LITERAL("/dev/null")),
base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE)); 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( void FakeUsbDeviceManager::SetClient(
mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient> client) { mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient> client) {

@ -86,7 +86,7 @@ class FakeUsbDeviceManager : public mojom::UsbDeviceManager {
RefreshDeviceInfoCallback callback) override; RefreshDeviceInfoCallback callback) override;
#endif #endif
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_ASH)
void CheckAccess(const std::string& guid, void CheckAccess(const std::string& guid,
CheckAccessCallback callback) override; CheckAccessCallback callback) override;
@ -94,7 +94,7 @@ class FakeUsbDeviceManager : public mojom::UsbDeviceManager {
uint32_t drop_privileges_mask, uint32_t drop_privileges_mask,
mojo::PlatformHandle lifeline_fd, mojo::PlatformHandle lifeline_fd,
OpenFileDescriptorCallback callback) override; OpenFileDescriptorCallback callback) override;
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
void SetClient(mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient> void SetClient(mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient>
client) override; client) override;

@ -41,7 +41,7 @@ interface UsbDeviceManager {
// Check whether permission_broker will allow a future Open call for // Check whether permission_broker will allow a future Open call for
// a given USB device to succeed. // a given USB device to succeed.
[EnableIf=is_chromeos] [EnableIf=is_chromeos_ash]
CheckAccess(string guid) => (bool success); CheckAccess(string guid) => (bool success);
// Attempt to open a USB device using permission_broker and return // 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 // |allowed_interfaces_mask|. The |lifeline_fd| should be the remote end of
// a pipe created locally, and when this pipe is closed permission_broker // a pipe created locally, and when this pipe is closed permission_broker
// reattaches any kernel drivers that may have been detached when opening. // 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, OpenFileDescriptor(string guid, uint32 allowed_interfaces_mask,
handle<platform> lifeline_fd) handle<platform> lifeline_fd)
=> (mojo_base.mojom.File? fd); => (mojo_base.mojom.File? fd);

@ -19,9 +19,9 @@
#include "build/chromeos_buildflags.h" #include "build/chromeos_buildflags.h"
#include "components/device_event_log/device_event_log.h" #include "components/device_event_log/device_event_log.h"
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #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) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace device { namespace device {
@ -51,7 +51,7 @@ void SerialIoHandler::Open(const mojom::SerialConnectionOptions& options,
DCHECK(ui_thread_task_runner_.get()); DCHECK(ui_thread_task_runner_.get());
MergeConnectionOptions(options); 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| // Note: dbus clients are destroyed in PostDestroyThreads so passing |client|
// as unretained is safe. // as unretained is safe.
auto* client = chromeos::PermissionBrokerClient::Get(); auto* client = chromeos::PermissionBrokerClient::Get();
@ -73,10 +73,10 @@ void SerialIoHandler::Open(const mojom::SerialConnectionOptions& options,
{base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&SerialIoHandler::StartOpen, this, base::BindOnce(&SerialIoHandler::StartOpen, this,
base::ThreadTaskRunnerHandle::Get())); 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( void SerialIoHandler::OnPathOpened(
scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, 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); std::move(open_complete_).Run(false);
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif
void SerialIoHandler::MergeConnectionOptions( void SerialIoHandler::MergeConnectionOptions(
const mojom::SerialConnectionOptions& options) { const mojom::SerialConnectionOptions& options) {

@ -44,7 +44,7 @@ class SerialIoHandler : public base::RefCountedThreadSafe<SerialIoHandler> {
virtual void Open(const mojom::SerialConnectionOptions& options, virtual void Open(const mojom::SerialConnectionOptions& options,
OpenCompleteCallback callback); OpenCompleteCallback callback);
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_ASH)
// Signals that the port has been opened. // Signals that the port has been opened.
void OnPathOpened( void OnPathOpened(
scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, 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. // Reports the open error from the permission broker.
void ReportPathOpenError(const std::string& error_name, void ReportPathOpenError(const std::string& error_name,
const std::string& error_message); 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 // Performs an async read operation. Behavior is undefined if this is called
// while a read is already pending. Otherwise, |callback| will eventually be // 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 += [ deps += [
"//chromeos/dbus/permission_broker", "//chromeos/dbus/permission_broker",
"//dbus", "//dbus",

@ -25,10 +25,10 @@
#include "services/device/usb/usb_device.h" #include "services/device/usb/usb_device.h"
#include "services/device/usb/usb_service.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" // nogncheck #include "chromeos/dbus/permission_broker/permission_broker_client.h"
#include "services/device/usb/usb_device_linux.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 device {
namespace usb { namespace usb {
@ -118,7 +118,7 @@ void DeviceManagerImpl::OnPermissionGrantedToRefresh(
} }
#endif // defined(OS_ANDROID) #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, void DeviceManagerImpl::CheckAccess(const std::string& guid,
CheckAccessCallback callback) { CheckAccessCallback callback) {
scoped_refptr<UsbDevice> device = usb_service_->GetDevice(guid); scoped_refptr<UsbDevice> device = usb_service_->GetDevice(guid);
@ -172,7 +172,7 @@ void DeviceManagerImpl::OnOpenFileDescriptorError(
<< message; << message;
std::move(callback).Run(base::File()); std::move(callback).Run(base::File());
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
void DeviceManagerImpl::SetClient( void DeviceManagerImpl::SetClient(
mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient> client) { mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient> client) {

@ -71,7 +71,7 @@ class DeviceManagerImpl : public mojom::UsbDeviceManager,
bool granted); bool granted);
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_ASH)
void CheckAccess(const std::string& guid, void CheckAccess(const std::string& guid,
CheckAccessCallback callback) override; CheckAccessCallback callback) override;
@ -86,7 +86,7 @@ class DeviceManagerImpl : public mojom::UsbDeviceManager,
void OnOpenFileDescriptorError(OpenFileDescriptorCallback callback, void OnOpenFileDescriptorError(OpenFileDescriptorCallback callback,
const std::string& error_name, const std::string& error_name,
const std::string& message); const std::string& message);
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
void SetClient(mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient> void SetClient(mojo::PendingAssociatedRemote<mojom::UsbDeviceManagerClient>
client) override; client) override;

@ -23,13 +23,13 @@
#include "services/device/usb/usb_device_handle_usbfs.h" #include "services/device/usb/usb_device_handle_usbfs.h"
#include "services/device/usb/usb_service.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" #include "chromeos/dbus/permission_broker/permission_broker_client.h"
namespace { namespace {
constexpr uint32_t kAllInterfacesMask = ~0U; constexpr uint32_t kAllInterfacesMask = ~0U;
} // namespace } // namespace
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace device { namespace device {
@ -40,7 +40,7 @@ UsbDeviceLinux::UsbDeviceLinux(const std::string& device_path,
UsbDeviceLinux::~UsbDeviceLinux() = default; UsbDeviceLinux::~UsbDeviceLinux() = default;
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_ASH)
void UsbDeviceLinux::CheckUsbAccess(ResultCallback callback) { void UsbDeviceLinux::CheckUsbAccess(ResultCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
@ -48,12 +48,12 @@ void UsbDeviceLinux::CheckUsbAccess(ResultCallback callback) {
std::move(callback)); std::move(callback));
} }
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
void UsbDeviceLinux::Open(OpenCallback callback) { void UsbDeviceLinux::Open(OpenCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 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 // create the pipe used as a lifetime to re-attach the original kernel driver
// to the USB device in permission_broker. // to the USB device in permission_broker.
base::ScopedFD read_end, write_end; base::ScopedFD read_end, write_end;
@ -78,10 +78,10 @@ void UsbDeviceLinux::Open(OpenCallback callback) {
base::BindOnce(&UsbDeviceLinux::OpenOnBlockingThread, this, base::BindOnce(&UsbDeviceLinux::OpenOnBlockingThread, this,
std::move(callback), base::ThreadTaskRunnerHandle::Get(), std::move(callback), base::ThreadTaskRunnerHandle::Get(),
blocking_task_runner)); 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, void UsbDeviceLinux::OnOpenRequestComplete(OpenCallback callback,
base::ScopedFD lifeline_fd, 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( void UsbDeviceLinux::Opened(
base::ScopedFD fd, base::ScopedFD fd,

@ -29,9 +29,9 @@ struct UsbDeviceDescriptor;
class UsbDeviceLinux : public UsbDevice { class UsbDeviceLinux : public UsbDevice {
public: public:
// UsbDevice implementation: // UsbDevice implementation:
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_ASH)
void CheckUsbAccess(ResultCallback callback) override; void CheckUsbAccess(ResultCallback callback) override;
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
void Open(OpenCallback callback) override; void Open(OpenCallback callback) override;
const std::string& device_path() const { return device_path_; } const std::string& device_path() const { return device_path_; }
@ -52,7 +52,7 @@ class UsbDeviceLinux : public UsbDevice {
~UsbDeviceLinux() override; ~UsbDeviceLinux() override;
private: private:
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_ASH)
void OnOpenRequestComplete(OpenCallback callback, void OnOpenRequestComplete(OpenCallback callback,
base::ScopedFD fd, base::ScopedFD fd,
base::ScopedFD lifeline_fd); base::ScopedFD lifeline_fd);
@ -64,7 +64,7 @@ class UsbDeviceLinux : public UsbDevice {
OpenCallback callback, OpenCallback callback,
scoped_refptr<base::SequencedTaskRunner> task_runner, scoped_refptr<base::SequencedTaskRunner> task_runner,
scoped_refptr<base::SequencedTaskRunner> blocking_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, void Opened(base::ScopedFD fd,
base::ScopedFD lifeline_fd, base::ScopedFD lifeline_fd,
OpenCallback callback, OpenCallback callback,