Commit 92590411 authored by Nicholas Verne's avatar Nicholas Verne Committed by Commit Bot

Crostini enabled only if allowed.

If Crostini is disabled by policy, IsCrostiniEnabled will now return false.

Bug: None
Change-Id: I4eb93223c7b3f65280e171f04895a8942186af51
Reviewed-on: https://chromium-review.googlesource.com/1152641Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578976}
parent b4e92b23
......@@ -479,8 +479,6 @@ void CrostiniRegistryService::RecordStartupMetrics() {
if (!IsCrostiniEnabled(profile_))
return;
if (!IsCrostiniUIAllowedForProfile(profile_))
return;
size_t num_apps = 0;
......
......@@ -228,7 +228,8 @@ bool IsCrostiniUIAllowedForProfile(Profile* profile) {
}
bool IsCrostiniEnabled(Profile* profile) {
return profile->GetPrefs()->GetBoolean(crostini::prefs::kCrostiniEnabled);
return IsCrostiniUIAllowedForProfile(profile) &&
profile->GetPrefs()->GetBoolean(crostini::prefs::kCrostiniEnabled);
}
bool IsCrostiniRunning(Profile* profile) {
......
......@@ -644,17 +644,10 @@ void FileManagerPrivateConfigureVolumeFunction::OnCompleted(
Respond(NoArguments());
}
namespace {
bool IsCrostiniEnabledForProfile(Profile* profile) {
return IsCrostiniUIAllowedForProfile(profile) && IsCrostiniEnabled(profile);
}
} // namespace
ExtensionFunction::ResponseAction
FileManagerPrivateIsCrostiniEnabledFunction::Run() {
return RespondNow(
OneArgument(std::make_unique<base::Value>(IsCrostiniEnabledForProfile(
Profile::FromBrowserContext(browser_context())))));
return RespondNow(OneArgument(std::make_unique<base::Value>(
IsCrostiniEnabled(Profile::FromBrowserContext(browser_context())))));
}
FileManagerPrivateMountCrostiniContainerFunction::
......@@ -665,7 +658,7 @@ FileManagerPrivateMountCrostiniContainerFunction::
bool FileManagerPrivateMountCrostiniContainerFunction::RunAsync() {
Profile* profile = Profile::FromBrowserContext(browser_context());
DCHECK(IsCrostiniEnabledForProfile(profile));
DCHECK(IsCrostiniEnabled(profile));
crostini::CrostiniManager::GetInstance()->RestartCrostini(
profile, kCrostiniDefaultVmName, kCrostiniDefaultContainerName,
base::BindOnce(
......
......@@ -4,7 +4,6 @@
#include "chrome/browser/ui/app_list/crostini/crostini_app_model_builder.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
#include "chrome/browser/chromeos/crostini/crostini_test_helper.h"
......@@ -84,8 +83,6 @@ class CrostiniAppModelBuilderTest : public AppListTestBase {
~CrostiniAppModelBuilderTest() override {}
void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(
features::kExperimentalCrostiniUI);
AppListTestBase::SetUp();
CreateBuilder();
}
......@@ -118,14 +115,14 @@ class CrostiniAppModelBuilderTest : public AppListTestBase {
std::unique_ptr<CrostiniAppModelBuilder> builder_;
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(CrostiniAppModelBuilderTest);
};
// Test that the Terminal app is only shown when Crostini is enabled
TEST_F(CrostiniAppModelBuilderTest, EnableCrostini) {
SetCrostiniUIAllowedForTesting(true);
EXPECT_EQ(0u, model_updater_->ItemCount());
CrostiniTestHelper::EnableCrostini(profile());
// Root folder + terminal app.
EXPECT_THAT(
......@@ -134,6 +131,7 @@ TEST_F(CrostiniAppModelBuilderTest, EnableCrostini) {
EXPECT_THAT(GetAppNames(model_updater_.get()),
testing::UnorderedElementsAre(
kRootFolderName, GetFullName(kCrostiniTerminalAppName)));
SetCrostiniUIAllowedForTesting(false);
}
TEST_F(CrostiniAppModelBuilderTest, AppInstallation) {
......
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