// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_POLICY_CORE_COMMON_FEATURES_H_
#define COMPONENTS_POLICY_CORE_COMMON_FEATURES_H_

#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/policy/policy_export.h"

namespace policy::features {

// Enable the PolicyBlocklistThrottle optimization to hide the DEFER latency
// on WillStartRequest and WillRedirectRequest. See https://crbug.com/349964973.
// This is launched, but the feature flag will be kept in 2025 for monitoring.
POLICY_EXPORT BASE_DECLARE_FEATURE(kPolicyBlocklistProceedUntilResponse);

// Enables the fact that the ProfileSeparationDomainExceptionList retroactively
// signs out accounts that require a new profile. This is used as a kill switch.
POLICY_EXPORT BASE_DECLARE_FEATURE(
    kProfileSeparationDomainExceptionListRetroactive);

// Enables the addition of new security fields for SecOps.
POLICY_EXPORT BASE_DECLARE_FEATURE(kEnhancedSecurityEventFields);

// Controls if we can use the cec flag in PolicyData.
POLICY_EXPORT BASE_DECLARE_FEATURE(kUseCECFlagInPolicyData);

#if BUILDFLAG(IS_ANDROID)
// Enables policy initialization for signed-in users in new entry points.
POLICY_EXPORT BASE_DECLARE_FEATURE(
    kInitializePoliciesForSignedInUserInNewEntryPoints);

// Controls whether to use active admins to calculate the enterprise info.
POLICY_EXPORT BASE_DECLARE_FEATURE(kAndroidUseAdminsForEnterpriseInfo);
#endif

// Enables a configurable delay for policy registration.
POLICY_EXPORT BASE_DECLARE_FEATURE(kCustomPolicyRegistrationDelay);
POLICY_EXPORT extern const base::FeatureParam<base::TimeDelta>
    kPolicyRegistrationDelay;

// A blocklist of policies supported on Desktop Android.
POLICY_EXPORT BASE_DECLARE_FEATURE(kDesktopAndroidPolicy);
POLICY_EXPORT extern const base::FeatureParam<std::string>
    kDesktopAndroidPolicyBlocklist;

// Used to add a captive portal check in SafeSitesNavigationThrottle.
POLICY_EXPORT BASE_DECLARE_FEATURE(kSafeSitesCaptivePortalCheck);

// Used to enable extension install policy support.
POLICY_EXPORT BASE_DECLARE_FEATURE(kEnableExtensionInstallPolicyFetching);

// When enabled, uses ManagementService to determine whether to honor sensitive
// policies. When disabled, falls back to the original ShouldHonorPolicies()
// behavior. This flag allows reverting if the new approach causes issues.
// Note: Only has an effect on Mac and Windows where ShouldHonorPolicies()
// performs platform-specific checks.
POLICY_EXPORT BASE_DECLARE_FEATURE(kUseManagementServiceForSensitivePolicies);

// When enabled, AzureActiveDirectoryDeviceStatusProvider only returns
// CLOUD_DOMAIN for device-joined Azure AD accounts. When disabled (kill
// switch), it falls back to the behavior of AzureActiveDirectoryStatusProvider,
// returning CLOUD_DOMAIN for all Azure AD joined accounts (including
// workplace-joined).
POLICY_EXPORT BASE_DECLARE_FEATURE(
    kFilterSensitivePoliciesOnWorkplaceJoinedDevices);

// Modifies behavior of policies utilizing URLBlocklistManager.
// When enabled, bypasses the wildcard "*" in the blocklist for internal
// chrome:// URLs such as chrome://ntp, chrome://bookmarks, etc.
// This feature serves as a killswitch to allow for immediate revert via Finch
// if regressions are detected.
POLICY_EXPORT BASE_DECLARE_FEATURE(
    kBypassURLBlocklistWildcardForInternalChromeUrls);

// Modifies behavior of policies utilizing URLBlocklistManager.
// When enabled, downgrades the match level to neutral if the URL is allowed by
// the wildcard '*' in the allowlist.
POLICY_EXPORT BASE_DECLARE_FEATURE(kDowngradeURLAllowlistWildcardToNeutral);

// Enables the mojo version of the page handler for chrome://policy.
POLICY_EXPORT BASE_DECLARE_FEATURE(kPolicyPageMojoMigration);

// If enabled, device signals collection disclaimer will be shown during signin
// for profiles created before the profile flow with disclaimer was released.
POLICY_EXPORT BASE_DECLARE_FEATURE(kDeviceSignalsBackfillDisclaimer);
POLICY_EXPORT extern const base::FeatureParam<bool>
    kClearDeviceSignalsPermissionOnStartup;

// When enabled, URLs in the general blocklist are still blocked in incognito
// even if they are in the incognito allowlist.
POLICY_EXPORT BASE_DECLARE_FEATURE(kURLBlocklistOverridesIncognitoAllowlist);

// Enables the export of platform policies as JSON on the chrome://policy page.
POLICY_EXPORT BASE_DECLARE_FEATURE(kExportPlatformPoliciesJson);

// When enabled, migrates user cloud management status and sign-in interception
// policy fetching from the legacy SecureConnect endpoint to Device Management
// Server.
POLICY_EXPORT BASE_DECLARE_FEATURE(kMigrateSecureConnectApiToDmServer);
POLICY_EXPORT extern const base::FeatureParam<base::TimeDelta>
    kMigrateSecureConnectApiToDmServerFetchTimeout;

}  // namespace policy::features

#endif  // COMPONENTS_POLICY_CORE_COMMON_FEATURES_H_
