0

[headless] Initialize Bluetooth on Linux with DBus

When using the --headless option with a normal Chrome build the
Bluetooth subsystem is fully enabled but the call to initialize the
connection to the BlueZ service over DBus was missing, leading to a
CHECK failure.

This change copies the initialization steps from the normal Chrome
startup sequence when DBus is enabled in the build.

Bug: 1093456
Change-Id: I171fbaa957acdcff521e020733d3024acf771e80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2240303
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777191}
This commit is contained in:
Reilly Grant
2020-06-11 00:36:00 +00:00
committed by Commit Bot
parent c0104578ad
commit 1fae077992
4 changed files with 32 additions and 1 deletions

@ -311,6 +311,7 @@ component("headless_non_renderer") {
"lib/browser/headless_browser_impl_mac.mm",
"lib/browser/headless_browser_main_parts.cc",
"lib/browser/headless_browser_main_parts.h",
"lib/browser/headless_browser_main_parts_linux.cc",
"lib/browser/headless_browser_main_parts_mac.mm",
"lib/browser/headless_devtools.cc",
"lib/browser/headless_devtools.h",
@ -377,6 +378,7 @@ component("headless_non_renderer") {
data_deps = []
data = []
defines = []
if (enable_basic_printing) {
public_deps += [ "//skia" ]
@ -491,6 +493,11 @@ component("headless_non_renderer") {
deps += [ "//ui/ozone" ]
}
if (use_dbus) {
defines += [ "USE_DBUS" ]
deps += [ "//device/bluetooth" ]
}
if (headless_fontconfig_utils && !is_fuchsia) {
deps += [ ":headless_fontconfig_utils" ]
}

@ -2,6 +2,9 @@ specific_include_rules = {
"headless_browser_browsertest.cc": [
"+third_party/crashpad/crashpad/client",
],
"headless_browser_main_parts_linux.cc": [
"+device/bluetooth",
],
"headless_content_client.cc": [
"+components/embedder_support/origin_trials",
],

@ -8,6 +8,7 @@
#include <memory>
#include "base/files/file_path.h"
#include "build/build_config.h"
#include "content/public/browser/browser_main_parts.h"
#include "content/public/common/main_function_params.h"
#include "headless/public/headless_browser.h"
@ -31,7 +32,9 @@ class HeadlessBrowserMainParts : public content::BrowserMainParts {
#if defined(OS_MACOSX)
void PreMainMessageLoopStart() override;
#endif
#if defined(OS_LINUX)
void PostMainMessageLoopStart() override;
#endif
void QuitMainMessageLoop();
private:

@ -0,0 +1,18 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "headless/lib/browser/headless_browser_main_parts.h"
#include "build/build_config.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
namespace headless {
void HeadlessBrowserMainParts::PostMainMessageLoopStart() {
#if defined(USE_DBUS) && !defined(OS_CHROMEOS)
bluez::BluezDBusManager::Initialize(/*system_bus=*/nullptr);
#endif
}
} // namespace headless