#include "chrome/browser/policy/developer_tools_policy_handler.h"
#include <optional>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/policy/extension_developer_mode_policy_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/policy_constants.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/pref_value_map.h"
#include "components/strings/grit/components_strings.h"
namespace policy {
namespace {
Availability;
enum class PolicyCheckResult { … };
PolicyCheckResult CheckDeveloperToolsDisabled(
const base::Value* developer_tools_disabled,
policy::PolicyErrorMap* errors) { … }
std::optional<Availability> GetValueFromDeveloperToolsDisabledPolicy(
const PolicyMap& policies) { … }
bool IsValidDeveloperToolsAvailabilityValue(int value) { … }
PolicyCheckResult CheckDeveloperToolsAvailability(
const base::Value* developer_tools_availability,
policy::PolicyErrorMap* errors) { … }
std::optional<Availability> GetValueFromDeveloperToolsAvailabilityPolicy(
const PolicyMap& policies) { … }
std::optional<Availability> GetValueFromBothPolicies(
const PolicyMap& policies) { … }
Availability GetDevToolsAvailability(const PrefService* pref_sevice) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
bool IsDevToolsAvailabilitySetByPolicy(const PrefService* pref_service) {
return pref_service->IsManagedPreference(prefs::kDevToolsAvailability);
}
Availability GetMostRestrictiveAvailability(Availability availability_1,
Availability availability_2) {
if (availability_1 == Availability::kDisallowed ||
availability_2 == Availability::kDisallowed) {
return Availability::kDisallowed;
}
if (availability_1 == Availability::kDisallowedForForceInstalledExtensions ||
availability_2 == Availability::kDisallowedForForceInstalledExtensions) {
return Availability::kDisallowedForForceInstalledExtensions;
}
return Availability::kAllowed;
}
#endif
}
DeveloperToolsPolicyHandler::DeveloperToolsPolicyHandler() = default;
DeveloperToolsPolicyHandler::~DeveloperToolsPolicyHandler() = default;
bool DeveloperToolsPolicyHandler::CheckPolicySettings(
const policy::PolicyMap& policies,
policy::PolicyErrorMap* errors) { … }
void DeveloperToolsPolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) { … }
void DeveloperToolsPolicyHandler::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
policy::DeveloperToolsPolicyHandler::Availability
DeveloperToolsPolicyHandler::GetEffectiveAvailability(Profile* profile) { … }
}