From 99a7837ca844b368e6afbc5273585caab230134c Mon Sep 17 00:00:00 2001 From: Timothy Loh Date: Thu, 25 Mar 2021 07:31:41 +0000 Subject: [PATCH] Revert "Stop supporting Plugin VM device license key" This reverts commit 1cb9f0f336952e6261ce5a6c05a5d59271421744. Reason for revert: Breaking uprev Original change's description: > Stop supporting Plugin VM device license key > > This has been superseded by ByteBot licensing, and has caused some > confusion by users who had previously added such a key, as the policy > is no longer available in the admin console (excl managedchrome). > > Bug: b/178895204 > Change-Id: I8c1715a2d7db9a5618c14e8f9805b831ab9e3f21 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2766562 > Reviewed-by: Maksim Ivanov > Reviewed-by: Xiyuan Xia > Reviewed-by: Jason Lin > Commit-Queue: Timothy Loh > Cr-Commit-Position: refs/heads/master@{#865901} Bug: b/178895204, 1192299 Change-Id: Ie09228479700abf1ed668ca1ec58651f8571168e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2784676 Bot-Commit: Rubber Stamper Commit-Queue: Timothy Loh Commit-Queue: Tim Sergeant Reviewed-by: Joel Hockey Owners-Override: Tim Sergeant Cr-Commit-Position: refs/heads/master@{#866480} --- .../ash/plugin_vm/plugin_vm_features.cc | 9 ++-- .../ash/plugin_vm/plugin_vm_installer.cc | 4 +- .../ash/plugin_vm/plugin_vm_installer.h | 2 - .../plugin_vm/plugin_vm_installer_unittest.cc | 1 - .../ash/plugin_vm/plugin_vm_test_helper.cc | 5 +- .../browser/ash/plugin_vm/plugin_vm_util.cc | 50 +++++++++++++++++-- chrome/browser/ash/plugin_vm/plugin_vm_util.h | 19 ++++--- .../ash/plugin_vm/plugin_vm_util_unittest.cc | 38 +++++++------- .../ash/settings/device_settings_provider.cc | 10 ++++ .../device_settings_provider_unittest.cc | 12 +++++ .../dbus/plugin_vm_service_provider.cc | 3 +- .../autotest_private/autotest_private_api.cc | 4 +- .../policy/device_policy_decoder_chromeos.cc | 10 ++++ .../plugin_vm_installer_view_browsertest.cc | 3 +- .../extensions/api/autotest_private.idl | 7 +-- .../test/data/policy/policy_test_cases.json | 14 +++++- chromeos/settings/cros_settings_names.cc | 2 + chromeos/settings/cros_settings_names.h | 2 + .../policy/resources/policy_templates.json | 7 +-- 19 files changed, 152 insertions(+), 50 deletions(-) diff --git a/chrome/browser/ash/plugin_vm/plugin_vm_features.cc b/chrome/browser/ash/plugin_vm/plugin_vm_features.cc index b10456c3afee3d..c92f74116e568b 100644 --- a/chrome/browser/ash/plugin_vm/plugin_vm_features.cc +++ b/chrome/browser/ash/plugin_vm/plugin_vm_features.cc @@ -45,7 +45,9 @@ PluginVmFeatures::~PluginVmFeatures() = default; // * User should be affiliated. // * PluginVmAllowed device policy should be set to true. // * UserPluginVmAllowed user policy should be set to true. -// * PluginVmUserId user policy should be set. +// * At least one of the following should be set: +// * PluginVmLicenseKey policy. +// * PluginVmUserId policy. bool PluginVmFeatures::IsAllowed(const Profile* profile, std::string* reason) { // Check that PluginVm feature is enabled. if (!base::FeatureList::IsEnabled(features::kPluginVm)) { @@ -69,7 +71,7 @@ bool PluginVmFeatures::IsAllowed(const Profile* profile, std::string* reason) { } // Bypass other checks when a fake policy is set, or running linux-chromeos. - if (FakePolicyIsSet() || !base::SysInfo::IsRunningOnChromeOS()) + if (FakeLicenseKeyIsSet() || !base::SysInfo::IsRunningOnChromeOS()) return true; // Check that the device is enterprise enrolled. @@ -111,7 +113,8 @@ bool PluginVmFeatures::IsAllowed(const Profile* profile, std::string* reason) { return false; } - if (GetPluginVmUserIdForProfile(profile).empty()) { + if (GetPluginVmLicenseKey().empty() && + GetPluginVmUserIdForProfile(profile).empty()) { VLOG(1) << "Parallels require a license be set up in policy."; *reason = "License for the product is not set up in policy"; return false; diff --git a/chrome/browser/ash/plugin_vm/plugin_vm_installer.cc b/chrome/browser/ash/plugin_vm/plugin_vm_installer.cc index 89c4e6a5704dce..cae9674e7e1d3a 100644 --- a/chrome/browser/ash/plugin_vm/plugin_vm_installer.cc +++ b/chrome/browser/ash/plugin_vm/plugin_vm_installer.cc @@ -321,7 +321,9 @@ PluginVmInstaller::~PluginVmInstaller() = default; void PluginVmInstaller::CheckLicense() { UpdateInstallingState(InstallingState::kCheckingLicense); - if (skip_license_check_for_testing_) { + // If the server has provided a license key, responsibility of validating is + // passed to the Plugin VM application. + if (!GetPluginVmLicenseKey().empty()) { OnLicenseChecked(true); return; } diff --git a/chrome/browser/ash/plugin_vm/plugin_vm_installer.h b/chrome/browser/ash/plugin_vm/plugin_vm_installer.h index b676e3ff979485..817fe05a89c911 100644 --- a/chrome/browser/ash/plugin_vm/plugin_vm_installer.h +++ b/chrome/browser/ash/plugin_vm/plugin_vm_installer.h @@ -152,7 +152,6 @@ class PluginVmInstaller : public KeyedService, // Returns free disk space required to install Plugin VM in bytes. int64_t RequiredFreeDiskSpace(); - void SkipLicenseCheckForTesting() { skip_license_check_for_testing_ = true; } void SetFreeDiskSpaceForTesting(int64_t bytes) { free_disk_space_for_testing_ = bytes; } @@ -278,7 +277,6 @@ class PluginVmInstaller : public KeyedService, std::unique_ptr license_checker_; bool using_drive_download_service_ = false; - bool skip_license_check_for_testing_ = false; // -1 indicates not set int64_t free_disk_space_for_testing_ = -1; base::Optional downloaded_image_for_testing_; diff --git a/chrome/browser/ash/plugin_vm/plugin_vm_installer_unittest.cc b/chrome/browser/ash/plugin_vm/plugin_vm_installer_unittest.cc index 3204ccaa24fa58..e46bfda98e2c7a 100644 --- a/chrome/browser/ash/plugin_vm/plugin_vm_installer_unittest.cc +++ b/chrome/browser/ash/plugin_vm/plugin_vm_installer_unittest.cc @@ -171,7 +171,6 @@ class PluginVmInstallerTestBase : public testing::Test { installer_ = PluginVmInstallerFactory::GetForProfile(profile_.get()); observer_ = std::make_unique>(); installer_->SetObserver(observer_.get()); - installer_->SkipLicenseCheckForTesting(); installer_->SetFreeDiskSpaceForTesting(std::numeric_limits::max()); installer_->SetDownloadedImageForTesting(CreateZipFile()); diff --git a/chrome/browser/ash/plugin_vm/plugin_vm_test_helper.cc b/chrome/browser/ash/plugin_vm/plugin_vm_test_helper.cc index 9899b3701c5828..c947010d15f4ba 100644 --- a/chrome/browser/ash/plugin_vm/plugin_vm_test_helper.cc +++ b/chrome/browser/ash/plugin_vm/plugin_vm_test_helper.cc @@ -28,6 +28,7 @@ namespace plugin_vm { namespace { const char kDiskImageImportCommandUuid[] = "3922722bd7394acf85bf4d5a330d4a47"; +const char kPluginVmLicenseKey[] = "LICENSE_KEY"; const char kDomain[] = "example.com"; const char kDeviceId[] = "device_id"; @@ -137,10 +138,10 @@ PluginVmTestHelper::~PluginVmTestHelper() = default; void PluginVmTestHelper::SetPolicyRequirementsToAllowPluginVm() { testing_profile_->GetPrefs()->SetBoolean(plugin_vm::prefs::kPluginVmAllowed, true); - testing_profile_->GetPrefs()->SetString(plugin_vm::prefs::kPluginVmUserId, - "fake-id"); testing_profile_->ScopedCrosSettingsTestHelper()->SetBoolean( chromeos::kPluginVmAllowed, true); + testing_profile_->ScopedCrosSettingsTestHelper()->SetString( + chromeos::kPluginVmLicenseKey, kPluginVmLicenseKey); } void PluginVmTestHelper::SetUserRequirementsToAllowPluginVm() { diff --git a/chrome/browser/ash/plugin_vm/plugin_vm_util.cc b/chrome/browser/ash/plugin_vm/plugin_vm_util.cc index 965e91a54e869a..0dc89085f88c59 100644 --- a/chrome/browser/ash/plugin_vm/plugin_vm_util.cc +++ b/chrome/browser/ash/plugin_vm/plugin_vm_util.cc @@ -38,7 +38,20 @@ const char kChromeOSBaseDirectoryDisplayText[] = "Network \u203a ChromeOS"; namespace { -static bool g_fake_policy_is_set = false; +static std::string& GetFakeLicenseKey() { + static base::NoDestructor license_key; + return *license_key; +} + +static base::RepeatingClosureList& GetFakeLicenceKeyListeners() { + static base::NoDestructor instance; + return *instance; +} + +static std::string& GetFakeUserId() { + static base::NoDestructor user_id; + return *user_id; +} } // namespace @@ -57,6 +70,17 @@ bool IsPluginVmAppWindow(const aura::Window* window) { return *app_id == "org.chromium.plugin_vm_ui"; } +std::string GetPluginVmLicenseKey() { + if (FakeLicenseKeyIsSet()) + return GetFakeLicenseKey(); + std::string plugin_vm_license_key; + if (!ash::CrosSettings::Get()->GetString(chromeos::kPluginVmLicenseKey, + &plugin_vm_license_key)) { + return std::string(); + } + return plugin_vm_license_key; +} + std::string GetPluginVmUserIdForProfile(const Profile* profile) { DCHECK(profile); return profile->GetPrefs()->GetString(plugin_vm::prefs::kPluginVmUserId); @@ -64,17 +88,26 @@ std::string GetPluginVmUserIdForProfile(const Profile* profile) { void SetFakePluginVmPolicy(Profile* profile, const std::string& image_url, - const std::string& image_hash) { + const std::string& image_hash, + const std::string& license_key) { DictionaryPrefUpdate update(profile->GetPrefs(), plugin_vm::prefs::kPluginVmImage); base::DictionaryValue* dict = update.Get(); dict->SetPath("url", base::Value(image_url)); dict->SetPath("hash", base::Value(image_hash)); - g_fake_policy_is_set = true; + + GetFakeLicenseKey() = license_key; + + GetFakeLicenceKeyListeners().Notify(); + GetFakeUserId() = "FAKE_USER_ID"; +} + +bool FakeLicenseKeyIsSet() { + return !GetFakeLicenseKey().empty(); } -bool FakePolicyIsSet() { - return g_fake_policy_is_set; +bool FakeUserIdIsSet() { + return !GetFakeUserId().empty(); } void RemoveDriveDownloadDirectoryIfExists() { @@ -142,6 +175,13 @@ PluginVmPolicySubscription::PluginVmPolicySubscription( chromeos::kPluginVmAllowed, base::BindRepeating(&PluginVmPolicySubscription::OnPolicyChanged, base::Unretained(this))); + license_subscription_ = cros_settings->AddSettingsObserver( + chromeos::kPluginVmLicenseKey, + base::BindRepeating(&PluginVmPolicySubscription::OnPolicyChanged, + base::Unretained(this))); + fake_license_subscription_ = GetFakeLicenceKeyListeners().Add( + base::BindRepeating(&PluginVmPolicySubscription::OnPolicyChanged, + base::Unretained(this))); is_allowed_ = PluginVmFeatures::Get()->IsAllowed(profile); } diff --git a/chrome/browser/ash/plugin_vm/plugin_vm_util.h b/chrome/browser/ash/plugin_vm/plugin_vm_util.h index b83f426436b557..e794a818a254f6 100644 --- a/chrome/browser/ash/plugin_vm/plugin_vm_util.h +++ b/chrome/browser/ash/plugin_vm/plugin_vm_util.h @@ -68,18 +68,24 @@ void ShowPluginVmInstallerView(Profile* profile); // the Plugin VM installer. bool IsPluginVmAppWindow(const aura::Window* window); +// Retrieves the license key to be used for Plugin VM. If +// none is set this will return an empty string. +std::string GetPluginVmLicenseKey(); + // Retrieves the User Id to be used for Plugin VM. If none is set this will // return an empty string. std::string GetPluginVmUserIdForProfile(const Profile* profile); -// Sets fake policy values and enables Plugin VM for tast tests. This sets -// global state. -// TODO(crbug.com/1025136): Set policy directly from tast instead of using a -// test helper function. +// Sets fake policy values and enables Plugin VM for testing. These set global +// state so this should be called with empty strings on tear down. +// TODO(crbug.com/1025136): Remove this once Tast supports setting test +// policies. void SetFakePluginVmPolicy(Profile* profile, const std::string& image_path, - const std::string& image_hash); -bool FakePolicyIsSet(); + const std::string& image_hash, + const std::string& license_key); +bool FakeLicenseKeyIsSet(); +bool FakeUserIdIsSet(); // Used to clean up the Plugin VM Drive download directory if it did not get // removed when it should have, perhaps due to a crash. @@ -114,6 +120,7 @@ class PluginVmPolicySubscription { std::unique_ptr pref_change_registrar_; base::CallbackListSubscription device_allowed_subscription_; + base::CallbackListSubscription license_subscription_; base::CallbackListSubscription fake_license_subscription_; }; diff --git a/chrome/browser/ash/plugin_vm/plugin_vm_util_unittest.cc b/chrome/browser/ash/plugin_vm/plugin_vm_util_unittest.cc index eb52f687e37ff0..1679d91ba557a2 100644 --- a/chrome/browser/ash/plugin_vm/plugin_vm_util_unittest.cc +++ b/chrome/browser/ash/plugin_vm/plugin_vm_util_unittest.cc @@ -76,6 +76,16 @@ TEST_F(PluginVmUtilTest, PluginVmShouldBeConfiguredOnceAllConditionsAreMet) { EXPECT_TRUE(PluginVmFeatures::Get()->IsConfigured(testing_profile_.get())); } +TEST_F(PluginVmUtilTest, GetPluginVmLicenseKey) { + // If no license key is set, the method should return the empty string. + EXPECT_EQ(std::string(), GetPluginVmLicenseKey()); + + const std::string kLicenseKey = "LICENSE_KEY"; + testing_profile_->ScopedCrosSettingsTestHelper()->SetString( + chromeos::kPluginVmLicenseKey, kLicenseKey); + EXPECT_EQ(kLicenseKey, GetPluginVmLicenseKey()); +} + TEST_F(PluginVmUtilTest, AddPluginVmPolicyObserver) { const std::unique_ptr subscription = std::make_unique( @@ -90,35 +100,29 @@ TEST_F(PluginVmUtilTest, AddPluginVmPolicyObserver) { testing::Mock::VerifyAndClearExpectations(this); EXPECT_CALL(*this, OnPolicyChanged(false)); - testing_profile_->ScopedCrosSettingsTestHelper()->SetBoolean( - chromeos::kPluginVmAllowed, false); + testing_profile_->ScopedCrosSettingsTestHelper()->SetString( + chromeos::kPluginVmLicenseKey, ""); testing::Mock::VerifyAndClearExpectations(this); EXPECT_CALL(*this, OnPolicyChanged(true)); - testing_profile_->ScopedCrosSettingsTestHelper()->SetBoolean( - chromeos::kPluginVmAllowed, true); + const std::string kLicenseKey = "LICENSE_KEY"; + testing_profile_->ScopedCrosSettingsTestHelper()->SetString( + chromeos::kPluginVmLicenseKey, kLicenseKey); testing::Mock::VerifyAndClearExpectations(this); EXPECT_CALL(*this, OnPolicyChanged(false)); - testing_profile_->GetPrefs()->SetBoolean(plugin_vm::prefs::kPluginVmAllowed, - false); + testing_profile_->ScopedCrosSettingsTestHelper()->SetBoolean( + chromeos::kPluginVmAllowed, false); testing::Mock::VerifyAndClearExpectations(this); EXPECT_CALL(*this, OnPolicyChanged(true)); - testing_profile_->GetPrefs()->SetBoolean(plugin_vm::prefs::kPluginVmAllowed, - true); + testing_profile_->ScopedCrosSettingsTestHelper()->SetBoolean( + chromeos::kPluginVmAllowed, true); testing::Mock::VerifyAndClearExpectations(this); EXPECT_CALL(*this, OnPolicyChanged(false)); - testing_profile_->GetPrefs()->SetString(plugin_vm::prefs::kPluginVmUserId, - ""); - testing::Mock::VerifyAndClearExpectations(this); - - EXPECT_CALL(*this, OnPolicyChanged(true)); - const std::string kPluginVmUserId = "fancy-user-id"; - testing_profile_->GetPrefs()->SetString(plugin_vm::prefs::kPluginVmUserId, - kPluginVmUserId); - testing::Mock::VerifyAndClearExpectations(this); + testing_profile_->GetPrefs()->SetBoolean(plugin_vm::prefs::kPluginVmAllowed, + false); } TEST_F(PluginVmUtilTest, DriveUrlNonMatches) { diff --git a/chrome/browser/ash/settings/device_settings_provider.cc b/chrome/browser/ash/settings/device_settings_provider.cc index 030d31661a9ea7..121ffe2b7b56a6 100644 --- a/chrome/browser/ash/settings/device_settings_provider.cc +++ b/chrome/browser/ash/settings/device_settings_provider.cc @@ -112,6 +112,7 @@ const char* const kKnownSettings[] = { kLoginAuthenticationBehavior, kLoginVideoCaptureAllowedUrls, kPluginVmAllowed, + kPluginVmLicenseKey, kPolicyMissingMitigationMode, kRebootOnShutdown, kReleaseChannel, @@ -901,6 +902,15 @@ void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, } } + if (policy.has_plugin_vm_license_key()) { + const em::PluginVmLicenseKeyProto& container( + policy.plugin_vm_license_key()); + if (container.has_plugin_vm_license_key()) { + new_values_cache->SetValue( + kPluginVmLicenseKey, base::Value(container.plugin_vm_license_key())); + } + } + // Default value of the policy in case it's missing. int access_mode = em::DevicePrintersAccessModeProto::ACCESS_MODE_ALL; // Use DevicePrintersAccessMode policy if present, otherwise Native version. diff --git a/chrome/browser/ash/settings/device_settings_provider_unittest.cc b/chrome/browser/ash/settings/device_settings_provider_unittest.cc index 4696eb0f44b75e..690b98fe5ac922 100644 --- a/chrome/browser/ash/settings/device_settings_provider_unittest.cc +++ b/chrome/browser/ash/settings/device_settings_provider_unittest.cc @@ -279,6 +279,13 @@ class DeviceSettingsProviderTest : public DeviceSettingsTestBase { BuildAndInstallDevicePolicy(); } + void SetPluginVmLicenseKeySetting(const std::string& plugin_vm_license_key) { + em::PluginVmLicenseKeyProto* proto = + device_policy_->payload().mutable_plugin_vm_license_key(); + proto->set_plugin_vm_license_key(plugin_vm_license_key); + BuildAndInstallDevicePolicy(); + } + void SetDeviceRebootOnUserSignout( em::DeviceRebootOnUserSignoutProto::RebootOnSignoutMode value) { EXPECT_CALL(*this, SettingChanged(_)).Times(AtLeast(1)); @@ -924,6 +931,11 @@ TEST_F(DeviceSettingsProviderTest, DecodePluginVmAllowedSetting) { EXPECT_EQ(base::Value(false), *provider_->Get(kPluginVmAllowed)); } +TEST_F(DeviceSettingsProviderTest, DecodePluginVmLicenseKeySetting) { + SetPluginVmLicenseKeySetting("LICENSE_KEY"); + EXPECT_EQ(base::Value("LICENSE_KEY"), *provider_->Get(kPluginVmLicenseKey)); +} + TEST_F(DeviceSettingsProviderTest, DeviceRebootAfterUserSignout) { using PolicyProto = em::DeviceRebootOnUserSignoutProto; diff --git a/chrome/browser/chromeos/dbus/plugin_vm_service_provider.cc b/chrome/browser/chromeos/dbus/plugin_vm_service_provider.cc index 7cd64a81f94abc..0cbcdc731fa3c7 100644 --- a/chrome/browser/chromeos/dbus/plugin_vm_service_provider.cc +++ b/chrome/browser/chromeos/dbus/plugin_vm_service_provider.cc @@ -79,13 +79,14 @@ void PluginVmServiceProvider::GetLicenseData( std::unique_ptr response = dbus::Response::FromMethodCall(method_call); plugin_vm_service::GetLicenseDataResponse payload; - if (plugin_vm::FakePolicyIsSet()) { + if (plugin_vm::FakeLicenseKeyIsSet()) { payload.set_device_id(kFakeUUID); } else { payload.set_device_id(g_browser_process->platform_part() ->browser_policy_connector_chromeos() ->GetDirectoryApiID()); } + payload.set_license_key(plugin_vm::GetPluginVmLicenseKey()); dbus::MessageWriter writer(response.get()); writer.AppendProtoAsArrayOfBytes(payload); std::move(response_sender).Run(std::move(response)); diff --git a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc index 899137fcf2f30a..bd186d1478151b 100644 --- a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc +++ b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc @@ -2202,11 +2202,11 @@ AutotestPrivateSetPluginVMPolicyFunction::Run() { api::autotest_private::SetPluginVMPolicy::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params); DVLOG(1) << "AutotestPrivateSetPluginVMPolicyFunction " << params->image_url - << ", " << params->image_hash; + << ", " << params->image_hash << ", " << params->license_key; Profile* profile = Profile::FromBrowserContext(browser_context()); plugin_vm::SetFakePluginVmPolicy(profile, params->image_url, - params->image_hash); + params->image_hash, params->license_key); return RespondNow(NoArguments()); } diff --git a/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc b/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc index 0c1599dec50b70..3373734395f91c 100644 --- a/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc +++ b/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc @@ -1720,6 +1720,16 @@ void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, } } + if (policy.has_plugin_vm_license_key()) { + const em::PluginVmLicenseKeyProto& container( + policy.plugin_vm_license_key()); + if (container.has_plugin_vm_license_key()) { + policies->Set(key::kPluginVmLicenseKey, POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, + base::Value(container.plugin_vm_license_key()), nullptr); + } + } + if (policy.has_device_wilco_dtc_allowed() && policy.device_wilco_dtc_allowed().has_device_wilco_dtc_allowed()) { VLOG(2) << "Set Wilco DTC allowed to " diff --git a/chrome/browser/ui/views/plugin_vm/plugin_vm_installer_view_browsertest.cc b/chrome/browser/ui/views/plugin_vm/plugin_vm_installer_view_browsertest.cc index cb80c30a50cf05..ae77a9496ab959 100644 --- a/chrome/browser/ui/views/plugin_vm/plugin_vm_installer_view_browsertest.cc +++ b/chrome/browser/ui/views/plugin_vm/plugin_vm_installer_view_browsertest.cc @@ -102,7 +102,6 @@ class PluginVmInstallerViewBrowserTest : public DialogBrowserTest { auto* installer = plugin_vm::PluginVmInstallerFactory::GetForProfile( browser()->profile()); installer->SetFreeDiskSpaceForTesting(installer->RequiredFreeDiskSpace()); - installer->SkipLicenseCheckForTesting(); } void SetPluginVmImagePref(std::string url, std::string hash) { @@ -166,6 +165,8 @@ class PluginVmInstallerViewBrowserTest : public DialogBrowserTest { // Device policies. scoped_testing_cros_settings_.device_settings()->Set( chromeos::kPluginVmAllowed, base::Value(true)); + scoped_testing_cros_settings_.device_settings()->Set( + chromeos::kPluginVmLicenseKey, base::Value("LICENSE_KEY")); } void SetUserWithAffiliation() { diff --git a/chrome/common/extensions/api/autotest_private.idl b/chrome/common/extensions/api/autotest_private.idl index 44e7f1c516b48f..3f89af2657bfe5 100644 --- a/chrome/common/extensions/api/autotest_private.idl +++ b/chrome/common/extensions/api/autotest_private.idl @@ -758,9 +758,10 @@ namespace autotestPrivate { // Sets mock Plugin VM policy. // |imageUrl|: URL to the image to install. // |imageHash|: Hash for the provided image. - // |ignored|: Deprecated, has no effect. - static void setPluginVMPolicy(DOMString imageUrl, DOMString imageHash, - optional DOMString ignored); + // |licenseKey|: License key for Plugin VM. + static void setPluginVMPolicy(DOMString imageUrl, + DOMString imageHash, + DOMString licenseKey); // Shows the Plugin VM installer. Does not start installation. static void showPluginVMInstaller(); diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json index 483c88d974b92a..2ebbb77b2f0060 100644 --- a/chrome/test/data/policy/policy_test_cases.json +++ b/chrome/test/data/policy/policy_test_cases.json @@ -6735,7 +6735,19 @@ }, "PluginVmLicenseKey": { - "note": "This policy has been removed since Chrome 91." + "os": ["chromeos"], + "policy_pref_mapping_tests": [ + { + "policies": { + "PluginVmLicenseKey": "LICENSE_KEY" + }, + "prefs": { + "cros.device.plugin_vm_license_key": { + "location": "cros_setting" + } + } + } + ] }, "ParentAccessCodeConfig": { diff --git a/chromeos/settings/cros_settings_names.cc b/chromeos/settings/cros_settings_names.cc index bff50fa66caa59..2312747b5b1fe8 100644 --- a/chromeos/settings/cros_settings_names.cc +++ b/chromeos/settings/cros_settings_names.cc @@ -439,6 +439,8 @@ const char kDeviceUnaffiliatedCrostiniAllowed[] = // A boolean pref that indicates whether PluginVm is allowed to run on this // device. const char kPluginVmAllowed[] = "cros.device.plugin_vm_allowed"; +// A string pref that specifies PluginVm license key for this device. +const char kPluginVmLicenseKey[] = "cros.device.plugin_vm_license_key"; // A boolean pref that indicates whether Borealis is allowed to run on this // device. diff --git a/chromeos/settings/cros_settings_names.h b/chromeos/settings/cros_settings_names.h index 45249a86e0fad2..4154ba5b04c632 100644 --- a/chromeos/settings/cros_settings_names.h +++ b/chromeos/settings/cros_settings_names.h @@ -241,6 +241,7 @@ COMPONENT_EXPORT(CHROMEOS_SETTINGS) extern const char kDeviceUnaffiliatedCrostiniAllowed[]; COMPONENT_EXPORT(CHROMEOS_SETTINGS) extern const char kPluginVmAllowed[]; +COMPONENT_EXPORT(CHROMEOS_SETTINGS) extern const char kPluginVmLicenseKey[]; COMPONENT_EXPORT(CHROMEOS_SETTINGS) extern const char kBorealisAllowedForDevice[]; @@ -365,6 +366,7 @@ using ::chromeos::kHeartbeatFrequency; using ::chromeos::kLoginAuthenticationBehavior; using ::chromeos::kLoginVideoCaptureAllowedUrls; using ::chromeos::kPluginVmAllowed; +using ::chromeos::kPluginVmLicenseKey; using ::chromeos::kPolicyMissingMitigationMode; using ::chromeos::kRebootOnShutdown; using ::chromeos::kReleaseChannel; diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index adfaeaa63152ed..780252d1cc9be9 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json @@ -20415,8 +20415,7 @@ 'sensitiveValue': True, 'type': 'string' }, - 'supported_on': ['chrome_os:73-90'], - 'deprecated': True, + 'supported_on': ['chrome_os:73-'], 'device_only': True, 'features': { 'dynamic_refresh': True, @@ -20425,9 +20424,7 @@ 'id': 515, 'caption': '''PluginVm license key''', 'tags': [], - 'desc': '''Setting the policy specifies the PluginVm license key for this device. - - This policy was removed in M91.''', + 'desc': '''Setting the policy specifies the PluginVm license key for this device.''', }, { 'name': 'PluginVmUserId',