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

Disable Crostini for children.

Also legacy supervised profiles.

Bug: 853198
Change-Id: I8a42363f3f28476f4882605517eac9b1b3512200
Reviewed-on: https://chromium-review.googlesource.com/1103984
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569194}
parent e0588bf3
...@@ -121,10 +121,13 @@ void SetCrostiniUIAllowedForTesting(bool enabled) { ...@@ -121,10 +121,13 @@ void SetCrostiniUIAllowedForTesting(bool enabled) {
g_crostini_ui_allowed_for_testing = enabled; g_crostini_ui_allowed_for_testing = enabled;
} }
bool IsCrostiniAllowed() { bool IsCrostiniAllowedForProfile(Profile* profile) {
if (g_crostini_ui_allowed_for_testing) { if (g_crostini_ui_allowed_for_testing) {
return true; return true;
} }
if (profile && (profile->IsChild() || profile->IsLegacySupervised())) {
return false;
}
return virtual_machines::AreVirtualMachinesAllowedByVersionAndChannel() && return virtual_machines::AreVirtualMachinesAllowedByVersionAndChannel() &&
virtual_machines::AreVirtualMachinesAllowedByPolicy() && virtual_machines::AreVirtualMachinesAllowedByPolicy() &&
base::FeatureList::IsEnabled(features::kCrostini); base::FeatureList::IsEnabled(features::kCrostini);
...@@ -138,7 +141,7 @@ bool IsCrostiniUIAllowedForProfile(Profile* profile) { ...@@ -138,7 +141,7 @@ bool IsCrostiniUIAllowedForProfile(Profile* profile) {
return false; return false;
} }
return IsCrostiniAllowed() && return IsCrostiniAllowedForProfile(profile) &&
base::FeatureList::IsEnabled(features::kExperimentalCrostiniUI); base::FeatureList::IsEnabled(features::kExperimentalCrostiniUI);
} }
......
...@@ -19,12 +19,13 @@ class Profile; ...@@ -19,12 +19,13 @@ class Profile;
// behaviour and returning true instead. // behaviour and returning true instead.
void SetCrostiniUIAllowedForTesting(bool enabled); void SetCrostiniUIAllowedForTesting(bool enabled);
// Returns true if crostini is allowed to run. // Returns true if crostini is allowed to run for |profile|.
// Otherwise, returns false, e.g. if crostini is not available on the device, // Otherwise, returns false, e.g. if crostini is not available on the device,
// or it is in the flow to set up managed account creation. // or it is in the flow to set up managed account creation.
bool IsCrostiniAllowed(); bool IsCrostiniAllowedForProfile(Profile* profile);
// Returns true if crostini UI can be shown. Implies crostini is allowed to run. // Returns true if crostini UI can be shown. Implies crostini is allowed to
// run.
bool IsCrostiniUIAllowedForProfile(Profile* profile); bool IsCrostiniUIAllowedForProfile(Profile* profile);
// Returns whether if Crostini has been enabled, i.e. the user has launched it // Returns whether if Crostini has been enabled, i.e. the user has launched it
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
#include "chrome/browser/chromeos/dbus/finch_features_service_provider_delegate.h" #include "chrome/browser/chromeos/dbus/finch_features_service_provider_delegate.h"
#include "chrome/browser/chromeos/virtual_machines/virtual_machines_util.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
namespace chromeos { namespace chromeos {
...@@ -12,9 +15,17 @@ FinchFeaturesServiceProviderDelegate::FinchFeaturesServiceProviderDelegate() {} ...@@ -12,9 +15,17 @@ FinchFeaturesServiceProviderDelegate::FinchFeaturesServiceProviderDelegate() {}
FinchFeaturesServiceProviderDelegate::~FinchFeaturesServiceProviderDelegate() {} FinchFeaturesServiceProviderDelegate::~FinchFeaturesServiceProviderDelegate() {}
bool FinchFeaturesServiceProviderDelegate::IsCrostiniEnabled() { bool FinchFeaturesServiceProviderDelegate::IsCrostiniEnabled(
return virtual_machines::AreVirtualMachinesAllowedByVersionAndChannel() && const std::string& user_id_hash) {
virtual_machines::AreVirtualMachinesAllowedByPolicy(); Profile* profile = nullptr;
if (!user_id_hash.empty()) {
profile = g_browser_process->profile_manager()->GetProfileByPath(
ProfileHelper::GetProfilePathByUserIdHash(user_id_hash));
} else {
profile = ProfileManager::GetActiveUserProfile();
}
return IsCrostiniAllowedForProfile(profile);
} }
} // namespace chromeos } // namespace chromeos
...@@ -18,7 +18,7 @@ class FinchFeaturesServiceProviderDelegate ...@@ -18,7 +18,7 @@ class FinchFeaturesServiceProviderDelegate
~FinchFeaturesServiceProviderDelegate() override; ~FinchFeaturesServiceProviderDelegate() override;
// ChromeServiceProvider::Delegate: // ChromeServiceProvider::Delegate:
bool IsCrostiniEnabled() override; bool IsCrostiniEnabled(const std::string& user_id_hash) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(FinchFeaturesServiceProviderDelegate); DISALLOW_COPY_AND_ASSIGN(FinchFeaturesServiceProviderDelegate);
......
...@@ -42,10 +42,16 @@ void ChromeFeaturesServiceProvider::OnExported( ...@@ -42,10 +42,16 @@ void ChromeFeaturesServiceProvider::OnExported(
void ChromeFeaturesServiceProvider::IsCrostiniEnabled( void ChromeFeaturesServiceProvider::IsCrostiniEnabled(
dbus::MethodCall* method_call, dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { dbus::ExportedObject::ResponseSender response_sender) {
dbus::MessageReader reader(method_call);
std::string user_id_hash;
// TODO(nverne): Make it an error to fail to PopString once callers have been
// updated.
reader.PopString(&user_id_hash);
std::unique_ptr<dbus::Response> response = std::unique_ptr<dbus::Response> response =
dbus::Response::FromMethodCall(method_call); dbus::Response::FromMethodCall(method_call);
dbus::MessageWriter writer(response.get()); dbus::MessageWriter writer(response.get());
writer.AppendBool(delegate_->IsCrostiniEnabled()); writer.AppendBool(delegate_->IsCrostiniEnabled(user_id_hash));
response_sender.Run(std::move(response)); response_sender.Run(std::move(response));
} }
......
...@@ -40,7 +40,7 @@ class CHROMEOS_EXPORT ChromeFeaturesServiceProvider ...@@ -40,7 +40,7 @@ class CHROMEOS_EXPORT ChromeFeaturesServiceProvider
Delegate() {} Delegate() {}
virtual ~Delegate() {} virtual ~Delegate() {}
virtual bool IsCrostiniEnabled() = 0; virtual bool IsCrostiniEnabled(const std::string& user_id_hash) = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(Delegate); DISALLOW_COPY_AND_ASSIGN(Delegate);
......
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