1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_POLICY_HANDLERS_CONFIGURATION_POLICY_HANDLER_ASH_H_
#define CHROME_BROWSER_ASH_POLICY_HANDLERS_CONFIGURATION_POLICY_HANDLER_ASH_H_
#include <string>
#include <string_view>
#include "base/values.h"
#include "chrome/browser/extensions/policy_handlers.h"
#include "chromeos/ash/components/network/network_ui_data.h"
#include "components/onc/onc_constants.h"
#include "components/policy/core/browser/configuration_policy_handler.h"
#include "components/policy/core/common/policy_map.h"
namespace policy {
class Schema;
// ConfigurationPolicyHandler for policies referencing external data.
class ExternalDataPolicyHandler : public TypeCheckingPolicyHandler {
public:
explicit ExternalDataPolicyHandler(const char* policy_name);
ExternalDataPolicyHandler(const ExternalDataPolicyHandler&) = delete;
ExternalDataPolicyHandler& operator=(const ExternalDataPolicyHandler&) =
delete;
~ExternalDataPolicyHandler() override;
static bool CheckPolicySettings(const char* policy,
const PolicyMap::Entry* entry,
PolicyErrorMap* errors);
// TypeCheckingPolicyHandler:
bool CheckPolicySettings(const PolicyMap& policies,
PolicyErrorMap* errors) override;
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
};
// ConfigurationPolicyHandler for validation of the network configuration
// policies. These actually don't set any preferences, but the handler just
// generates error messages.
class NetworkConfigurationPolicyHandler : public TypeCheckingPolicyHandler {
public:
static NetworkConfigurationPolicyHandler* CreateForUserPolicy();
static NetworkConfigurationPolicyHandler* CreateForDevicePolicy();
NetworkConfigurationPolicyHandler(const NetworkConfigurationPolicyHandler&) =
delete;
NetworkConfigurationPolicyHandler& operator=(
const NetworkConfigurationPolicyHandler&) = delete;
~NetworkConfigurationPolicyHandler() override;
// ConfigurationPolicyHandler methods:
bool CheckPolicySettings(const PolicyMap& policies,
PolicyErrorMap* errors) override;
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
void PrepareForDisplaying(PolicyMap* policies) const override;
private:
explicit NetworkConfigurationPolicyHandler(const char* policy_name,
::onc::ONCSource onc_source,
const char* pref_path);
// Takes network policy in Value representation and produces an output Value
// that contains a pretty-printed and sanitized version. In particular, we
// remove any Passphrases that may be contained in the JSON. Ownership of the
// return value is transferred to the caller.
static std::optional<base::Value> SanitizeNetworkConfig(
const base::Value* config);
// The kind of ONC source that this handler represents. ONCSource
// distinguishes between user and device policy.
const ::onc::ONCSource onc_source_;
// The name of the pref to apply the policy to.
const char* pref_path_;
};
// Maps the PinnedLauncherApps policy to the corresponding pref. List entries
// may be Android app ids or extension ids.
class PinnedLauncherAppsPolicyHandler : public ListPolicyHandler {
public:
PinnedLauncherAppsPolicyHandler();
PinnedLauncherAppsPolicyHandler(const PinnedLauncherAppsPolicyHandler&) =
delete;
PinnedLauncherAppsPolicyHandler& operator=(
const PinnedLauncherAppsPolicyHandler&) = delete;
~PinnedLauncherAppsPolicyHandler() override;
protected:
// ListPolicyHandler methods:
// Returns true if |value| contains an Android app id (using a heuristic) or
// an extension id.
bool CheckListEntry(const base::Value& value) override;
// Converts the list of strings |filtered_list| to a list of dictionaries and
// sets the pref.
void ApplyList(base::Value::List filtered_list, PrefValueMap* prefs) override;
};
// Maps the DefaultHandlersForFileExtensions policy to the corresponding pref.
class DefaultHandlersForFileExtensionsPolicyHandler
: public SchemaValidatingPolicyHandler {
public:
explicit DefaultHandlersForFileExtensionsPolicyHandler(const policy::Schema&);
// SchemaValidatingPolicyHandler:
bool CheckPolicySettings(const PolicyMap& policies,
PolicyErrorMap* errors) override;
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
bool IsValidPolicyId(std::string_view policy_id) const;
};
class ScreenMagnifierPolicyHandler : public IntRangePolicyHandlerBase {
public:
ScreenMagnifierPolicyHandler();
ScreenMagnifierPolicyHandler(const ScreenMagnifierPolicyHandler&) = delete;
ScreenMagnifierPolicyHandler& operator=(const ScreenMagnifierPolicyHandler&) =
delete;
~ScreenMagnifierPolicyHandler() override;
// IntRangePolicyHandlerBase:
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
};
// Policy handler for login screen power management settings. This does not
// actually set any prefs, it just checks whether the settings are valid and
// generates errors if appropriate.
class LoginScreenPowerManagementPolicyHandler
: public SchemaValidatingPolicyHandler {
public:
explicit LoginScreenPowerManagementPolicyHandler(const Schema& chrome_schema);
LoginScreenPowerManagementPolicyHandler(
const LoginScreenPowerManagementPolicyHandler&) = delete;
LoginScreenPowerManagementPolicyHandler& operator=(
const LoginScreenPowerManagementPolicyHandler&) = delete;
~LoginScreenPowerManagementPolicyHandler() override;
// SchemaValidatingPolicyHandler:
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
};
// Handles the deprecated IdleAction policy, so both kIdleActionBattery and
// kIdleActionAC fall back to the deprecated action.
class DeprecatedIdleActionHandler : public IntRangePolicyHandlerBase {
public:
DeprecatedIdleActionHandler();
DeprecatedIdleActionHandler(const DeprecatedIdleActionHandler&) = delete;
DeprecatedIdleActionHandler& operator=(const DeprecatedIdleActionHandler&) =
delete;
~DeprecatedIdleActionHandler() override;
// IntRangePolicyHandlerBase:
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
};
class PowerManagementIdleSettingsPolicyHandler
: public SchemaValidatingPolicyHandler {
public:
explicit PowerManagementIdleSettingsPolicyHandler(
const Schema& chrome_schema);
PowerManagementIdleSettingsPolicyHandler(
const PowerManagementIdleSettingsPolicyHandler&) = delete;
PowerManagementIdleSettingsPolicyHandler& operator=(
const PowerManagementIdleSettingsPolicyHandler&) = delete;
~PowerManagementIdleSettingsPolicyHandler() override;
// SchemaValidatingPolicyHandler:
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
};
class ScreenLockDelayPolicyHandler : public SchemaValidatingPolicyHandler {
public:
explicit ScreenLockDelayPolicyHandler(const Schema& chrome_schema);
ScreenLockDelayPolicyHandler(const ScreenLockDelayPolicyHandler&) = delete;
ScreenLockDelayPolicyHandler& operator=(const ScreenLockDelayPolicyHandler&) =
delete;
~ScreenLockDelayPolicyHandler() override;
// SchemaValidatingPolicyHandler:
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
};
class ScreenBrightnessPercentPolicyHandler
: public SchemaValidatingPolicyHandler {
public:
explicit ScreenBrightnessPercentPolicyHandler(const Schema& chrome_schema);
ScreenBrightnessPercentPolicyHandler(
const ScreenBrightnessPercentPolicyHandler&) = delete;
ScreenBrightnessPercentPolicyHandler& operator=(
const ScreenBrightnessPercentPolicyHandler&) = delete;
~ScreenBrightnessPercentPolicyHandler() override;
// SchemaValidatingPolicyHandler:
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
};
// Supported values for the |ArcBackupRestoreServiceEnabled| and
// |ArcGoogleLocationServicesEnabled| policies.
enum class ArcServicePolicyValue {
kDisabled = 0,
kUnderUserControl = 1,
kEnabled = 2
};
// Instantiated once each for the |ArcBackupRestoreServiceEnabled| and
// |ArcGoogleLocationServicesEnabled| policies to handle their special logic:
// If the policy is set to |kUnderUserControl|, the pref is unmanaged, as if no
// policy was set.
class ArcServicePolicyHandler : public IntRangePolicyHandlerBase {
public:
ArcServicePolicyHandler(const char* policy, const char* pref);
ArcServicePolicyHandler(const ArcServicePolicyHandler&) = delete;
ArcServicePolicyHandler& operator=(const ArcServicePolicyHandler&) = delete;
// IntRangePolicyHandlerBase:
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
private:
const std::string pref_;
};
// Instantiated for the `ArcGoogleLocationServicesEnabled` policy. This
// overrides the old handling of the `ArcGoogleLocationServicesEnabled` policy
// when the Privacy Hub location is rolled out.
class ArcLocationServicePolicyHandler : public ArcServicePolicyHandler {
public:
explicit ArcLocationServicePolicyHandler(const char* policy,
const char* pref);
ArcLocationServicePolicyHandler(const ArcLocationServicePolicyHandler&) =
delete;
ArcLocationServicePolicyHandler& operator=(
const ArcLocationServicePolicyHandler&) = delete;
// IntRangePolicyHandlerBase:
void ApplyPolicySettings(const PolicyMap& policies,
PrefValueMap* prefs) override;
};
} // namespace policy
#endif // CHROME_BROWSER_ASH_POLICY_HANDLERS_CONFIGURATION_POLICY_HANDLER_ASH_H_
|