0

Remove IS_CHROMEOS(|_ASH|_LACROS) usage from chromeos/

- IS_CHROMEOS_LACROS is always false, remove uses and any code.
- IS_CHROMEOS_ASH is obsolete and replaced with IS_CHROMEOS. However,
  in source code from this directory it's always true, so remove it
  (except for assertions).
- Remove some unnecessary includes, mostly as consequence of the above.

Bug: b:354842935, b:365742770
Change-Id: I4a197c8a424c4beffec232f7a46badefaa90301c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6204846
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1412697}
This commit is contained in:
Georg Neis
2025-01-28 22:15:45 -08:00
committed by Chromium LUCI CQ
parent 5134fa1257
commit ac588f79de
43 changed files with 56 additions and 503 deletions

@ -34,13 +34,7 @@ base::WeakPtr<Kcer> ExtraInstances::GetEmptyKcer() {
// static
base::WeakPtr<Kcer> ExtraInstances::GetDeviceKcer() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
#if BUILDFLAG(IS_CHROMEOS_ASH)
return Get()->device_kcer_->GetWeakPtr();
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
// At the moment `device_kcer_` is never initialized for Lacros. This can be
// changed if needed.
return GetEmptyKcer();
#endif
}
void ExtraInstances::InitializeDeviceKcer(
@ -60,9 +54,7 @@ ExtraInstances::ExtraInstances() {
empty_kcer_.Initialize(/*token_task_runner=*/nullptr, /*user_token=*/nullptr,
/*device_token=*/nullptr);
#if BUILDFLAG(IS_CHROMEOS_ASH)
device_kcer_ = std::make_unique<internal::KcerImpl>();
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
// Never called (see NoDestructor<>).

@ -28,7 +28,6 @@
#include "base/metrics/histogram_functions.h"
#include "base/task/bind_post_task.h"
#include "base/task/thread_pool.h"
#include "build/chromeos_buildflags.h"
#include "chromeos/ash/components/chaps_util/chaps_util.h"
#include "chromeos/ash/components/kcer/cert_cache.h"
#include "chromeos/ash/components/kcer/chaps/high_level_chaps_client.h"
@ -142,13 +141,9 @@ void GenerateRsaKeyOnWorkerThread(Token token,
slot.get(), modulus_length_bits_uint, /*permanent=*/true, &public_key,
&private_key);
} else {
#if BUILDFLAG(IS_CHROMEOS_ASH)
auto chaps_util = chromeos::ChapsUtil::Create();
key_gen_success = chaps_util->GenerateSoftwareBackedRSAKey(
slot.get(), modulus_length_bits_uint, &public_key, &private_key);
#else
return std::move(callback).Run(base::unexpected(Error::kNotImplemented));
#endif
}
if (!key_gen_success) {

@ -14,6 +14,7 @@
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "build/chromeos_buildflags.h"
#include "chromeos/ash/components/memory/elf_sections.h"
namespace ash {

@ -52,7 +52,6 @@ source_set("unit_tests") {
":userspace_swap",
"//base/allocator:buildflags",
"//base/test:test_support",
"//build:chromeos_buildflags",
"//mojo/core/embedder",
"//services/resource_coordinator/public/cpp/memory_instrumentation",
"//testing/gmock",

@ -16,8 +16,5 @@ component("metrics") {
output_name = "ash_metrics"
deps = [
"//base",
"//build:chromeos_buildflags",
]
deps = [ "//base" ]
}

@ -3,7 +3,6 @@ noparent = True
include_rules = [
"+ash/constants",
"+base",
"+build/chromeos_buildflags.h",
"+components/user_manager/user_type.h",
"+google_apis/gaia",
"+third_party/icu",

@ -18,12 +18,11 @@
#include "base/memory/raw_ptr.h"
#include "base/sequence_checker.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "chromeos/ash/components/settings/cros_settings_names.h"
#include "chromeos/ash/components/settings/cros_settings_provider.h"
#include "components/user_manager/user_type.h"
static_assert(BUILDFLAG(IS_CHROMEOS_ASH), "For ChromeOS ash-chrome only");
static_assert(BUILDFLAG(IS_CHROMEOS), "For ChromeOS only");
namespace ash {

@ -5,11 +5,9 @@
#ifndef CHROMEOS_ASH_EXPERIENCES_ARC_ARC_EXPORT_H_
#define CHROMEOS_ASH_EXPERIENCES_ARC_ARC_EXPORT_H_
#include "build/chromeos_buildflags.h"
#include "build/build_config.h"
#if !BUILDFLAG(IS_CHROMEOS_ASH)
#error "ARC can be built only for Chrome OS."
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
static_assert(BUILDFLAG(IS_CHROMEOS), "ARC can be built only for ChromeOS.");
#if defined(COMPONENT_BUILD) && defined(ARC_IMPLEMENTATION)
#define ARC_EXPORT __attribute__((visibility("default")))

@ -21,12 +21,9 @@
#include "ui/gfx/image/image_skia.h"
#include "url/gurl.h"
#if !BUILDFLAG(IS_CHROMEOS)
#error "ARC files should only be included for ChromeOS/ASH"
#endif
static_assert(BUILDFLAG(IS_CHROMEOS), "ARC can be built only for ChromeOS.");
namespace arc {
class AdaptiveIconDelegate;
namespace internal {
@ -63,8 +60,8 @@ class ActivityIconLoader {
SUCCEEDED_ASYNC,
// Succeeded. The callback has already been called synchronously.
SUCCEEDED_SYNC,
// Failed. The intent_helper instance is not yet ready. This is a temporary
// error.
// Failed. The intent_helper instance is not yet ready. This is a
// temporary error.
FAILED_ARC_NOT_READY,
// Failed. Either ARC is not supported at all or intent_helper instance
// version is too old.

@ -7,7 +7,6 @@
#include "base/component_export.h"
#include "base/files/file_path.h"
#include "build/chromeos_buildflags.h"
namespace ash::libassistant {

@ -16,7 +16,6 @@
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "build/chromeos_buildflags.h"
#include "chromeos/ash/components/dbus/dlcservice/dlcservice_client.h"
#include "chromeos/ash/services/assistant/public/cpp/assistant_enums.h"
#include "chromeos/ash/services/assistant/public/cpp/features.h"

@ -8,7 +8,6 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "build/chromeos_buildflags.h"
#include "chromeos/ash/services/network_health/in_process_instance.h"
#include "chromeos/ash/services/network_health/network_health_service.h"
#include "url/gurl.h"

@ -13,7 +13,6 @@ component("cdm_factory_daemon_browser") {
public_deps = [ "//chromeos/components/cdm_factory_daemon/mojom" ]
deps = [
"//base",
"//build:chromeos_buildflags",
"//content/public/browser",
"//mojo/public/cpp/bindings",
]

@ -83,7 +83,6 @@ void GetOutputProtectionOnTaskRunner(
std::move(output_protection));
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
class SingletonCdmContextRef : public media::CdmContextRef {
public:
explicit SingletonCdmContextRef(media::CdmContext* cdm_context)
@ -157,7 +156,6 @@ class ArcCdmContext : public ChromeOsCdmContext, public media::CdmContext {
// media::CdmContext implementation.
ChromeOsCdmContext* GetChromeOsCdmContext() override { return this; }
};
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void OnCdmCreated(media::CdmCreatedCB callback,
scoped_refptr<ContentDecryptionModuleAdapter> cdm,
@ -278,7 +276,6 @@ void ChromeOsCdmFactory::ParseEncryptedSliceHeader(
secure_handle, offset, stream_data, std::move(callback));
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
// static
void ChromeOsCdmFactory::SetBrowserCdmFactoryRemote(
mojo::Remote<cdm::mojom::BrowserCdmFactory> remote) {
@ -292,7 +289,6 @@ media::CdmContext* ChromeOsCdmFactory::GetArcCdmContext() {
static base::NoDestructor<ArcCdmContext> arc_cdm_context;
return arc_cdm_context.get();
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void ChromeOsCdmFactory::OnVerifiedAccessEnabled(
const media::CdmConfig& cdm_config,

@ -10,7 +10,6 @@
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "build/chromeos_buildflags.h"
#include "chromeos/components/cdm_factory_daemon/chromeos_cdm_context.h"
#include "chromeos/components/cdm_factory_daemon/mojom/browser_cdm_factory.mojom.h"
#include "chromeos/components/cdm_factory_daemon/mojom/cdm_factory_daemon.mojom.h"
@ -76,7 +75,6 @@ class COMPONENT_EXPORT(CDM_FACTORY_DAEMON) ChromeOsCdmFactory
const std::vector<uint8_t>& stream_data,
ChromeOsCdmContext::ParseEncryptedSliceHeaderCB callback);
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Invoked in the OOP Video Decoder utility process to set the Mojo connection
// back to the browser process. Normally the GPU process has a Mojo connection
// to the browser process for this purpose. When we launch an OOP Video
@ -90,7 +88,6 @@ class COMPONENT_EXPORT(CDM_FACTORY_DAEMON) ChromeOsCdmFactory
// Returns a singleton pointer that can be used as the media::CdmContext for
// ARC video decode operations.
static media::CdmContext* GetArcCdmContext();
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
private:
void OnVerifiedAccessEnabled(

@ -11,10 +11,7 @@ static_library("kiosk") {
"kiosk_utils.cc",
"kiosk_utils.h",
]
deps = [
"//build:chromeos_buildflags",
"//chromeos/crosapi/mojom",
]
deps = [ "//chromeos/crosapi/mojom" ]
if (is_chromeos_ash) {
deps += [ "//components/user_manager" ]
@ -30,10 +27,7 @@ static_library("test_support") {
"kiosk_test_utils.cc",
"kiosk_test_utils.h",
]
deps = [
"//build:chromeos_buildflags",
"//chromeos/crosapi/mojom",
]
deps = [ "//chromeos/crosapi/mojom" ]
if (is_chromeos_ash) {
deps += [
"//components/account_id",

@ -4,24 +4,16 @@
#include "chromeos/components/kiosk/kiosk_test_utils.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/check.h"
#include "components/account_id/account_id.h" // nogncheck
#include "components/account_id/account_id.h"
#include "components/user_manager/fake_user_manager.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_manager_impl.h"
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/startup/browser_init_params.h" // nogncheck
#endif
namespace chromeos {
void SetUpFakeKioskSession(const std::string& email) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
CHECK(user_manager::UserManager::Get());
auto* user_manager = static_cast<user_manager::UserManagerImpl*>(
@ -33,12 +25,6 @@ void SetUpFakeKioskSession(const std::string& email) {
user_manager->UserLoggedIn(user->GetAccountId(), user->username_hash(),
/* browser_restart= */ false,
/* is_child= */ false);
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
crosapi::mojom::BrowserInitParamsPtr init_params =
chromeos::BrowserInitParams::GetForTests()->Clone();
init_params->session_type = crosapi::mojom::SessionType::kWebKioskSession;
chromeos::BrowserInitParams::SetInitParamsForTests(std::move(init_params));
#endif
}
} // namespace chromeos

@ -4,45 +4,18 @@
#include "chromeos/components/kiosk/kiosk_utils.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/user_manager/user_manager.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/crosapi/mojom/crosapi.mojom.h"
#include "chromeos/startup/browser_params_proxy.h"
#endif
namespace chromeos {
bool IsKioskSession() {
#if BUILDFLAG(IS_CHROMEOS_ASH)
return user_manager::UserManager::IsInitialized() &&
user_manager::UserManager::Get()->IsLoggedInAsAnyKioskApp();
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
crosapi::mojom::SessionType session_type =
chromeos::BrowserParamsProxy::Get()->SessionType();
return session_type == crosapi::mojom::SessionType::kWebKioskSession ||
session_type == crosapi::mojom::SessionType::kAppKioskSession;
#else
return false;
#endif
}
bool IsWebKioskSession() {
#if BUILDFLAG(IS_CHROMEOS_ASH)
return user_manager::UserManager::IsInitialized() &&
user_manager::UserManager::Get()->IsLoggedInAsWebKioskApp();
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
crosapi::mojom::SessionType session_type =
chromeos::BrowserParamsProxy::Get()->SessionType();
return session_type == crosapi::mojom::SessionType::kWebKioskSession;
#else
return false;
#endif
}
} // namespace chromeos

@ -4,23 +4,14 @@
#include "chromeos/components/mahi/public/cpp/mahi_manager.h"
#include "ash/constants/ash_switches.h"
#include "base/check_is_test.h"
#include "base/check_op.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_switches.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "google_apis/gaia/gaia_auth_util.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/startup/browser_params_proxy.h"
#endif
namespace chromeos {

@ -11,10 +11,7 @@ static_library("mgs") {
"managed_guest_session_utils.cc",
"managed_guest_session_utils.h",
]
deps = [
"//build:chromeos_buildflags",
"//chromeos/crosapi/mojom",
]
deps = [ "//chromeos/crosapi/mojom" ]
if (is_chromeos_ash) {
deps += [ "//chromeos/ash/components/login/login_state:login_state" ]
@ -30,10 +27,7 @@ static_library("test_support") {
"managed_guest_session_test_utils.cc",
"managed_guest_session_test_utils.h",
]
deps = [
"//build:chromeos_buildflags",
"//chromeos/crosapi/mojom",
]
deps = [ "//chromeos/crosapi/mojom" ]
if (is_chromeos_ash) {
deps += [ "//chromeos/ash/components/login/login_state:login_state" ]
}

@ -4,14 +4,7 @@
#include "chromeos/components/mgs/managed_guest_session_test_utils.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/login/login_state/login_state.h"
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/startup/browser_init_params.h"
#endif
namespace chromeos {
@ -25,27 +18,18 @@ FakeManagedGuestSession::~FakeManagedGuestSession() {
}
void FakeManagedGuestSession::SetUpFakeManagedGuestSession() {
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (initialize_login_state_) {
ash::LoginState::Initialize();
}
ash::LoginState::Get()->SetLoggedInState(
ash::LoginState::LoggedInState::LOGGED_IN_ACTIVE,
ash::LoginState::LoggedInUserType::LOGGED_IN_USER_PUBLIC_ACCOUNT);
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
crosapi::mojom::BrowserInitParamsPtr init_params =
chromeos::BrowserInitParams::GetForTests()->Clone();
init_params->session_type = crosapi::mojom::SessionType::kPublicSession;
chromeos::BrowserInitParams::SetInitParamsForTests(std::move(init_params));
#endif
}
void FakeManagedGuestSession::TearDownFakeManagedGuestSession() {
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (initialize_login_state_) {
ash::LoginState::Shutdown();
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
} // namespace chromeos

@ -4,30 +4,13 @@
#include "chromeos/components/mgs/managed_guest_session_utils.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/login/login_state/login_state.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/crosapi/mojom/crosapi.mojom.h"
#include "chromeos/startup/browser_params_proxy.h"
#endif
namespace chromeos {
bool IsManagedGuestSession() {
#if BUILDFLAG(IS_CHROMEOS_ASH)
return ash::LoginState::IsInitialized() &&
ash::LoginState::Get()->IsManagedGuestSessionUser();
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()->SessionType() ==
crosapi::mojom::SessionType::kPublicSession;
#else
return false;
#endif
}
} // namespace chromeos

@ -52,26 +52,17 @@ class FakeObserver : public QuickAnswersStateObserver {
quick_answers::prefs::ConsentStatus::kUnknown;
};
std::unique_ptr<base::test::ScopedFeatureList> EnableMagicBoost() {
// Note that `kMahi` is associated with the Magic Boost feature.
auto feature_list = std::make_unique<base::test::ScopedFeatureList>();
feature_list->InitWithFeatures(
{chromeos::features::kMahi, chromeos::features::kFeatureManagementMahi},
{});
return feature_list;
}
class QuickAnswersStateWithMagicBoostTest : public testing::Test {
protected:
QuickAnswersStateWithMagicBoostTest() {
// Note that `kMahi` is associated with the Magic Boost feature.
feature_list_.InitWithFeatures(
{chromeos::features::kMahi, chromeos::features::kFeatureManagementMahi},
{});
}
std::unique_ptr<base::test::ScopedFeatureList> MaybeEnableMagicBoost() {
#if BUILDFLAG(IS_CHROMEOS)
return EnableMagicBoost();
#else
// chromeos_components_unittests is expected to run only in Ash build for now.
//
// Build config:
// https://source.chromium.org/chromium/chromium/src/+/main:BUILD.gn;l=454;drc=bfcb02f1ceb574659c9f0d9b5eb1cbf85040696b
return nullptr;
#endif
}
base::test::ScopedFeatureList feature_list_;
};
} // namespace
@ -103,12 +94,7 @@ TEST(QuickAnswersStateTest, IsEligibleObserverInit) {
EXPECT_TRUE(observer.is_eligible());
}
TEST(QuickAnswersStateTest, IsEligibleFeatureType) {
std::unique_ptr<base::test::ScopedFeatureList> magic_boost_enabled =
MaybeEnableMagicBoost();
ASSERT_TRUE(magic_boost_enabled)
<< "This *test* code does not support Lacros. See MaybeEnableMagicBoost.";
TEST_F(QuickAnswersStateWithMagicBoostTest, IsEligibleFeatureType) {
chromeos::test::FakeMagicBoostState magic_boost_state;
FakeQuickAnswersState quick_answers_state;
quick_answers_state.SetApplicationLocale("en");
@ -150,10 +136,7 @@ TEST(QuickAnswersStateTest, EnabledButNotEligible) {
// MagicBoost availability check requires an async operation. There is a short
// period where `MagicBoostState` returns false for its availability even if a
// user/device is eligible.
TEST(QuickAnswersStateTest, MagicBoostStateEligibilityChanged) {
std::unique_ptr<base::test::ScopedFeatureList> magic_boost_enabled =
EnableMagicBoost();
TEST_F(QuickAnswersStateWithMagicBoostTest, MagicBoostStateEligibilityChanged) {
chromeos::test::FakeMagicBoostState magic_boost_state;
magic_boost_state.SetMagicBoostAvailability(false);
FakeQuickAnswersState quick_answers_state;
@ -203,12 +186,7 @@ TEST(QuickAnswersStateTest, IsEnabledObserverInit) {
EXPECT_TRUE(observer.is_enabled());
}
TEST(QuickAnswersStateTest, IsEnabledUnderMagicBoost) {
std::unique_ptr<base::test::ScopedFeatureList> magic_boost_enabled =
MaybeEnableMagicBoost();
ASSERT_TRUE(magic_boost_enabled)
<< "This *test* code does not support Lacros. See MaybeEnableMagicBoost.";
TEST_F(QuickAnswersStateWithMagicBoostTest, IsEnabledUnderMagicBoost) {
chromeos::test::FakeMagicBoostState magic_boost_state;
FakeQuickAnswersState quick_answers_state;
quick_answers_state.SetApplicationLocale("en");
@ -288,12 +266,7 @@ TEST(QuickAnswersStateTest, GetConsentStatus) {
observer.consent_status());
}
TEST(QuickAnswersStateTest, GetConsentStatusUnderMagicBoost) {
std::unique_ptr<base::test::ScopedFeatureList> magic_boost_enabled =
MaybeEnableMagicBoost();
ASSERT_TRUE(magic_boost_enabled)
<< "This *test* code does not support Lacros. See MaybeEnableMagicBoost.";
TEST_F(QuickAnswersStateWithMagicBoostTest, GetConsentStatusUnderMagicBoost) {
chromeos::test::FakeMagicBoostState magic_boost_state;
FakeObserver observer;
FakeQuickAnswersState quick_answers_state;
@ -317,12 +290,7 @@ TEST(QuickAnswersStateTest, GetConsentStatusUnderMagicBoost) {
observer.consent_status());
}
TEST(QuickAnswersStateTest, PendingUnderMagicBoost) {
std::unique_ptr<base::test::ScopedFeatureList> magic_boost_enabled =
MaybeEnableMagicBoost();
ASSERT_TRUE(magic_boost_enabled)
<< "This *test* code does not support Lacros. See MaybeEnableMagicBoost.";
TEST_F(QuickAnswersStateWithMagicBoostTest, PendingUnderMagicBoost) {
chromeos::test::FakeMagicBoostState magic_boost_state;
FakeQuickAnswersState quick_answers_state;
quick_answers_state.SetApplicationLocale("en");
@ -341,12 +309,7 @@ TEST(QuickAnswersStateTest, PendingUnderMagicBoost) {
"via MagicBoost.";
}
TEST(QuickAnswersStateTest, PendingNotEnabledUnderMagicBoost) {
std::unique_ptr<base::test::ScopedFeatureList> magic_boost_enabled =
MaybeEnableMagicBoost();
ASSERT_TRUE(magic_boost_enabled)
<< "This *test* code does not support Lacros. See MaybeEnableMagicBoost.";
TEST_F(QuickAnswersStateWithMagicBoostTest, PendingNotEnabledUnderMagicBoost) {
chromeos::test::FakeMagicBoostState magic_boost_state;
FakeQuickAnswersState quick_answers_state;
quick_answers_state.SetApplicationLocale("en");
@ -429,12 +392,7 @@ TEST(QuickAnswersStateTest, IsIntentEligibleGatedByGlobalEligible) {
<< "Intent is ineligible if a feature itself is ineligible";
}
TEST(QuickAnswersStateTest, IsIntentEligibleUnderMagicBoost) {
std::unique_ptr<base::test::ScopedFeatureList> magic_boost_enabled =
MaybeEnableMagicBoost();
ASSERT_TRUE(magic_boost_enabled)
<< "This *test* code does not support Lacros. See MaybeEnableMagicBoost.";
TEST_F(QuickAnswersStateWithMagicBoostTest, IsIntentEligibleUnderMagicBoost) {
chromeos::test::FakeMagicBoostState magic_boost_state;
FakeQuickAnswersState quick_answers_state;

@ -9,10 +9,10 @@
#include "chromeos/components/chromeos_components_test_suite.h"
#include "mojo/core/embedder/embedder.h"
#if BUILDFLAG(IS_CHROMEOS_DEVICE)
#error This test target only builds with linux-chromeos, not for real ChromeOS\
devices. See comment in build/config/chromeos/args.gni.
#endif
static_assert(
!BUILDFLAG(IS_CHROMEOS_DEVICE),
"This test target only builds with linux-chromeos, not for real ChromeOS "
"devices. See comment in build/config/chromeos/args.gni.");
int main(int argc, char** argv) {
// Some unit tests make Mojo calls.

@ -13,7 +13,6 @@ component("sensors") {
]
deps = [
"//base",
"//build:chromeos_buildflags",
"//chromeos/components/sensors/mojom",
"//mojo/public/cpp/bindings",
]

@ -4,46 +4,20 @@
#include "chromeos/components/sensors/sensor_util.h"
#include "build/chromeos_buildflags.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/components/sensors/ash/sensor_hal_dispatcher.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/lacros/lacros_service.h"
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
namespace chromeos {
namespace sensors {
bool BindSensorHalClient(mojo::PendingRemote<mojom::SensorHalClient> remote) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
auto* dispatcher = SensorHalDispatcher::GetInstance();
if (!dispatcher) {
// In some unit tests, it's not initialized.
// In some unit tests it's not initialized.
return false;
}
dispatcher->RegisterClient(std::move(remote));
return true;
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
auto* lacros_service = chromeos::LacrosService::Get();
if (!lacros_service) {
// In unit tests.
return false;
}
if (!lacros_service
->IsSupported<chromeos::sensors::mojom::SensorHalClient>()) {
return false;
}
lacros_service->BindSensorHalClient(std::move(remote));
return true;
#else
#error "This file should only be used in either Ash-Chrome or Lacros-Chrome"
#endif
}
} // namespace sensors

@ -20,7 +20,6 @@ component("constants") {
]
deps = [
"//base",
"//build:chromeos_buildflags",
"//chromeos/components/libsegmentation:buildflags",
]
if (is_chromeos_lacros) {
@ -37,7 +36,6 @@ source_set("unit_tests") {
deps = [
":constants",
"//base/test:test_support",
"//build:chromeos_buildflags",
"//chromeos/crosapi/mojom",
"//testing/gtest",
]

@ -8,10 +8,6 @@
#include "base/metrics/field_trial_params.h"
#include "chromeos_features.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/startup/browser_params_proxy.h"
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
namespace chromeos::features {
// Adds Managed APN Policies support.
@ -130,7 +126,6 @@ BASE_FEATURE(kGeminiAppPreinstall,
"GeminiAppPreinstall",
base::FEATURE_ENABLED_BY_DEFAULT);
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Enables Kiosk Heartbeats to be sent via Encrypted Reporting Pipeline
BASE_FEATURE(kKioskHeartbeatsViaERP,
"KioskHeartbeatsViaERP",
@ -163,7 +158,6 @@ BASE_FEATURE(kMahiSendingUrl,
// Controls whether to enable Mahi for managed users.
BASE_FEATURE(kMahiManaged, "MahiManaged", base::FEATURE_ENABLED_BY_DEFAULT);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Controls enabling / disabling the mahi debugging.
BASE_FEATURE(kMahiDebugging,
@ -373,11 +367,7 @@ bool IsBluetoothWifiQSPodRefreshEnabled() {
}
bool IsCloudGamingDeviceEnabled() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()->IsCloudGamingDevice();
#else
return base::FeatureList::IsEnabled(kCloudGamingDevice);
#endif
}
bool IsAlmanacLauncherPayloadEnabled() {
@ -410,11 +400,7 @@ bool IsDataMigrationEnabled() {
}
bool IsDeskProfilesEnabled() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()->IsDeskProfilesEnabled();
#else
return base::FeatureList::IsEnabled(kDeskProfiles);
#endif
}
bool IsEssentialSearchEnabled() {
@ -422,12 +408,7 @@ bool IsEssentialSearchEnabled() {
}
bool IsFileSystemProviderCloudFileSystemEnabled() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()
->IsFileSystemProviderCloudFileSystemEnabled();
#else
return base::FeatureList::IsEnabled(kFileSystemProviderCloudFileSystem);
#endif
}
bool IsFileSystemProviderContentCacheEnabled() {
@ -436,12 +417,7 @@ bool IsFileSystemProviderContentCacheEnabled() {
if (!IsFileSystemProviderCloudFileSystemEnabled()) {
return false;
}
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()
->IsFileSystemProviderContentCacheEnabled();
#else
return base::FeatureList::IsEnabled(kFileSystemProviderContentCache);
#endif
}
bool IsGeminiAppPreinstallFeatureManagementEnabled() {
@ -453,37 +429,21 @@ bool IsGeminiAppPreinstallEnabled() {
}
bool IsMagicBoostRevampEnabled() {
#if BUILDFLAG(IS_CHROMEOS)
return base::FeatureList::IsEnabled(kMagicBoostRevamp);
#else
return false;
#endif
}
bool IsMahiEnabled() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()->IsMahiEnabled();
#else
return base::FeatureList::IsEnabled(kMahi) &&
base::FeatureList::IsEnabled(kFeatureManagementMahi);
#endif
}
// Mahi requests are composed & sent from ash.
bool IsMahiSendingUrl() {
#if BUILDFLAG(IS_CHROMEOS_ASH)
return base::FeatureList::IsEnabled(kMahiSendingUrl);
#else
return false;
#endif
}
bool IsMahiManagedEnabled() {
#if BUILDFLAG(IS_CHROMEOS_ASH)
return base::FeatureList::IsEnabled(kMahiManaged);
#else
return false;
#endif
}
bool IsMahiDebuggingEnabled() {
@ -511,40 +471,23 @@ bool IsOfficeNavigationCapturingReimplEnabled() {
}
bool IsOrcaEnabled() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()->IsOrcaEnabled();
#else
return base::FeatureList::IsEnabled(chromeos::features::kOrcaDogfood) ||
(base::FeatureList::IsEnabled(chromeos::features::kOrca) &&
base::FeatureList::IsEnabled(kFeatureManagementOrca));
#endif
}
bool IsOrcaUseL10nStringsEnabled() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()->IsOrcaUseL10nStringsEnabled();
#else
return base::FeatureList::IsEnabled(chromeos::features::kOrcaUseL10nStrings);
#endif
}
bool IsOrcaInternationalizeEnabled() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()->IsOrcaInternationalizeEnabled();
#else
return base::FeatureList::IsEnabled(
chromeos::features::kOrcaInternationalize);
#endif
}
bool ShouldDisableChromeComposeOnChromeOS() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()
->ShouldDisableChromeComposeOnChromeOS();
#else
return base::FeatureList::IsEnabled(kFeatureManagementDisableChromeCompose) ||
IsOrcaEnabled();
#endif
}
bool IsQuickAnswersMaterialNextUIEnabled() {
@ -564,21 +507,12 @@ bool IsQuickAnswersV2SettingsSubToggleEnabled() {
}
bool IsUploadOfficeToCloudEnabled() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
return chromeos::BrowserParamsProxy::Get()->IsUploadOfficeToCloudEnabled();
#else
return base::FeatureList::IsEnabled(kUploadOfficeToCloud);
#endif
}
bool IsUploadOfficeToCloudForEnterpriseEnabled() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// TODO(b/296282654): Implement propagation if necessary.
return false;
#else
return base::FeatureList::IsEnabled(kUploadOfficeToCloud) &&
base::FeatureList::IsEnabled(kUploadOfficeToCloudForEnterprise);
#endif
}
bool IsUploadOfficeToCloudSyncEnabled() {

@ -11,11 +11,7 @@
#include "base/metrics/field_trial_params.h"
#include "build/buildflag.h"
// This file is only for the feature flags that are shared between ash-chrome
// and lacros-chrome that are not common. For ash features, please add them
// in //ash/constants/ash_features.h.
namespace chromeos {
namespace features {
// All features in alphabetical order. The features should be documented
@ -56,7 +52,6 @@ BASE_DECLARE_FEATURE(kEnablePkcs12ToChapsDualWrite);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kEssentialSearch);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
BASE_DECLARE_FEATURE(kGeminiAppPreinstall);
#if BUILDFLAG(IS_CHROMEOS_ASH)
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
BASE_DECLARE_FEATURE(kKioskHeartbeatsViaERP);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kMahi);
@ -68,10 +63,7 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kMahiManaged);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kPompano);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
BASE_DECLARE_FEATURE(kMahiSummarizeSelected);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_CHROMEOS)
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kMagicBoostRevamp);
#endif // BUILDFLAG(IS_CHROMEOS)
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kMahiDebugging);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kOrca);
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) BASE_DECLARE_FEATURE(kOrcaDogfood);
@ -201,6 +193,7 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
bool IsFeatureManagementHistoryEmbeddingEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
bool AreOverviewSessionInitOptimizationsEnabled();
} // namespace features
} // namespace chromeos

@ -12,7 +12,6 @@
#include "base/component_export.h"
#include "base/time/time.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
// This file is only for command-line switches that are shared between
// ash-chrome and lacros-chrome. For ash command-line switches, please add them

@ -4,30 +4,18 @@
#include "chromeos/constants/devicetype.h"
#include "base/logging.h"
#include "build/chromeos_buildflags.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/command_line.h"
#include "base/logging.h"
#include "base/system/sys_info.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/crosapi/mojom/crosapi.mojom.h" // nogncheck
#include "chromeos/startup/browser_params_proxy.h"
#endif
namespace chromeos {
namespace {
#if BUILDFLAG(IS_CHROMEOS_ASH)
constexpr char kDeviceTypeKey[] = "DEVICETYPE";
constexpr char kFormFactor[] = "form-factor";
#endif
} // namespace
DeviceType GetDeviceType() {
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::string value;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kFormFactor)) {
@ -53,24 +41,6 @@ DeviceType GetDeviceType() {
}
LOG(ERROR) << "Unknown device type \"" << value << "\"";
return DeviceType::kUnknown;
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
auto device_type = BrowserParamsProxy::Get()->DeviceType();
switch (device_type) {
case crosapi::mojom::BrowserInitParams::DeviceType::kChromebook:
return chromeos::DeviceType::kChromebook;
case crosapi::mojom::BrowserInitParams::DeviceType::kChromebase:
return chromeos::DeviceType::kChromebase;
case crosapi::mojom::BrowserInitParams::DeviceType::kChromebit:
return chromeos::DeviceType::kChromebit;
case crosapi::mojom::BrowserInitParams::DeviceType::kChromebox:
return chromeos::DeviceType::kChromebox;
case crosapi::mojom::BrowserInitParams::DeviceType::kUnknown:
[[fallthrough]];
default:
return chromeos::DeviceType::kUnknown;
}
#endif
}
} // namespace chromeos

@ -6,19 +6,10 @@
#include "base/command_line.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/crosapi/mojom/crosapi.mojom.h"
#include "chromeos/lacros/lacros_test_helper.h"
#include "chromeos/startup/browser_init_params.h"
#endif
namespace chromeos {
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST(DeviceTypeTest, GetDeviceTypeAsh) {
auto* command_line = base::CommandLine::ForCurrentProcess();
{
@ -62,53 +53,5 @@ TEST(DeviceTypeTest, GetDeviceTypeAsh) {
EXPECT_EQ(chromeos::GetDeviceType(), chromeos::DeviceType::kUnknown);
}
}
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
TEST(DeviceTypeTest, GetDeviceTypeLacros) {
base::test::TaskEnvironment task_environment;
{
auto params = crosapi::mojom::BrowserInitParams::New();
params->device_type =
crosapi::mojom::BrowserInitParams::DeviceType::kChromebook;
chromeos::BrowserInitParams::SetInitParamsForTests(std::move(params));
EXPECT_EQ(GetDeviceType(), chromeos::DeviceType::kChromebook);
}
{
auto params = crosapi::mojom::BrowserInitParams::New();
params->device_type =
crosapi::mojom::BrowserInitParams::DeviceType::kChromebase;
chromeos::BrowserInitParams::SetInitParamsForTests(std::move(params));
EXPECT_EQ(GetDeviceType(), chromeos::DeviceType::kChromebase);
}
{
auto params = crosapi::mojom::BrowserInitParams::New();
params->device_type =
crosapi::mojom::BrowserInitParams::DeviceType::kChromebit;
chromeos::BrowserInitParams::SetInitParamsForTests(std::move(params));
EXPECT_EQ(GetDeviceType(), chromeos::DeviceType::kChromebit);
}
{
auto params = crosapi::mojom::BrowserInitParams::New();
params->device_type =
crosapi::mojom::BrowserInitParams::DeviceType::kChromebox;
chromeos::BrowserInitParams::SetInitParamsForTests(std::move(params));
EXPECT_EQ(GetDeviceType(), chromeos::DeviceType::kChromebox);
}
{
auto params = crosapi::mojom::BrowserInitParams::New();
params->device_type =
crosapi::mojom::BrowserInitParams::DeviceType::kUnknown;
chromeos::BrowserInitParams::SetInitParamsForTests(std::move(params));
EXPECT_EQ(GetDeviceType(), chromeos::DeviceType::kUnknown);
}
{
// When device_type is not set, GetDeviceType() should return kUnknown.
auto params = crosapi::mojom::BrowserInitParams::New();
chromeos::BrowserInitParams::SetInitParamsForTests(std::move(params));
EXPECT_EQ(GetDeviceType(), chromeos::DeviceType::kUnknown);
}
}
#endif
} // namespace chromeos

@ -407,11 +407,9 @@ class MissiveClientImpl : public MissiveClient {
*request_.mutable_record() = std::move(record);
request_.set_priority(priority);
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Turn on/off the debug state flag (for Ash only).
// Turn on/off the debug state flag.
request_.set_health_data_logging_enabled(
::reporting::HistoryTracker::Get()->debug_state());
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
bool WriteRequest(dbus::MessageWriter* writer) override {
@ -425,13 +423,11 @@ class MissiveClientImpl : public MissiveClient {
"Response was not parsable.");
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Accept health data if present (ChromeOS only)
// Accept health data if present.
if (response_body.has_health_data()) {
::reporting::HistoryTracker::Get()->set_data(
std::move(response_body.health_data()), base::DoNothing());
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
reporting::Status status;
status.RestoreFrom(response_body.status());
@ -453,11 +449,9 @@ class MissiveClientImpl : public MissiveClient {
std::move(completion_callback)) {
request_.set_priority(priority);
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Turn on/off the debug state flag (for Ash only).
// Turn on/off the debug state flag.
request_.set_health_data_logging_enabled(
::reporting::HistoryTracker::Get()->debug_state());
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
bool WriteRequest(dbus::MessageWriter* writer) override {
@ -471,13 +465,11 @@ class MissiveClientImpl : public MissiveClient {
"Response was not parsable.");
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Accept health data if present (ChromeOS only)
// Accept health data if present.
if (response_body.has_health_data()) {
::reporting::HistoryTracker::Get()->set_data(
std::move(response_body.health_data()), base::DoNothing());
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
reporting::Status status;
status.RestoreFrom(response_body.status());
@ -538,11 +530,9 @@ class MissiveClientImpl : public MissiveClient {
*request_.mutable_sequence_information() = sequence_information;
request_.set_force_confirm(force_confirm);
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Turn on/off the debug state flag (for Ash only).
// Turn on/off the debug state flag.
request_.set_health_data_logging_enabled(
::reporting::HistoryTracker::Get()->debug_state());
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
bool WriteRequest(dbus::MessageWriter* writer) override {
@ -556,13 +546,11 @@ class MissiveClientImpl : public MissiveClient {
"Response was not parsable.");
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Accept health data if present (ChromeOS only)
// Accept health data if present.
if (response_body.has_health_data()) {
::reporting::HistoryTracker::Get()->set_data(
std::move(response_body.health_data()), base::DoNothing());
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
reporting::Status status;
status.RestoreFrom(response_body.status());

@ -5,31 +5,20 @@
#include "base/functional/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "build/chromeos_buildflags.h"
#include "chromeos/ash/components/test/ash_test_suite.h"
#include "mojo/core/embedder/embedder.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/test/ash_test_suite.h"
#else
#include "base/test/test_suite.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_CHROMEOS_DEVICE)
#error This test target only builds with linux-chromeos, not for real ChromeOS\
devices. See comment in build/config/chromeos/args.gni.
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
using TestSuite = ash::AshTestSuite;
#else
using TestSuite = base::TestSuite;
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
static_assert(
!BUILDFLAG(IS_CHROMEOS_DEVICE),
"This test target only builds with linux-chromeos, not for real ChromeOS "
"devices. See comment in build/config/chromeos/args.gni.");
int main(int argc, char** argv) {
// Some unit tests make Mojo calls.
mojo::core::Init();
TestSuite test_suite(argc, argv);
ash::AshTestSuite test_suite(argc, argv);
return base::LaunchUnitTests(
argc, argv,
base::BindOnce(&TestSuite::Run, base::Unretained(&test_suite)));
base::BindOnce(&ash::AshTestSuite::Run, base::Unretained(&test_suite)));
}

@ -54,15 +54,8 @@ void TileRoundRect(gfx::Canvas* canvas,
// For now, we should only apply dynamic color to the default frame header if
// the window is a system web app.
bool ShouldApplyDynamicColor(aura::Window* window) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
return window->GetProperty(chromeos::kAppTypeKey) ==
chromeos::AppType::SYSTEM_APP;
#else
// Default frame is used for non-browser frames in Lacros. In Lacros, we
// never need dynamic colors as we don't display SWAs. This will need to be
// redesigned if SWAs run in Lacros.
return false;
#endif
}
} // namespace
@ -118,9 +111,7 @@ void DefaultFrameHeader::UpdateFrameColors() {
if (updated) {
StartTransitionAnimation(kDefaultFrameColorChangeAnimationDuration);
#if BUILDFLAG(IS_CHROMEOS_ASH)
frame_color_metrics_helper_->UpdateFrameColorChangesCount();
#endif
}
if (ShouldApplyDynamicColor(GetTargetWindow())) {
@ -194,12 +185,10 @@ SkColor DefaultFrameHeader::GetCurrentFrameColor() const {
}
void DefaultFrameHeader::InitializeFrameColorMetricsHelper() {
#if BUILDFLAG(IS_CHROMEOS_ASH)
aura::Window* window = GetTargetWindow();
CHECK(window);
frame_color_metrics_helper_ = std::make_unique<FrameColorMetricsHelper>(
window->GetProperty(chromeos::kAppTypeKey));
#endif
}
} // namespace chromeos

@ -68,9 +68,7 @@ class COMPONENT_EXPORT(CHROMEOS_UI_FRAME) DefaultFrameHeader
int width_in_pixels_ = -1;
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<FrameColorMetricsHelper> frame_color_metrics_helper_;
#endif
};
} // namespace chromeos

@ -28,10 +28,6 @@
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "ui/platform_window/extensions/wayland_extension.h"
#endif
DEFINE_UI_CLASS_PROPERTY_TYPE(chromeos::ImmersiveFullscreenController*)
namespace chromeos {

@ -4,12 +4,16 @@
#include "chromeos/ui/frame/multitask_menu/multitask_menu_nudge_controller.h"
#include "ash/constants/ash_pref_names.h"
#include "ash/constants/ash_switches.h"
#include "ash/constants/notifier_catalogs.h"
#include "base/command_line.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "chromeos/ui/base/nudge_util.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/user_manager/user_manager.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
@ -24,13 +28,6 @@
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/widget/widget.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_pref_names.h"
#include "ash/constants/ash_switches.h"
#include "base/command_line.h"
#include "components/user_manager/user_manager.h"
#endif
namespace chromeos {
namespace {
@ -75,11 +72,6 @@ std::unique_ptr<views::Widget> CreateWidget(aura::Window* window) {
params.name = "MultitaskNudgeWidget";
params.accept_events = false;
params.parent = window->parent();
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// This widget must not set `use_accelerated_widget_override` b/c this
// widget's window will be reparented to `window`.
params.use_accelerated_widget_override = false;
#endif
auto widget = std::make_unique<views::Widget>(std::move(params));
const int message_id = display::Screen::GetScreen()->InTabletMode()
@ -128,16 +120,12 @@ MultitaskMenuNudgeController::Delegate::Delegate() {
}
bool MultitaskMenuNudgeController::Delegate::IsUserNewOrGuest() const {
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (!user_manager::UserManager::IsInitialized()) {
return false;
}
return user_manager::UserManager::Get()->IsCurrentUserNew() ||
user_manager::UserManager::Get()->IsLoggedInAsGuest();
#else
return false;
#endif
}
MultitaskMenuNudgeController::MultitaskMenuNudgeController() = default;
@ -146,7 +134,6 @@ MultitaskMenuNudgeController::~MultitaskMenuNudgeController() {
DismissNudge();
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
// static
void MultitaskMenuNudgeController::RegisterProfilePrefs(
PrefRegistrySimple* registry) {
@ -159,7 +146,6 @@ void MultitaskMenuNudgeController::RegisterProfilePrefs(
registry->RegisterTimePref(ash::prefs::kMultitaskMenuNudgeTabletLastShown,
base::Time());
}
#endif
void MultitaskMenuNudgeController::MaybeShowNudge(aura::Window* window) {
MaybeShowNudge(window, /*anchor_view=*/nullptr);
@ -176,12 +162,10 @@ void MultitaskMenuNudgeController::MaybeShowNudge(aura::Window* window,
return;
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
ash::switches::kAshNoNudges)) {
return;
}
#endif
// If the window is not visible, do not show the nudge.
if (!window->IsVisible()) {
@ -501,18 +485,11 @@ void MultitaskMenuNudgeController::UpdateWidgetAndPulse() {
anchor_bounds_in_screen.CenterPoint().x() - size.width() / 2,
anchor_bounds_in_screen.bottom() + kNudgeDistanceFromAnchor, size.width(),
size.height());
bool adjust_to_fit = false;
const display::Display display =
display::Screen::GetScreen()->GetDisplayNearestView(window_);
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// Lacros always needs adjustment since the child cannot go outside the
// parents bounds currently. See https://crbug.com/1416919.
adjust_to_fit = true;
#elif BUILDFLAG(IS_CHROMEOS_ASH)
// If the nudge is going to be offscreen, make sure it is within the window
// bounds.
adjust_to_fit = !display.work_area().Contains(bounds_in_screen);
#endif
bool adjust_to_fit = !display.work_area().Contains(bounds_in_screen);
if (adjust_to_fit) {
// The nudge should be within the window bounds.
bounds_in_screen.AdjustToFit(window_->GetBoundsInScreen());

@ -75,9 +75,7 @@ class COMPONENT_EXPORT(CHROMEOS_UI_FRAME) MultitaskMenuNudgeController
delete;
~MultitaskMenuNudgeController() override;
#if BUILDFLAG(IS_CHROMEOS_ASH)
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
#endif
// Attempts to show the nudge. Reads preferences and then calls
// `OnGetPreferences()`.

@ -27,7 +27,6 @@ source_set("wm") {
deps = [
"//base",
"//build:chromeos_buildflags",
"//chromeos/ui/base",
"//components/prefs",
"//components/url_matcher",

@ -72,7 +72,6 @@ std::vector<std::string> PrintWindowHierarchy(
bool scrub_data,
std::ostringstream* out,
GetChildrenCallback children_callback) {
#if !BUILDFLAG(IS_CHROMEOS_LACROS)
// TODO(crbug.com/41496823): Make ActiveClient and FocusClient return the same
// window across all instances of the clients on Lacros.
aura::Window* root0 = roots[0];
@ -82,20 +81,11 @@ std::vector<std::string> PrintWindowHierarchy(
aura::client::GetFocusClient(root0)->GetFocusedWindow();
aura::Window* capture_window =
aura::client::GetCaptureClient(root0)->GetCaptureWindow();
#endif
std::vector<std::string> window_titles;
for (size_t i = 0; i < roots.size(); ++i) {
*out << "RootWindow " << i << ":\n";
aura::Window* root = roots[i];
#if BUILDFLAG(IS_CHROMEOS_LACROS)
aura::Window* active_window =
::wm::GetActivationClient(root)->GetActiveWindow();
aura::Window* focused_window =
aura::client::GetFocusClient(root)->GetFocusedWindow();
aura::Window* capture_window =
aura::client::GetCaptureClient(root)->GetCaptureWindow();
#else
// These windows must be the same across root windows.
DCHECK_EQ(active_window,
::wm::GetActivationClient(root)->GetActiveWindow());
@ -103,7 +93,6 @@ std::vector<std::string> PrintWindowHierarchy(
aura::client::GetFocusClient(root)->GetFocusedWindow());
DCHECK_EQ(capture_window,
aura::client::GetCaptureClient(root)->GetCaptureWindow());
#endif
PrintWindowHierarchy(active_window, focused_window, capture_window, root, 0,
scrub_data, children_callback, &window_titles, out);

@ -9,7 +9,6 @@
#include "base/component_export.h"
#include "base/functional/callback.h"
#include "build/chromeos_buildflags.h"
namespace aura {
class Window;

@ -99,14 +99,10 @@ gfx::Size GetFloatedWindowTabletSize(aura::Window* window) {
// floatable window to not be floatable anymore.
// TODO(b/278769645): Remove this workaround once browser returns a viable
// minimum size.
#if BUILDFLAG(IS_CHROMEOS_LACROS)
const int minimum_width_padding = kBrowserExtraPaddingDp;
#else
const int minimum_width_padding =
window->GetProperty(chromeos::kAppTypeKey) == chromeos::AppType::BROWSER
? kBrowserExtraPaddingDp
: 0;
#endif
// If the preferred width is less than the minimum width, use the minimum
// width. Add padding to the preferred width if the window is a browser, but
@ -118,9 +114,6 @@ gfx::Size GetFloatedWindowTabletSize(aura::Window* window) {
}
bool CanFloatWindow(aura::Window* window) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Only app window can be floated. All windows on lacros side are expected to
// be lacros, so this check is not needed.
if (window->GetProperty(chromeos::kAppTypeKey) ==
chromeos::AppType::NON_APP) {
return false;
@ -140,7 +133,6 @@ bool CanFloatWindow(aura::Window* window) {
state_type == chromeos::WindowStateType::kMaximized)) {
return false;
}
#endif
if (window->GetProperty(aura::client::kZOrderingKey) !=
ui::ZOrderLevel::kNormal) {