Commit 937d66f7 authored by Pavol Marko's avatar Pavol Marko Committed by Commit Bot

Only check primary profile's dev tools enablement if it's managed

If the primary profile is not manged, the kDevToolsAvailability pref
will default to 0 (allow, except for in force-installed extensions).
This matters *only* if there's a secondary profile with a more liberal
kDevToolsAvailabilityPref, because the primary profile's value would be
more retrictive then. Only evaluate the primary profile's value if it is
really managed.

      secondary profile with force-installed extensions. Set
      DeveloperToolsAvailability policy in the secondary profile's
      policy to 1 (allowed) and ensure that developer tools are usable
      in force-installed extensions.

Bug: 924973
Test: manual -- sign-in with an unmanaged primary profile and a managed
Change-Id: I1328a70664af759231ebc19bdb51a7ff1c193783
Reviewed-on: https://chromium-review.googlesource.com/c/1434316Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarLutz Justen <ljusten@chromium.org>
Commit-Queue: Pavol Marko <pmarko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626290}
parent 726375b6
......@@ -169,7 +169,10 @@ bool ChromeDevToolsManagerDelegate::AllowInspection(
profile->GetPrefs());
#if defined(OS_CHROMEOS)
// Do not create DevTools if it's disabled for primary profile.
if (Profile* primary_profile = ProfileManager::GetPrimaryUserProfile()) {
Profile* primary_profile = ProfileManager::GetPrimaryUserProfile();
if (primary_profile &&
policy::DeveloperToolsPolicyHandler::IsDevToolsAvailabilitySetByPolicy(
primary_profile->GetPrefs())) {
availability =
policy::DeveloperToolsPolicyHandler::GetMostRestrictiveAvailability(
availability,
......
......@@ -217,6 +217,12 @@ DeveloperToolsPolicyHandler::GetDevToolsAvailability(
return static_cast<Availability>(value);
}
// static
bool DeveloperToolsPolicyHandler::IsDevToolsAvailabilitySetByPolicy(
const PrefService* pref_service) {
return pref_service->IsManagedPreference(prefs::kDevToolsAvailability);
}
// static
DeveloperToolsPolicyHandler::Availability
DeveloperToolsPolicyHandler::GetMostRestrictiveAvailability(
......
......@@ -54,6 +54,11 @@ class DeveloperToolsPolicyHandler : public ConfigurationPolicyHandler {
// |Availability::kDisallowedForForceInstalledExtensions|.
static Availability GetDevToolsAvailability(const PrefService* pref_service);
// Returns true if developer tools availability is set by an active policy in
// |pref_service|.
static bool IsDevToolsAvailabilitySetByPolicy(
const PrefService* pref_service);
// Returns the most restrictive availability within [|availability_1|,
// |availability_2|].
static Availability GetMostRestrictiveAvailability(
......
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