Skip to content

Commit

Permalink
Migrate c/b/ash/login/demo_mode/ to namespace ash
Browse files Browse the repository at this point in the history
The migration of chromeos/browser/chromeos/login/demo_mode/ was finished
in https://crrev.com/c/2721996. This CL changes the namespace from
chromeos to ash. Compatibility code is added until the Chrome OS source
code migration is finished.

This CL is part of the Chrome OS source code directory migration:
https://docs.google.com/document/d/1g-98HpzA8XcoGBWUv1gQNr4rbnD5yfvbtYZyPDDbkaE.

Bug: 1164001
Change-Id: I3af2077c63b334960585ee31ce5e65b9c6fc2d47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2871728
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Owners-Override: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#881130}
  • Loading branch information
hferreiro authored and Chromium LUCI CQ committed May 10, 2021
1 parent 0cfae82 commit d71de90
Show file tree
Hide file tree
Showing 90 changed files with 400 additions and 256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ ExtensionFunction::ResponseAction ArcAppsPrivateLaunchAppFunction::Run() {
return RespondNow(Error("Launch failed"));
}

chromeos::DemoSession::RecordAppLaunchSourceIfInDemoMode(
chromeos::DemoSession::AppLaunchSource::kExtensionApi);
ash::DemoSession::RecordAppLaunchSourceIfInDemoMode(
ash::DemoSession::AppLaunchSource::kExtensionApi);

return RespondNow(NoArguments());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ IN_PROC_BROWSER_TEST_F(ArcAppsPrivateApiTest, OnInstalled) {
IN_PROC_BROWSER_TEST_F(ArcAppsPrivateApiTest,
NoDemoModeAppLaunchSourceReported) {
// Not in Demo mode
EXPECT_FALSE(chromeos::DemoSession::IsDeviceInDemoMode());
EXPECT_FALSE(ash::DemoSession::IsDeviceInDemoMode());

base::HistogramTester histogram_tester;

Expand All @@ -169,9 +169,9 @@ IN_PROC_BROWSER_TEST_F(ArcAppsPrivateApiTest,

IN_PROC_BROWSER_TEST_F(ArcAppsPrivateApiTest, DemoModeAppLaunchSourceReported) {
// Set Demo mode
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kOnline);
EXPECT_TRUE(chromeos::DemoSession::IsDeviceInDemoMode());
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kOnline);
EXPECT_TRUE(ash::DemoSession::IsDeviceInDemoMode());

base::HistogramTester histogram_tester;

Expand All @@ -192,5 +192,5 @@ IN_PROC_BROWSER_TEST_F(ArcAppsPrivateApiTest, DemoModeAppLaunchSourceReported) {
// Should see 1 app launched from the highlights app in the histogram.
histogram_tester.ExpectUniqueSample(
"DemoMode.AppLaunchSource",
chromeos::DemoSession::AppLaunchSource::kExtensionApi, 1);
ash::DemoSession::AppLaunchSource::kExtensionApi, 1);
}
9 changes: 4 additions & 5 deletions chrome/browser/ash/arc/arc_demo_mode_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ namespace arc {

void ArcDemoModeDelegateImpl::EnsureOfflineResourcesLoaded(
base::OnceClosure callback) {
if (!chromeos::DemoSession::IsDeviceInDemoMode()) {
if (!ash::DemoSession::IsDeviceInDemoMode()) {
std::move(callback).Run();
return;
}
chromeos::DemoSession::Get()->EnsureOfflineResourcesLoaded(
std::move(callback));
ash::DemoSession::Get()->EnsureOfflineResourcesLoaded(std::move(callback));
}

base::FilePath ArcDemoModeDelegateImpl::GetDemoAppsPath() {
if (!chromeos::DemoSession::IsDeviceInDemoMode())
if (!ash::DemoSession::IsDeviceInDemoMode())
return base::FilePath();
return chromeos::DemoSession::Get()->resources()->GetDemoAppsPath();
return ash::DemoSession::Get()->resources()->GetDemoAppsPath();
}

} // namespace arc
12 changes: 6 additions & 6 deletions chrome/browser/ash/arc/arc_demo_mode_delegate_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ class ArcDemoModeDelegateImplTest : public testing::Test {
delete;

protected:
chromeos::DemoModeTestHelper* demo_helper() { return &demo_helper_; }
ash::DemoModeTestHelper* demo_helper() { return &demo_helper_; }

ArcDemoModeDelegateImpl* delegate() { return &delegate_; }

private:
content::BrowserTaskEnvironment browser_task_environment_;
user_manager::ScopedUserManager user_manager_enabler_;
chromeos::DemoModeTestHelper demo_helper_;
ash::DemoModeTestHelper demo_helper_;
ArcDemoModeDelegateImpl delegate_;
};

// Test that EnsureOfflineResourcesLoaded returns immediately if demo mode is
// not enabled.
TEST_F(ArcDemoModeDelegateImplTest, EnsureOfflineResourcesLoaded_NotEnabled) {
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kNone);
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kNone);

bool was_called = false;
base::OnceClosure callback =
Expand All @@ -68,8 +68,8 @@ TEST_F(ArcDemoModeDelegateImplTest, EnsureOfflineResourcesLoaded_Enabled) {

// Test that GetDemoAppsPath returns empty path if demo mode is not enabled.
TEST_F(ArcDemoModeDelegateImplTest, GetDemoAppsPath_NotEnabled) {
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kNone);
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kNone);

base::FilePath demo_session_apps_path = delegate()->GetDemoAppsPath();
EXPECT_TRUE(demo_session_apps_path.empty());
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/ash/arc/arc_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ bool IsArcStatsReportingEnabled() {
}

bool IsArcDemoModeSetupFlow() {
return chromeos::DemoSetupController::IsOobeDemoSetupFlowInProgress();
return ash::DemoSetupController::IsOobeDemoSetupFlowInProgress();
}

void UpdateArcFileSystemCompatibilityPrefIfNeeded(
Expand Down Expand Up @@ -615,12 +615,12 @@ bool IsPlayStoreAvailable() {
return true;

// Demo Mode is the only public session scenario that can launch Play.
if (!chromeos::DemoSession::IsDeviceInDemoMode())
if (!ash::DemoSession::IsDeviceInDemoMode())
return false;

// TODO(b/154290639): Remove check for |IsDemoModeOfflineEnrolled| when fixed
// in Play Store.
return !chromeos::DemoSession::IsDemoModeOfflineEnrolled() &&
return !ash::DemoSession::IsDemoModeOfflineEnrolled() &&
chromeos::features::ShouldShowPlayStoreInDemoMode();
}

Expand Down Expand Up @@ -687,7 +687,7 @@ std::string GetHistogramNameByUserType(const std::string& base_name,
profile = ProfileManager::GetPrimaryUserProfile();
}
if (IsRobotOrOfflineDemoAccountMode()) {
chromeos::DemoSession* demo_session = chromeos::DemoSession::Get();
auto* demo_session = ash::DemoSession::Get();
if (demo_session && demo_session->started()) {
return demo_session->offline_enrolled() ? base_name + ".OfflineDemoMode"
: base_name + ".DemoMode";
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/ash/arc/arc_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,8 @@ TEST_F(ChromeArcUtilTest, ArcStartModeDefaultPublicSession) {
TEST_F(ChromeArcUtilTest, ArcStartModeDefaultDemoMode) {
auto* command_line = base::CommandLine::ForCurrentProcess();
command_line->InitFromArgv({"", "--arc-availability=installed"});
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kOnline);
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kOnline);
ScopedLogIn login(GetFakeUserManager(),
AccountId::FromUserEmail("public_user@gmail.com"),
user_manager::USER_TYPE_PUBLIC_ACCOUNT);
Expand All @@ -699,8 +699,8 @@ TEST_F(ChromeArcUtilTest, ArcStartModeDefaultDemoMode) {
TEST_F(ChromeArcUtilTest, ArcStartModeDefaultOfflineDemoMode) {
auto* command_line = base::CommandLine::ForCurrentProcess();
command_line->InitFromArgv({"", "--arc-availability=installed"});
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kOffline);
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kOffline);
ScopedLogIn login(GetFakeUserManager(),
AccountId::FromUserEmail("public_user@gmail.com"),
user_manager::USER_TYPE_PUBLIC_ACCOUNT);
Expand All @@ -713,8 +713,8 @@ TEST_F(ChromeArcUtilTest, ArcStartModeDefaultDemoModeWithoutPlayStore) {
false /* disabled */);
auto* command_line = base::CommandLine::ForCurrentProcess();
command_line->InitFromArgv({"", "--arc-availability=installed"});
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kOnline);
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kOnline);
ScopedLogIn login(GetFakeUserManager(),
AccountId::FromUserEmail("public_user@gmail.com"),
user_manager::USER_TYPE_PUBLIC_ACCOUNT);
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/ash/arc/auth/arc_auth_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mojom::ChromeAccountType GetAccountType(const Profile* profile) {
if (IsActiveDirectoryUserForProfile(profile))
return mojom::ChromeAccountType::ACTIVE_DIRECTORY_ACCOUNT;

chromeos::DemoSession* demo_session = chromeos::DemoSession::Get();
auto* demo_session = ash::DemoSession::Get();
if (demo_session && demo_session->started()) {
// Internally, demo mode is implemented as a public session, and should
// generally follow normal robot account provisioning flow. Offline enrolled
Expand Down Expand Up @@ -645,8 +645,7 @@ void ArcAuthService::OnPrimaryAccountAuthCodeFetched(
CreateAccountInfo(!IsArcOptInVerificationDisabled(), auth_code,
full_account_id, GetAccountType(profile_),
policy_util::IsAccountManaged(profile_)));
} else if (chromeos::DemoSession::Get() &&
chromeos::DemoSession::Get()->started()) {
} else if (ash::DemoSession::Get() && ash::DemoSession::Get()->started()) {
// For demo sessions, if auth code fetch failed (e.g. because the device is
// offline), fall back to accountless offline demo mode provisioning.
std::move(callback).Run(
Expand Down
24 changes: 12 additions & 12 deletions chrome/browser/ash/arc/auth/arc_auth_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ IN_PROC_BROWSER_TEST_F(ArcAuthServiceTest, GetPrimaryAccountForPublicAccounts) {

IN_PROC_BROWSER_TEST_F(ArcAuthServiceTest,
GetPrimaryAccountForOfflineDemoAccounts) {
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kOffline);
chromeos::DemoSession::StartIfInDemoMode();
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kOffline);
ash::DemoSession::StartIfInDemoMode();
SetAccountAndProfile(user_manager::USER_TYPE_PUBLIC_ACCOUNT);
const std::pair<std::string, mojom::ChromeAccountType>
primary_account = RequestPrimaryAccount();
Expand Down Expand Up @@ -843,9 +843,9 @@ class ArcRobotAccountAuthServiceTest : public ArcAuthServiceTest {
// Tests that when ARC requests account info for a demo session account,
// Chrome supplies the info configured in SetAccountAndProfile() above.
IN_PROC_BROWSER_TEST_F(ArcRobotAccountAuthServiceTest, GetDemoAccount) {
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kOnline);
chromeos::DemoSession::StartIfInDemoMode();
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kOnline);
ash::DemoSession::StartIfInDemoMode();

SetAccountAndProfile(user_manager::USER_TYPE_PUBLIC_ACCOUNT);

Expand All @@ -868,9 +868,9 @@ IN_PROC_BROWSER_TEST_F(ArcRobotAccountAuthServiceTest, GetDemoAccount) {
}

IN_PROC_BROWSER_TEST_F(ArcRobotAccountAuthServiceTest, GetOfflineDemoAccount) {
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kOffline);
chromeos::DemoSession::StartIfInDemoMode();
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kOffline);
ash::DemoSession::StartIfInDemoMode();

SetAccountAndProfile(user_manager::USER_TYPE_PUBLIC_ACCOUNT);

Expand All @@ -889,9 +889,9 @@ IN_PROC_BROWSER_TEST_F(ArcRobotAccountAuthServiceTest, GetOfflineDemoAccount) {

IN_PROC_BROWSER_TEST_F(ArcRobotAccountAuthServiceTest,
GetDemoAccountOnAuthTokenFetchFailure) {
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kOnline);
chromeos::DemoSession::StartIfInDemoMode();
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kOnline);
ash::DemoSession::StartIfInDemoMode();

SetAccountAndProfile(user_manager::USER_TYPE_PUBLIC_ACCOUNT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ void ArcProvisionNotificationService::OnArcPlayStoreEnabledChanged(
void ArcProvisionNotificationService::OnArcStarted() {
// Show notification only for Public Session (except for Demo Session) when
// ARC is going to start.
if (profiles::IsPublicSession() &&
!chromeos::DemoSession::IsDeviceInDemoMode()) {
if (profiles::IsPublicSession() && !ash::DemoSession::IsDeviceInDemoMode()) {
MaybeShowNotification();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ void ArcDemoModePreferenceHandler::OnPreferenceChanged() {
if (!IsArcVmEnabled())
return;

chromeos::DemoSession::DemoModeConfig config =
static_cast<chromeos::DemoSession::DemoModeConfig>(
pref_service_->GetInteger(prefs::kDemoModeConfig));
auto config = static_cast<ash::DemoSession::DemoModeConfig>(
pref_service_->GetInteger(prefs::kDemoModeConfig));
switch (config) {
case chromeos::DemoSession::DemoModeConfig::kNone:
case ash::DemoSession::DemoModeConfig::kNone:
return;
case chromeos::DemoSession::DemoModeConfig::kOnline:
case chromeos::DemoSession::DemoModeConfig::kOffline:
case ash::DemoSession::DemoModeConfig::kOnline:
case ash::DemoSession::DemoModeConfig::kOffline:
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ArcDemoModePreferenceHandlerTest;
// Observes Demo Mode preference and stops mini-ARCVM once, if running, via
// ArcSessionManager when the preference is enabled, which only happens after
// Demo Mode enrollment is complete (in
// chromeos::DemoSetupController::OnDeviceRegistered). ARCVM will automatically
// ash::DemoSetupController::OnDeviceRegistered). ARCVM will automatically
// start again once the Demo session starts. This is necessary because (1) the
// demo apps image must be present at ARCVM boot and (2) mini-ARCVM is started
// once the OOBE is visible, but before Demo Mode setup is completed. As a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ArcDemoModePreferenceHandlerTest : public testing::Test {
void SetUp() override {
pref_service_.registry()->RegisterIntegerPref(
prefs::kDemoModeConfig,
static_cast<int>(chromeos::DemoSession::DemoModeConfig::kNone));
static_cast<int>(ash::DemoSession::DemoModeConfig::kNone));
handler_ = base::WrapUnique<ArcDemoModePreferenceHandler>(
new ArcDemoModePreferenceHandler(
base::BindOnce(
Expand Down Expand Up @@ -62,7 +62,7 @@ TEST_F(ArcDemoModePreferenceHandlerTest, DemoPrefOnline) {

pref_service()->SetInteger(
prefs::kDemoModeConfig,
static_cast<int>(chromeos::DemoSession::DemoModeConfig::kOnline));
static_cast<int>(ash::DemoSession::DemoModeConfig::kOnline));

EXPECT_TRUE(handler_was_called());
}
Expand All @@ -72,7 +72,7 @@ TEST_F(ArcDemoModePreferenceHandlerTest, DemoPrefOnline_NoArcVm) {

pref_service()->SetInteger(
prefs::kDemoModeConfig,
static_cast<int>(chromeos::DemoSession::DemoModeConfig::kOnline));
static_cast<int>(ash::DemoSession::DemoModeConfig::kOnline));

EXPECT_FALSE(handler_was_called());
}
Expand All @@ -83,7 +83,7 @@ TEST_F(ArcDemoModePreferenceHandlerTest, DemoPrefOffline) {

pref_service()->SetInteger(
prefs::kDemoModeConfig,
static_cast<int>(chromeos::DemoSession::DemoModeConfig::kOffline));
static_cast<int>(ash::DemoSession::DemoModeConfig::kOffline));

EXPECT_TRUE(handler_was_called());
}
Expand All @@ -94,7 +94,7 @@ TEST_F(ArcDemoModePreferenceHandlerTest, DemoPrefNone) {

pref_service()->SetInteger(
prefs::kDemoModeConfig,
static_cast<int>(chromeos::DemoSession::DemoModeConfig::kNone));
static_cast<int>(ash::DemoSession::DemoModeConfig::kNone));

EXPECT_FALSE(handler_was_called());
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ash/arc/session/arc_session_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ bool ShouldUseErrorDialog() {
if (IsArcKioskMode())
return false;

if (chromeos::DemoSession::IsDeviceInDemoMode())
if (ash::DemoSession::IsDeviceInDemoMode())
return false;

return true;
Expand Down Expand Up @@ -1395,7 +1395,7 @@ void ArcSessionManager::StartArc() {

UpgradeParams params;

const chromeos::DemoSession* demo_session = chromeos::DemoSession::Get();
const auto* demo_session = ash::DemoSession::Get();
params.is_demo_session = demo_session && demo_session->started();
if (params.is_demo_session) {
DCHECK(demo_session->resources()->loaded());
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ash/assistant/assistant_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ AssistantAllowedState IsAssistantAllowedForProfile(const Profile* profile) {
if (profile->IsOffTheRecord())
return AssistantAllowedState::DISALLOWED_BY_INCOGNITO;

if (chromeos::DemoSession::IsDeviceInDemoMode())
if (ash::DemoSession::IsDeviceInDemoMode())
return AssistantAllowedState::DISALLOWED_BY_DEMO_MODE;

if (!IsAssistantAllowedForUserType(profile))
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/ash/assistant/assistant_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,16 @@ TEST_F(ChromeAssistantUtilTest, IsAssistantAllowedForProfile_Locale) {
}

TEST_F(ChromeAssistantUtilTest, IsAssistantAllowedForProfile_DemoMode) {
chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kOnline);
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kOnline);
ScopedLogIn login(GetFakeUserManager(), identity_test_env(),
GetNonGaiaUserAccountId(profile()),
user_manager::USER_TYPE_PUBLIC_ACCOUNT);
EXPECT_EQ(chromeos::assistant::AssistantAllowedState::DISALLOWED_BY_DEMO_MODE,
IsAssistantAllowedForProfile(profile()));

chromeos::DemoSession::SetDemoConfigForTesting(
chromeos::DemoSession::DemoModeConfig::kNone);
ash::DemoSession::SetDemoConfigForTesting(
ash::DemoSession::DemoModeConfig::kNone);
}

TEST_F(ChromeAssistantUtilTest, IsAssistantAllowedForProfile_PublicSession) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ class OobeConfigurationTest : public OobeBaseTest {
WizardController::default_controller()->demo_setup_controller();

// Simulate offline data directory.
ASSERT_TRUE(
chromeos::test::SetupDummyOfflinePolicyDir("test", &fake_policy_dir_));
ASSERT_TRUE(test::SetupDummyOfflinePolicyDir("test", &fake_policy_dir_));
controller->SetPreinstalledOfflineResourcesPathForTesting(
fake_policy_dir_.GetPath());
}
Expand Down

0 comments on commit d71de90

Please sign in to comment.