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() { ...@@ -479,8 +479,6 @@ void CrostiniRegistryService::RecordStartupMetrics() {
if (!IsCrostiniEnabled(profile_)) if (!IsCrostiniEnabled(profile_))
return; return;
if (!IsCrostiniUIAllowedForProfile(profile_))
return;
size_t num_apps = 0; size_t num_apps = 0;
......
...@@ -228,7 +228,8 @@ bool IsCrostiniUIAllowedForProfile(Profile* profile) { ...@@ -228,7 +228,8 @@ bool IsCrostiniUIAllowedForProfile(Profile* profile) {
} }
bool IsCrostiniEnabled(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) { bool IsCrostiniRunning(Profile* profile) {
......
...@@ -644,17 +644,10 @@ void FileManagerPrivateConfigureVolumeFunction::OnCompleted( ...@@ -644,17 +644,10 @@ void FileManagerPrivateConfigureVolumeFunction::OnCompleted(
Respond(NoArguments()); Respond(NoArguments());
} }
namespace {
bool IsCrostiniEnabledForProfile(Profile* profile) {
return IsCrostiniUIAllowedForProfile(profile) && IsCrostiniEnabled(profile);
}
} // namespace
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
FileManagerPrivateIsCrostiniEnabledFunction::Run() { FileManagerPrivateIsCrostiniEnabledFunction::Run() {
return RespondNow( return RespondNow(OneArgument(std::make_unique<base::Value>(
OneArgument(std::make_unique<base::Value>(IsCrostiniEnabledForProfile( IsCrostiniEnabled(Profile::FromBrowserContext(browser_context())))));
Profile::FromBrowserContext(browser_context())))));
} }
FileManagerPrivateMountCrostiniContainerFunction:: FileManagerPrivateMountCrostiniContainerFunction::
...@@ -665,7 +658,7 @@ FileManagerPrivateMountCrostiniContainerFunction:: ...@@ -665,7 +658,7 @@ FileManagerPrivateMountCrostiniContainerFunction::
bool FileManagerPrivateMountCrostiniContainerFunction::RunAsync() { bool FileManagerPrivateMountCrostiniContainerFunction::RunAsync() {
Profile* profile = Profile::FromBrowserContext(browser_context()); Profile* profile = Profile::FromBrowserContext(browser_context());
DCHECK(IsCrostiniEnabledForProfile(profile)); DCHECK(IsCrostiniEnabled(profile));
crostini::CrostiniManager::GetInstance()->RestartCrostini( crostini::CrostiniManager::GetInstance()->RestartCrostini(
profile, kCrostiniDefaultVmName, kCrostiniDefaultContainerName, profile, kCrostiniDefaultVmName, kCrostiniDefaultContainerName,
base::BindOnce( base::BindOnce(
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "chrome/browser/ui/app_list/crostini/crostini_app_model_builder.h" #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.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h" #include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
#include "chrome/browser/chromeos/crostini/crostini_test_helper.h" #include "chrome/browser/chromeos/crostini/crostini_test_helper.h"
...@@ -84,8 +83,6 @@ class CrostiniAppModelBuilderTest : public AppListTestBase { ...@@ -84,8 +83,6 @@ class CrostiniAppModelBuilderTest : public AppListTestBase {
~CrostiniAppModelBuilderTest() override {} ~CrostiniAppModelBuilderTest() override {}
void SetUp() override { void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(
features::kExperimentalCrostiniUI);
AppListTestBase::SetUp(); AppListTestBase::SetUp();
CreateBuilder(); CreateBuilder();
} }
...@@ -118,14 +115,14 @@ class CrostiniAppModelBuilderTest : public AppListTestBase { ...@@ -118,14 +115,14 @@ class CrostiniAppModelBuilderTest : public AppListTestBase {
std::unique_ptr<CrostiniAppModelBuilder> builder_; std::unique_ptr<CrostiniAppModelBuilder> builder_;
private: private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(CrostiniAppModelBuilderTest); DISALLOW_COPY_AND_ASSIGN(CrostiniAppModelBuilderTest);
}; };
// Test that the Terminal app is only shown when Crostini is enabled // Test that the Terminal app is only shown when Crostini is enabled
TEST_F(CrostiniAppModelBuilderTest, EnableCrostini) { TEST_F(CrostiniAppModelBuilderTest, EnableCrostini) {
SetCrostiniUIAllowedForTesting(true);
EXPECT_EQ(0u, model_updater_->ItemCount()); EXPECT_EQ(0u, model_updater_->ItemCount());
CrostiniTestHelper::EnableCrostini(profile()); CrostiniTestHelper::EnableCrostini(profile());
// Root folder + terminal app. // Root folder + terminal app.
EXPECT_THAT( EXPECT_THAT(
...@@ -134,6 +131,7 @@ TEST_F(CrostiniAppModelBuilderTest, EnableCrostini) { ...@@ -134,6 +131,7 @@ TEST_F(CrostiniAppModelBuilderTest, EnableCrostini) {
EXPECT_THAT(GetAppNames(model_updater_.get()), EXPECT_THAT(GetAppNames(model_updater_.get()),
testing::UnorderedElementsAre( testing::UnorderedElementsAre(
kRootFolderName, GetFullName(kCrostiniTerminalAppName))); kRootFolderName, GetFullName(kCrostiniTerminalAppName)));
SetCrostiniUIAllowedForTesting(false);
} }
TEST_F(CrostiniAppModelBuilderTest, AppInstallation) { 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