]> git.armaanb.net Git - asd-repo.git/blob - extra/chromium/patches/chromium-optional-atk-dbus.patch
Switch browser to Chromium
[asd-repo.git] / extra / chromium / patches / chromium-optional-atk-dbus.patch
1 diff --git a/build/config/ui.gni b/build/config/ui.gni
2 index 1ad352c..68a6be5 100644
3 --- a/build/config/ui.gni
4 +++ b/build/config/ui.gni
5 @@ -51,8 +51,10 @@ declare_args() {
6  assert(!use_glib || ((is_linux || is_chromeos_lacros) && !is_chromecast))
7  
8  # TODO(crbug.com/1171629): Remove is_chromeos_lacros.
9 -# Whether to use atk, the Accessibility ToolKit library
10 -use_atk = (is_linux || is_chromeos_lacros) && !is_chromecast && use_glib
11 +declare_args() {
12 +  # Whether to use atk, the Accessibility ToolKit library
13 +  use_atk = is_linux && !is_chromecast && use_glib
14 +}
15  
16  # Whether using Xvfb to provide a display server for a test might be
17  # necessary.
18 diff --git a/chrome/browser/chrome_browser_main_linux.cc b/chrome/browser/chrome_browser_main_linux.cc
19 index a9e1513..b64e334 100644
20 --- a/chrome/browser/chrome_browser_main_linux.cc
21 +++ b/chrome/browser/chrome_browser_main_linux.cc
22 @@ -79,7 +79,7 @@ void ChromeBrowserMainPartsLinux::PreProfileInit() {
23  
24  
25  void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() {
26 -#if !BUILDFLAG(IS_CHROMEOS_ASH)
27 +#if !BUILDFLAG(IS_CHROMEOS_ASH) && defined(USE_DBUS)
28    bluez::BluezDBusManager::Initialize(nullptr /* system_bus */);
29  #endif
30  
31 @@ -87,7 +87,7 @@ void ChromeBrowserMainPartsLinux::PostMainMessageLoopStart() {
32  }
33  
34  void ChromeBrowserMainPartsLinux::PostDestroyThreads() {
35 -#if !BUILDFLAG(IS_CHROMEOS_ASH)
36 +#if !BUILDFLAG(IS_CHROMEOS_ASH) && defined(USE_DBUS)
37    bluez::BluezDBusManager::Shutdown();
38    bluez::BluezDBusThreadManager::Shutdown();
39  #endif
40 diff --git a/chrome/browser/metrics/bluetooth_available_utility.cc b/chrome/browser/metrics/bluetooth_available_utility.cc
41 index a08be4c..55f3824 100644
42 --- a/chrome/browser/metrics/bluetooth_available_utility.cc
43 +++ b/chrome/browser/metrics/bluetooth_available_utility.cc
44 @@ -13,7 +13,7 @@
45  #include "device/bluetooth/bluetooth_adapter.h"
46  #include "device/bluetooth/bluetooth_adapter_factory.h"
47  
48 -#if defined(OS_LINUX) || defined(OS_CHROMEOS)
49 +#if defined(OS_LINUX) && defined(USE_DBUS) || defined(OS_CHROMEOS)
50  #include "device/bluetooth/dbus/bluez_dbus_manager.h"
51  #endif  // defined(OS_LINUX) || defined(OS_CHROMEOS)
52  
53 @@ -55,7 +55,7 @@ void ReportBluetoothAvailability() {
54      return;
55    }
56  
57 -#if defined(OS_LINUX) || defined(OS_CHROMEOS)
58 +#if defined(OS_LINUX) && defined(USE_DBUS)
59    // This is for tests that have not initialized bluez or dbus thread manager.
60    // Outside of tests these are initialized earlier during browser startup.
61    if (!bluez::BluezDBusManager::IsInitialized())
62 diff --git a/chrome/browser/platform_util_linux.cc b/chrome/browser/platform_util_linux.cc
63 index cbe3372..cfbfbc2 100644
64 --- a/chrome/browser/platform_util_linux.cc
65 +++ b/chrome/browser/platform_util_linux.cc
66 @@ -13,14 +13,18 @@
67  #include "base/threading/scoped_blocking_call.h"
68  #include "chrome/browser/chrome_notification_types.h"
69  #include "chrome/browser/platform_util_internal.h"
70 +#if defined(USE_DBUS)
71  #include "components/dbus/thread_linux/dbus_thread_linux.h"
72 +#endif
73  #include "content/public/browser/browser_thread.h"
74  #include "content/public/browser/notification_observer.h"
75  #include "content/public/browser/notification_registrar.h"
76  #include "content/public/browser/notification_service.h"
77 +#if defined(USE_DBUS)
78  #include "dbus/bus.h"
79  #include "dbus/message.h"
80  #include "dbus/object_proxy.h"
81 +#endif
82  #include "url/gurl.h"
83  
84  using content::BrowserThread;
85 @@ -29,6 +33,7 @@ namespace platform_util {
86  
87  namespace {
88  
89 +#if defined(USE_DBUS)
90  const char kFreedesktopFileManagerName[] = "org.freedesktop.FileManager1";
91  const char kFreedesktopFileManagerPath[] = "/org/freedesktop/FileManager1";
92  
93 @@ -116,6 +121,7 @@ class ShowItemHelper : public content::NotificationObserver {
94  
95    base::WeakPtrFactory<ShowItemHelper> weak_ptr_factory_{this};
96  };
97 +#endif
98  
99  void RunCommand(const std::string& command,
100                  const base::FilePath& working_directory,
101 @@ -182,8 +188,10 @@ void PlatformOpenVerifiedItem(const base::FilePath& path, OpenItemType type) {
102  }  // namespace internal
103  
104  void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) {
105 +#if defined(USE_DBUS)
106    DCHECK_CURRENTLY_ON(BrowserThread::UI);
107    ShowItemHelper::GetInstance().ShowItemInFolder(profile, full_path);
108 +#endif
109  }
110  
111  void OpenExternal(Profile* profile, const GURL& url) {
112 diff --git a/device/bluetooth/bluetooth_adapter_factory.cc b/device/bluetooth/bluetooth_adapter_factory.cc
113 index 2fa8e06..329fa52 100644
114 --- a/device/bluetooth/bluetooth_adapter_factory.cc
115 +++ b/device/bluetooth/bluetooth_adapter_factory.cc
116 @@ -46,7 +46,7 @@ bool BluetoothAdapterFactory::IsBluetoothSupported() {
117    // instance even on platforms that would otherwise not support it.
118    if (Get()->adapter_)
119      return true;
120 -#if defined(OS_ANDROID) || defined(OS_WIN) || defined(OS_LINUX) || \
121 +#if defined(OS_ANDROID) || defined(OS_WIN) || defined(OS_LINUX) && defined(USE_DBUS) || \
122      defined(OS_CHROMEOS) || defined(OS_MAC)
123    return true;
124  #else
125 @@ -69,7 +69,7 @@ bool BluetoothAdapterFactory::IsLowEnergySupported() {
126    return base::win::GetVersion() >= base::win::Version::WIN10;
127  #elif defined(OS_MAC)
128    return true;
129 -#elif (defined(OS_LINUX) || defined(OS_CHROMEOS))
130 +#elif (defined(OS_LINUX) && defined(USE_DBUS) || defined(OS_CHROMEOS))
131    return true;
132  #else
133    return false;
134 diff --git a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
135 index 776abf0..4e15678 100644
136 --- a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
137 +++ b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
138 @@ -1339,7 +1339,7 @@ void BluetoothLowEnergyCreateServiceFunction::DoWork() {
139  // TODO: Ideally this should be handled by our feature system, so that this
140  // code doesn't even compile on OSes it isn't being used on, but currently this
141  // is not possible.
142 -#if !defined(OS_WIN)
143 +#if !defined(OS_WIN) && (!defined(OS_LINUX) || defined(USE_DBUS))
144    base::WeakPtr<device::BluetoothLocalGattService> service =
145        device::BluetoothLocalGattService::Create(
146            event_router_->adapter(),
147 @@ -1368,6 +1368,7 @@ bool BluetoothLowEnergyCreateCharacteristicFunction::ParseParams() {
148  }
149  
150  void BluetoothLowEnergyCreateCharacteristicFunction::DoWork() {
151 +#if !defined(OS_LINUX) || defined(USE_DBUS)
152    device::BluetoothLocalGattService* service =
153        event_router_->adapter()->GetGattService(params_->service_id);
154    if (!service) {
155 @@ -1388,6 +1389,9 @@ void BluetoothLowEnergyCreateCharacteristicFunction::DoWork() {
156  
157    Respond(ArgumentList(apibtle::CreateCharacteristic::Results::Create(
158        characteristic->GetIdentifier())));
159 +#else
160 +  Respond(Error(kErrorPlatformNotSupported));
161 +#endif
162  }
163  
164  // createDescriptor:
165 @@ -1404,6 +1408,7 @@ bool BluetoothLowEnergyCreateDescriptorFunction::ParseParams() {
166  }
167  
168  void BluetoothLowEnergyCreateDescriptorFunction::DoWork() {
169 +#if !defined(OS_LINUX) || defined(USE_DBUS)
170    device::BluetoothLocalGattCharacteristic* characteristic =
171        event_router_->GetLocalCharacteristic(params_->characteristic_id);
172    if (!characteristic) {
173 @@ -1419,6 +1424,9 @@ void BluetoothLowEnergyCreateDescriptorFunction::DoWork() {
174  
175    Respond(ArgumentList(
176        apibtle::CreateDescriptor::Results::Create(descriptor->GetIdentifier())));
177 +#else
178 +  Respond(Error(kErrorPlatformNotSupported));
179 +#endif
180  }
181  
182  // registerService:
183 diff --git a/services/device/battery/battery_status_manager_default.cc b/services/device/battery/battery_status_manager_default.cc
184 index 3526876..dbaa872 100644
185 --- a/services/device/battery/battery_status_manager_default.cc
186 +++ b/services/device/battery/battery_status_manager_default.cc
187 @@ -22,11 +22,10 @@ class BatteryStatusManagerDefault : public BatteryStatusManager {
188   private:
189    // BatteryStatusManager:
190    bool StartListeningBatteryChange() override {
191 -    NOTIMPLEMENTED();
192      return false;
193    }
194  
195 -  void StopListeningBatteryChange() override { NOTIMPLEMENTED(); }
196 +  void StopListeningBatteryChange() override { }
197  
198    DISALLOW_COPY_AND_ASSIGN(BatteryStatusManagerDefault);
199  };
200 diff --git a/services/device/wake_lock/power_save_blocker/BUILD.gn b/services/device/wake_lock/power_save_blocker/BUILD.gn
201 index 8ca1d4d..5326d82 100644
202 --- a/services/device/wake_lock/power_save_blocker/BUILD.gn
203 +++ b/services/device/wake_lock/power_save_blocker/BUILD.gn
204 @@ -83,6 +83,9 @@ if (is_android) {
205      visibility = [ ":power_save_blocker" ]
206      sources = java_sources_needing_jni
207    }
208 +  if (!is_chromeos && use_x11 && !use_dbus) {
209 +    sources += [ "power_save_blocker_ozone.cc" ]
210 +  }
211  
212    android_library("java") {
213      # Conceptually, this should be visible only to //services/device:java.