Commit 7a15fe49 authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Remove exception to allow Plugin VM in dev mode

This CL removes the exception which allows Plugin VM in dev mode, so
users will now have to have the appropriate policies set up before they
will see Plugin VM.

Bug: b/150257462
Change-Id: Ib73436e093dbab9e2ba64479a0327799bcca8405
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072524
Commit-Queue: Timothy Loh <timloh@chromium.org>
Reviewed-by: default avatarJulian Watson <juwa@google.com>
Cr-Commit-Position: refs/heads/master@{#744559}
parent 95405aa7
......@@ -6,7 +6,6 @@
#include "ash/public/cpp/shelf_item_delegate.h"
#include "ash/public/cpp/shelf_model.h"
#include "base/json/json_reader.h"
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_pref_names.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h"
......@@ -15,7 +14,6 @@
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/constants/chromeos_switches.h"
#include "components/account_id/account_id.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
......@@ -123,11 +121,6 @@ void PluginVmTestHelper::EnablePluginVmFeature() {
scoped_feature_list_.InitAndEnableFeature(features::kPluginVm);
}
void PluginVmTestHelper::EnableDevMode() {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
chromeos::switches::kSystemDevMode);
}
void PluginVmTestHelper::EnterpriseEnrollDevice() {
testing_profile_->ScopedCrosSettingsTestHelper()
->InstallAttributes()
......@@ -143,14 +136,6 @@ void PluginVmTestHelper::AllowPluginVm() {
ASSERT_TRUE(IsPluginVmAllowedForProfile(testing_profile_));
}
void PluginVmTestHelper::AllowPluginVmForManualTesting() {
ASSERT_FALSE(IsPluginVmAllowedForProfile(testing_profile_));
SetUserRequirementsToAllowPluginVm();
EnablePluginVmFeature();
EnableDevMode();
ASSERT_TRUE(IsPluginVmAllowedForProfile(testing_profile_));
}
void PluginVmTestHelper::OpenShelfItem() {
ash::ShelfID shelf_id(kPluginVmAppId);
std::unique_ptr<ash::ShelfItemDelegate> delegate =
......
......@@ -32,13 +32,9 @@ class PluginVmTestHelper {
void SetPolicyRequirementsToAllowPluginVm();
void SetUserRequirementsToAllowPluginVm();
void EnablePluginVmFeature();
void EnableDevMode();
void EnterpriseEnrollDevice();
void AllowPluginVm();
// Sets the conditions required by PluginVm to be allowed when device is not
// enterprise enrolled so that manual testing of PluginVm is easier.
void AllowPluginVmForManualTesting();
// Fakes the Plugin VM window being opened or closed.
void OpenShelfItem();
......
......@@ -8,7 +8,6 @@
#include <utility>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/task/post_task.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_drive_image_download_service.h"
......@@ -19,7 +18,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/common/chrome_features.h"
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/tpm/install_attributes.h"
#include "components/exo/shell_surface_util.h"
#include "components/prefs/pref_service.h"
......@@ -40,16 +38,9 @@ static std::string& GetFakeLicenseKey() {
// For PluginVm to be allowed:
// * Profile should be eligible.
// * PluginVm feature should be enabled.
// If device is not enterprise enrolled:
// * Device should be in a dev mode.
// If device is enterprise enrolled:
// * User should be affiliated.
// * All necessary policies should be set (PluginVmAllowed and
// PluginVmLicenseKey).
//
// TODO(okalitova, aoldemeier): PluginVm should be disabled in case of
// non-managed devices once it is launched. Currently this conditions are used
// for making manual tests easier.
// * Device should be enterprise enrolled:
// * User should be affiliated.
// * PluginVmAllowed and PluginVmLicenseKey policies should be set.
bool IsPluginVmAllowedForProfile(const Profile* profile) {
// Check that the profile is eligible.
if (!profile || profile->IsChild() || profile->IsLegacySupervised() ||
......@@ -68,16 +59,9 @@ bool IsPluginVmAllowedForProfile(const Profile* profile) {
if (FakeLicenseKeyIsSet())
return true;
// TODO(okalitova, aoldemeier): Remove once PluginVm is ready to be launched.
// Check for alternative condition for manual testing, i.e. the device is in
// developer mode and the device is not enterprise-enrolled.
if (!chromeos::InstallAttributes::Get()->IsEnterpriseManaged()) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kSystemDevMode)) {
return true;
}
// Check that the device is enterprise enrolled.
if (!chromeos::InstallAttributes::Get()->IsEnterpriseManaged())
return false;
}
// Check that the user is affiliated.
const user_manager::User* const user =
......
......@@ -80,13 +80,6 @@ TEST_F(PluginVmUtilTest, GetPluginVmLicenseKey) {
EXPECT_EQ(kLicenseKey, GetPluginVmLicenseKey());
}
TEST_F(PluginVmUtilTest, PluginVmShouldBeAllowedForManualTesting) {
EXPECT_FALSE(IsPluginVmAllowedForProfile(testing_profile_.get()));
test_helper_->AllowPluginVmForManualTesting();
EXPECT_TRUE(IsPluginVmAllowedForProfile(testing_profile_.get()));
}
TEST_F(PluginVmUtilTest, DriveLinkDetection) {
std::string base_url(kBaseDriveUrl);
std::string file_id(kDriveFileId);
......
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