Commit 9aae6d14 authored by Yuta Hijikata's avatar Yuta Hijikata Committed by Commit Bot

LaCrOS: Replace defined(OS_CHROMEOS) with BUILDFLAG(IS_CHROMEOS_ASH)

The change is mostly mechanical replacing defined(OS_CHROMEOS) with
BUILDFLAG(IS_CHROMEOS_ASH) and GN variable is_chromeos with is_ash
with some special cases (For those cases please refer to
http://go/lacros-macros).

The patch is made in preparation to switching lacros build from
target_os=linux to target_os=chromeos. This will prevent lacros from
changing behaviour after the switch.

Bug: 1052397
Change-Id: Iedb6f15e5aac26bdf6eb17d4017e6fe86f22f951
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2537252Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Yuta Hijikata <ythjkt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829112}
parent d0fdf9ff
......@@ -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/config/chromeos/ui_mode.gni")
import("//build/config/ui.gni")
import("//testing/test.gni")
import("//ui/display/display.gni")
......@@ -91,6 +92,7 @@ component("display") {
deps = [
"//base",
"//build:chromeos_buildflags",
"//mojo/public/cpp/bindings:struct_traits",
"//ui/display/util",
"//ui/gfx",
......@@ -128,6 +130,7 @@ component("display_manager_test_api") {
deps = [
"//base",
"//build:chromeos_buildflags",
"//ui/display",
"//ui/display/types",
]
......@@ -232,6 +235,7 @@ test("display_unittests") {
":test_support",
"//base",
"//base/test:test_support",
"//build:chromeos_buildflags",
"//cc/base",
"//mojo/core/test:run_all_unittests",
"//testing/gmock",
......@@ -253,7 +257,7 @@ test("display_unittests") {
sources += [ "display_change_notifier_unittest.cc" ]
}
if (is_chromeos) {
if (is_chromeos_ash) {
deps += [ "//chromeos/constants" ]
}
}
......@@ -2,7 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/chromeos/ui_mode.gni")
declare_args() {
# Build Chrome OS display configuration code.
build_display_configuration = is_chromeos
build_display_configuration = is_chromeos_ash
}
......@@ -5,11 +5,12 @@
#include "ui/display/display_features.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
namespace display {
namespace features {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Enables using HDR transfer function if the monitor says it supports it.
const base::Feature kUseHDRTransferFunction {
"UseHDRTransferFunction",
......
......@@ -6,12 +6,13 @@
#define UI_DISPLAY_DISPLAY_FEATURES_H_
#include "base/feature_list.h"
#include "build/chromeos_buildflags.h"
#include "ui/display/display_export.h"
namespace display {
namespace features {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
DISPLAY_EXPORT extern const base::Feature kUseHDRTransferFunction;
#endif
......
......@@ -4,6 +4,7 @@
#include "ui/display/display_switches.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
namespace switches {
......@@ -53,7 +54,7 @@ const char kScreenConfig[] = "screen-config";
// This is for debugging on linux desktop.
const char kUseFirstDisplayAsInternal[] = "use-first-display-as-internal";
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Enables unified desktop mode.
const char kEnableUnifiedDesktop[] = "ash-enable-unified-desktop";
#endif
......
......@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "base/feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "ui/display/display_export.h"
namespace switches {
......@@ -24,7 +25,7 @@ DISPLAY_EXPORT extern const char kScreenConfig[];
DISPLAY_EXPORT extern const char kSecondaryDisplayLayout[];
DISPLAY_EXPORT extern const char kUseFirstDisplayAsInternal[];
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
DISPLAY_EXPORT extern const char kEnableUnifiedDesktop[];
#endif
......
......@@ -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/config/chromeos/ui_mode.gni")
import("//build/config/ui.gni")
import("//ui/display/display.gni")
......@@ -55,6 +56,7 @@ component("manager") {
deps = [
"//base",
"//build:chromeos_buildflags",
"//ui/base",
"//ui/display/mojom:mojom",
"//ui/display/util",
......@@ -65,7 +67,7 @@ component("manager") {
defines = [ "DISPLAY_MANAGER_IMPLEMENTATION" ]
if (is_chromeos) {
if (is_chromeos_ash) {
deps += [ "//chromeos/system" ]
}
}
......@@ -17,6 +17,7 @@
#include "base/cpu.h"
#include "base/no_destructor.h"
#include "base/stl_util.h"
#include "build/chromeos_buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/user_activity/user_activity_detector.h"
#include "ui/display/display.h"
......@@ -78,7 +79,7 @@ ManagedDisplayInfo::ManagedDisplayModeList GetModeListWithAllRefreshRates(
return display_mode_list;
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Constructs the raster DisplayColorSpaces out of |snapshot_color_space|,
// including the HDR ones if present and |allow_high_bit_depth| is set.
gfx::DisplayColorSpaces FillDisplayColorSpaces(
......@@ -393,7 +394,7 @@ ManagedDisplayInfo DisplayChangeObserver::CreateManagedDisplayInfo(
if (dpi)
new_info.set_device_dpi(dpi);
#if !defined(OS_CHROMEOS)
#if !BUILDFLAG(IS_CHROMEOS_ASH)
// TODO(crbug.com/1012846): This should configure the HDR color spaces.
gfx::DisplayColorSpaces display_color_spaces(
snapshot->color_space(), DisplaySnapshot::PrimaryFormat());
......
......@@ -9,6 +9,7 @@
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "build/chromeos_buildflags.h"
#include "cc/base/math_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display_features.h"
......@@ -419,7 +420,7 @@ TEST_P(DisplayChangeObserverTest, WCGDisplayColorSpaces) {
gfx::ColorSpace::TransferID::IEC61966_2_1);
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_P(DisplayChangeObserverTest, HDRDisplayColorSpaces) {
// TODO(crbug.com/1012846): Remove this flag and provision when HDR is fully
// supported on ChromeOS.
......@@ -481,7 +482,7 @@ INSTANTIATE_TEST_SUITE_P(All,
DisplayChangeObserverTest,
::testing::Values(false, true));
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
using DisplayResolutionTest = testing::Test;
TEST_F(DisplayResolutionTest, CheckEffectiveResoutionUMAIndex) {
......
......@@ -26,6 +26,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/chromeos_buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/display/display.h"
#include "ui/display/display_features.h"
......@@ -43,7 +44,7 @@
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/strings/grit/ui_strings.h"
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "chromeos/system/devicemode.h"
......@@ -73,7 +74,7 @@ const char kMirrorModeTypesHistogram[] = "DisplayManager.MirrorModeTypes";
const char kMirroringDisplayCountRangesHistogram[] =
"DisplayManager.MirroringDisplayCountRanges";
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// The UMA historgram that logs the zoom percentage level of the intenral
// display.
constexpr char kInternalDisplayZoomPercentageHistogram[] =
......@@ -82,7 +83,7 @@ constexpr char kInternalDisplayZoomPercentageHistogram[] =
// Timeout in seconds after which we consider the change to the display zoom
// is not temporary.
constexpr int kDisplayZoomModifyTimeoutSec = 15;
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
struct DisplaySortFunctor {
bool operator()(const Display& a, const Display& b) {
......@@ -147,7 +148,7 @@ bool ContainsDisplayWithId(const std::vector<Display>& displays,
return false;
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Gets the next mode in |modes| in the direction marked by |up|. If trying to
// move past either end of |modes|, returns the same.
......@@ -293,7 +294,7 @@ enum class MirrorModeTypes {
kCount,
};
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
void OnInternalDisplayZoomChanged(float zoom_factor) {
constexpr static int kMaxValue = 300;
constexpr static int kBucketSize = 5;
......@@ -304,7 +305,7 @@ void OnInternalDisplayZoomChanged(float zoom_factor) {
kNumBuckets, base::HistogramBase::kUmaTargetedHistogramFlag)
->Add(std::round(zoom_factor * 100));
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace
......@@ -326,7 +327,7 @@ DisplayManager::BeginEndNotifier::~BeginEndNotifier() {
DisplayManager::DisplayManager(std::unique_ptr<Screen> screen)
: screen_(std::move(screen)), layout_store_(new DisplayLayoutStore) {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
configure_displays_ = chromeos::IsRunningAsSystemCompositor();
change_display_upon_host_resize_ = !configure_displays_;
unified_desktop_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
......@@ -336,7 +337,7 @@ DisplayManager::DisplayManager(std::unique_ptr<Screen> screen)
}
DisplayManager::~DisplayManager() {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Reset the font params.
gfx::SetFontRenderParamsDeviceScaleFactor(1.0f);
on_display_zoom_modify_timeout_.Cancel();
......@@ -376,7 +377,7 @@ void DisplayManager::UpdateInternalDisplay(
}
void DisplayManager::RefreshFontParams() {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Use the largest device scale factor among currently active displays. Non
// internal display may have bigger scale factor in case the external display
// is an 4K display.
......@@ -387,7 +388,7 @@ void DisplayManager::RefreshFontParams() {
largest_device_scale_factor, info.GetEffectiveDeviceScaleFactor());
}
gfx::SetFontRenderParamsDeviceScaleFactor(largest_device_scale_factor);
#endif // OS_CHROMEOS
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
const DisplayLayout& DisplayManager::GetCurrentDisplayLayout() const {
......@@ -620,10 +621,10 @@ bool DisplayManager::SetDisplayMode(int64_t display_id,
if (resolution_changed && IsInUnifiedMode())
ReconfigureDisplays();
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
else if (resolution_changed && configure_displays_)
display_configurator_->OnConfigurationChanged();
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return resolution_changed || display_property_changed;
}
......@@ -841,7 +842,7 @@ void DisplayManager::OnNativeDisplaysChanged(
}
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (!configure_displays_ && new_display_info_list.size() > 1 &&
hardware_mirroring_display_id_list.empty()) {
DisplayIdList list = GenerateDisplayIdList(
......@@ -1369,7 +1370,7 @@ void DisplayManager::SetMirrorMode(
}
const bool enabled = mode != MirrorMode::kOff;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (configure_displays_) {
MultipleDisplayState new_state =
enabled ? MULTIPLE_DISPLAY_STATE_MULTI_MIRROR
......@@ -1444,7 +1445,7 @@ void DisplayManager::ToggleDisplayScaleFactor() {
UpdateDisplaysWith(new_display_info_list);
}
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
void DisplayManager::InitConfigurator(
std::unique_ptr<NativeDisplayDelegate> delegate) {
display_configurator_ = std::make_unique<display::DisplayConfigurator>();
......@@ -1670,7 +1671,7 @@ void DisplayManager::UpdateInternalManagedDisplayModeListForTest() {
}
bool DisplayManager::ZoomDisplay(int64_t display_id, bool up) {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (IsInUnifiedMode()) {
DCHECK_EQ(display_id, kUnifiedDisplayId);
const ManagedDisplayInfo& display_info = GetDisplayInfo(display_id);
......
......@@ -23,6 +23,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "build/chromeos_buildflags.h"
#include "ui/display/display.h"
#include "ui/display/display_layout.h"
#include "ui/display/display_observer.h"
......@@ -32,7 +33,7 @@
#include "ui/display/types/display_constants.h"
#include "ui/display/unified_desktop_utils.h"
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/cancelable_callback.h"
#include "base/optional.h"
#include "ui/display/manager/display_configurator.h"
......@@ -59,7 +60,7 @@ class DisplayManagerTestApi;
// DisplayManager maintains the current display configurations,
// and notifies observers when configuration changes.
class DISPLAY_MANAGER_EXPORT DisplayManager
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
: public DisplayConfigurator::SoftwareMirroringController
#endif
{
......@@ -108,7 +109,7 @@ class DISPLAY_MANAGER_EXPORT DisplayManager
};
explicit DisplayManager(std::unique_ptr<Screen> screen);
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
~DisplayManager() override;
#else
~DisplayManager();
......@@ -135,7 +136,7 @@ class DISPLAY_MANAGER_EXPORT DisplayManager
// Returns the display id of the first display in the outupt list.
int64_t first_display_id() const { return first_display_id_; }
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
TouchDeviceManager* touch_device_manager() const {
return touch_device_manager_.get();
}
......@@ -434,7 +435,7 @@ class DISPLAY_MANAGER_EXPORT DisplayManager
ManagedDisplayInfo::ManagedDisplayModeList display_modes = {});
void ToggleDisplayScaleFactor();
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
void InitConfigurator(std::unique_ptr<NativeDisplayDelegate> delegate);
void ForceInitialConfigureWithObservers(
display::DisplayChangeObserver* display_change_observer,
......@@ -689,7 +690,7 @@ class DISPLAY_MANAGER_EXPORT DisplayManager
// OnWillProcessDisplayChanges() and OnDidProcessDisplayChanges().
int notify_depth_ = 0;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<display::DisplayConfigurator> display_configurator_;
std::unique_ptr<TouchDeviceManager> touch_device_manager_;
......
......@@ -12,12 +12,13 @@
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/system/sys_info.h"
#include "build/chromeos_buildflags.h"
#include "ui/display/display_switches.h"
#include "ui/display/manager/managed_display_info.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/size_f.h"
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/system/statistics_provider.h"
#endif
......@@ -64,7 +65,7 @@ ManagedDisplayInfo::ManagedDisplayModeList CreateUnifiedManagedDisplayModeList(
bool ForceFirstDisplayInternal() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool ret = command_line->HasSwitch(::switches::kUseFirstDisplayAsInternal);
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Touch view mode is only available to internal display. We force the
// display as internal for emulator to test touch view mode.
ret = ret ||
......
......@@ -13,12 +13,13 @@
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "build/chromeos_buildflags.h"
#include "ui/display/manager/managed_display_info.h"
#include "ui/display/types/display_snapshot.h"
namespace display {
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) {
switch (state) {
case chromeos::DISPLAY_POWER_ALL_ON:
......@@ -56,7 +57,7 @@ int GetDisplayPower(const std::vector<DisplaySnapshot*>& displays,
return num_on_displays;
}
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
bool WithinEpsilon(float a, float b) {
return std::abs(a - b) < std::numeric_limits<float>::epsilon();
......
......@@ -8,19 +8,20 @@
#include <string>
#include <vector>
#include "build/chromeos_buildflags.h"
#include "ui/display/manager/display_manager_export.h"
#include "ui/display/types/display_constants.h"
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "third_party/cros_system_api/dbus/service_constants.h"
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace display {
class DisplaySnapshot;
class ManagedDisplayMode;
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Returns a string describing |state|.
std::string DisplayPowerStateToString(chromeos::DisplayPowerState state);
......@@ -32,7 +33,7 @@ GetDisplayPower(const std::vector<DisplaySnapshot*>& displays,
chromeos::DisplayPowerState state,
std::vector<bool>* display_power);
#endif // defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Determines whether |a| is within an epsilon of |b|.
bool WithinEpsilon(float a, float b);
......
......@@ -4,10 +4,11 @@
#include "ui/display/manager/managed_display_info.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display_switches.h"
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ui/display/manager/touch_device_manager.h"
#endif
......
......@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/strings/string_split.h"
#include "build/chromeos_buildflags.h"
#include "ui/display/display.h"
#include "ui/display/display_layout_builder.h"
#include "ui/display/manager/display_manager.h"
......@@ -87,7 +88,7 @@ void DisplayManagerTestApi::ResetMaximumDisplay() {
void DisplayManagerTestApi::UpdateDisplay(const std::string& display_specs) {
DisplayInfoList display_info_list =
CreateDisplayInfoListFromString(display_specs, display_manager_);
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (display_info_list.size() > maximum_support_display_) {
display_manager_->configurator()->has_unassociated_display_ = true;
while (display_info_list.size() > maximum_support_display_)
......
......@@ -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/config/chromeos/ui_mode.gni")
import("//build/config/ui.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
......@@ -27,7 +28,7 @@ component("util") {
"//ui/gfx/geometry",
]
if (is_chromeos) {
if (is_chromeos_ash) {
deps += [ "//ui/display/types" ]
} else if (is_mac) {
frameworks = [ "IOSurface.framework" ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment