Test for feature (e.g. USE_X11) not Linux
As well as being more technically correct, this makes the jobs of
porters to other OSes easier. It should be a NOP for all supported
platforms.
Bug: 290185
Change-Id: Ib0528cfe431f652173768a6916b31ee51199e84f
Reviewed-on: https://chromium-review.googlesource.com/540916
Commit-Queue: Tim Brown <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Dominic Mazzoni <[email protected]>
Reviewed-by: Thomas Anderson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#482396}
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index d43831d2..1510834 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/buildflag_header.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//gpu/vulkan/features.gni")
@@ -172,6 +173,7 @@
]
public_deps = [
+ ":accessibility_flags",
"//ipc",
"//media/mojo/interfaces:remoting",
"//third_party/WebKit/public:offscreen_canvas_mojo_bindings",
@@ -2144,6 +2146,12 @@
}
}
+buildflag_header("accessibility_flags") {
+ header = "accessibility_flags.h"
+ header_dir = "content/browser/accessibility"
+ flags = [ "USE_ATK=$use_atk" ]
+}
+
# See comment at the top of //content/BUILD.gn for how this works.
group("for_content_tests") {
visibility = [ "//content/test/*" ]
diff --git a/content/browser/accessibility/ax_platform_position.cc b/content/browser/accessibility/ax_platform_position.cc
index cf01ea9..47caacda 100644
--- a/content/browser/accessibility/ax_platform_position.cc
+++ b/content/browser/accessibility/ax_platform_position.cc
@@ -4,6 +4,7 @@
#include "content/browser/accessibility/ax_platform_position.h"
+#include "content/browser/accessibility/accessibility_flags.h"
#include "content/browser/accessibility/browser_accessibility.h"
#include "content/browser/accessibility/browser_accessibility_manager.h"
#include "ui/accessibility/ax_enums.h"
@@ -103,8 +104,7 @@
// with a special (embedded object) character and not with their actual text
// contents.
int AXPlatformPosition::MaxTextOffsetInParent() const {
-#if defined(OS_WIN) || \
- (defined(OS_LINUX) && defined(USE_X11) && !defined(OS_CHROMEOS))
+#if defined(OS_WIN) || BUILDFLAG(USE_ATK)
if (IsNullPosition())
return INVALID_OFFSET;
if (GetAnchor()->IsTextOnlyObject())
diff --git a/content/browser/accessibility/browser_accessibility.h b/content/browser/accessibility/browser_accessibility.h
index 8d9152b..577f145 100644
--- a/content/browser/accessibility/browser_accessibility.h
+++ b/content/browser/accessibility/browser_accessibility.h
@@ -15,6 +15,7 @@
#include "base/strings/string16.h"
#include "base/strings/string_split.h"
#include "build/build_config.h"
+#include "content/browser/accessibility/accessibility_flags.h"
#include "content/browser/accessibility/ax_platform_position.h"
#include "content/common/content_export.h"
#include "third_party/WebKit/public/web/WebAXEnums.h"
@@ -42,7 +43,7 @@
#define PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL 1
#endif
-#if defined(OS_LINUX) && defined(USE_X11) && !defined(OS_CHROMEOS)
+#if BUILDFLAG(USE_ATK)
#define PLATFORM_HAS_NATIVE_ACCESSIBILITY_IMPL 1
#endif
diff --git a/content/browser/accessibility/browser_accessibility_manager.h b/content/browser/accessibility/browser_accessibility_manager.h
index 3f1d7b5..47338156 100644
--- a/content/browser/accessibility/browser_accessibility_manager.h
+++ b/content/browser/accessibility/browser_accessibility_manager.h
@@ -14,6 +14,7 @@
#include "base/containers/hash_tables.h"
#include "base/macros.h"
#include "build/build_config.h"
+#include "content/browser/accessibility/accessibility_flags.h"
#include "content/browser/accessibility/ax_platform_position.h"
#include "content/browser/accessibility/browser_accessibility_event.h"
#include "content/common/content_export.h"
@@ -36,7 +37,7 @@
class BrowserAccessibilityManagerAndroid;
#elif defined(OS_WIN)
class BrowserAccessibilityManagerWin;
-#elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11)
+#elif BUILDFLAG(USE_ATK)
class BrowserAccessibilityManagerAuraLinux;
#elif defined(OS_MACOSX)
class BrowserAccessibilityManagerMac;
@@ -259,7 +260,7 @@
BrowserAccessibilityManagerAndroid* ToBrowserAccessibilityManagerAndroid();
#endif
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11)
+#if BUILDFLAG(USE_ATK)
BrowserAccessibilityManagerAuraLinux*
ToBrowserAccessibilityManagerAuraLinux();
#endif
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index 09bcda3..52a9d1eb 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -55,7 +55,7 @@
#include "storage/browser/blob/blob_url_request_job_factory.h"
#include "url/origin.h"
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
#include "base/nix/xdg_util.h"
#endif
@@ -178,7 +178,7 @@
}
};
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
base::FilePath GetTemporaryDownloadDirectory() {
std::unique_ptr<base::Environment> env(base::Environment::Create());
return base::nix::GetXDGDirectory(env.get(), "XDG_DATA_HOME", ".local/share");
@@ -370,7 +370,7 @@
}
base::FilePath default_download_directory;
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
// TODO(thomasanderson): Remove this when all Linux distros with
// versions of GTK lower than 3.14.7 are no longer supported. This
// should happen when support for Ubuntu Trusty and Debian Jessie
diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc
index 0d2dd13..ad9dd844c 100644
--- a/content/browser/download/download_manager_impl_unittest.cc
+++ b/content/browser/download/download_manager_impl_unittest.cc
@@ -553,7 +553,7 @@
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetNextId(_))
.WillOnce(RunCallback<0>(local_id));
-#if !defined(OS_LINUX) || defined(OS_CHROMEOS)
+#if !defined(USE_X11) || defined(OS_CHROMEOS)
// Doing nothing will set the default download directory to null.
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _, _));
#endif
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 9a4eece..6f9dbcf6 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -112,7 +112,7 @@
#include "ui/gfx/gdi_util.h"
#endif
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11)
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
#include "content/browser/accessibility/browser_accessibility_auralinux.h"
#endif
@@ -629,7 +629,7 @@
host_->GetOrCreateRootBrowserAccessibilityManager();
if (manager)
return ToBrowserAccessibilityWin(manager->GetRoot())->GetCOM();
-#elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_X11)
+#elif defined(USE_X11) && !defined(OS_CHROMEOS)
BrowserAccessibilityManager* manager =
host_->GetOrCreateRootBrowserAccessibilityManager();
if (manager)