Commit 6bcada40 authored by Aya ElAttar's avatar Aya ElAttar Committed by Commit Bot

Enabled OsSettings if hosted_app not allowed

Bug: 1067528
Change-Id: I4aa1eb71244e082dabfa1ff9667ca6ab59fc5ac5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134288Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Aya Elsayed <ayaelattar@google.com>
Cr-Commit-Position: refs/heads/master@{#756228}
parent 9676bf51
......@@ -85,19 +85,26 @@ std::string
bool StandardManagementPolicyProvider::UserMayLoad(
const Extension* extension,
base::string16* error) const {
ExtensionManagement::InstallationMode installation_mode =
settings_->GetInstallationMode(extension);
// TODO(crbug.com/1065865): The special check for kOsSettingsAppId should be
// removed once OSSettings is moved to WebApps.
#if defined(OS_CHROMEOS)
if (extension->id() == chromeos::default_web_apps::kOsSettingsAppId &&
(installation_mode == ExtensionManagement::INSTALLATION_BLOCKED ||
installation_mode == ExtensionManagement::INSTALLATION_REMOVED)) {
return ReturnLoadError(extension, error);
}
#endif // defined(OS_CHROMEOS)
// Component extensions are always allowed, besides the camera app that can be
// disabled by extension policy. This is a temporary solution until there's a
// dedicated policy to disable the camera, at which point the special check in
// the 'if' statement should be removed.
// TODO(http://crbug.com/1002935)
// TODO(crbug.com/1065865): The special check for kOsSettingsAppId should be
// removed once OSSettings is moved to WebApps.
if (Manifest::IsComponentLocation(extension->location()) &&
extension->id() != extension_misc::kCameraAppId
#if defined(OS_CHROMEOS)
&& extension->id() != chromeos::default_web_apps::kOsSettingsAppId
#endif // defined(OS_CHROMEOS)
) {
extension->id() != extension_misc::kCameraAppId) {
return true;
}
......@@ -112,13 +119,7 @@ bool StandardManagementPolicyProvider::UserMayLoad(
// by extension management policies. See crbug.com/786061.
// TODO(calamity): This special case should be removed by removing bookmark
// apps from external sources. See crbug.com/788245.
// TODO(crbug.com/1065865): The special check for kOsSettingsAppId should be
// removed once OSSettings is moved to WebApps.
if (extension->from_bookmark()
#if defined(OS_CHROMEOS)
&& extension->id() != chromeos::default_web_apps::kOsSettingsAppId
#endif // defined(OS_CHROMEOS)
)
if (extension->from_bookmark())
return true;
// Check whether the extension type is allowed.
......@@ -148,8 +149,6 @@ bool StandardManagementPolicyProvider::UserMayLoad(
NOTREACHED();
}
ExtensionManagement::InstallationMode installation_mode =
settings_->GetInstallationMode(extension);
if (installation_mode == ExtensionManagement::INSTALLATION_BLOCKED ||
installation_mode == ExtensionManagement::INSTALLATION_REMOVED) {
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
......
......@@ -373,6 +373,27 @@ IN_PROC_BROWSER_TEST_F(ExtensionPolicyTest,
extension_prefs->GetDisableReasons(
chromeos::default_web_apps::kOsSettingsAppId));
}
// Ensure that OS Settings is not blocked by the ExtensionAllowedTypes policy.
IN_PROC_BROWSER_TEST_F(ExtensionPolicyTest, ExtensionAllowedTypesOsSettings) {
extensions::ExtensionRegistry* registry = extension_registry();
const extensions::Extension* bookmark_app = InstallOSSettings();
ASSERT_TRUE(bookmark_app);
ASSERT_TRUE(registry->enabled_extensions().GetByID(
chromeos::default_web_apps::kOsSettingsAppId));
base::ListValue allowed_types;
allowed_types.AppendString("theme");
PolicyMap policies;
policies.Set(key::kExtensionAllowedTypes, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
allowed_types.CreateDeepCopy(), nullptr);
UpdateProviderPolicy(policies);
extensions::ExtensionService* service = extension_service();
EXPECT_TRUE(service->IsExtensionEnabled(
chromeos::default_web_apps::kOsSettingsAppId));
}
#endif // defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(ExtensionPolicyTest,
......
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