Skip to content

Commit

Permalink
Revert "[Lacros] Enable WebUSB, WebSerial, chrome.usb, chrome.serial …
Browse files Browse the repository at this point in the history
…API support."

This reverts commit 97e3106.

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}
  • Loading branch information
Hidehiko Abe authored and Chromium LUCI CQ committed Jun 21, 2021
1 parent 1c8a904 commit 5b439bf
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 71 deletions.
9 changes: 3 additions & 6 deletions chrome/browser/extensions/api/chrome_extensions_api_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/extensions/api/chrome_extensions_api_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions chromeos/dbus/permission_broker/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
2 changes: 1 addition & 1 deletion device/gamepad/gamepad_device_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion extensions/browser/api/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ source_set("api") {
"clipboard/clipboard_api.h",
]
deps += [
"//chromeos/dbus/permission_broker",
"//components/prefs:prefs",
"//ui/base/clipboard",
]
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 5 additions & 6 deletions extensions/browser/api/device_permissions_prompt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions extensions/browser/api/extensions_api_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions extensions/browser/api/extensions_api_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 4 additions & 4 deletions extensions/browser/api/usb/usb_apitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions extensions/browser/api/usb/usb_device_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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_)
Expand Down
4 changes: 2 additions & 2 deletions extensions/browser/api/usb/usb_device_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 1 addition & 3 deletions services/device/hid/hid_service_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions services/device/public/cpp/test/fake_usb_device_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions services/device/public/cpp/test/fake_usb_device_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ 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;

void OpenFileDescriptor(const std::string& guid,
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;
Expand Down
4 changes: 2 additions & 2 deletions services/device/public/mojom/usb_manager.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ 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
// a file descriptor. Allow access only to interfaces specified in
// |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);
Expand Down
14 changes: 7 additions & 7 deletions services/device/serial/serial_io_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions services/device/serial/serial_io_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion services/device/usb/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static_library("usb") {
]
}

if (is_chromeos_ash || is_chromeos_lacros) {
if (is_chromeos_ash) {
deps += [
"//chromeos/dbus/permission_broker",
"//dbus",
Expand Down
10 changes: 5 additions & 5 deletions services/device/usb/mojo/device_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 5b439bf

Please sign in to comment.