#include "chrome/browser/policy/printing_restrictions_policy_handler.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/common/pref_names.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/schema.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_value_map.h"
#include "components/strings/grit/components_strings.h"
#include "printing/buildflags/buildflags.h"
namespace policy {
template <class Mode>
PrintingEnumPolicyHandler<Mode>::PrintingEnumPolicyHandler(
const char* policy_name,
const char* pref_name,
const base::flat_map<std::string, Mode>& policy_value_to_mode)
: … { … }
template <class Mode>
PrintingEnumPolicyHandler<Mode>::~PrintingEnumPolicyHandler() = default;
template <class Mode>
bool PrintingEnumPolicyHandler<Mode>::CheckPolicySettings(
const PolicyMap& policies,
PolicyErrorMap* errors) { … }
template <class Mode>
void PrintingEnumPolicyHandler<Mode>::ApplyPolicySettings(
const PolicyMap& policies,
PrefValueMap* prefs) { … }
template <class Mode>
bool PrintingEnumPolicyHandler<Mode>::GetValue(const PolicyMap& policies,
PolicyErrorMap* errors,
Mode* result) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
PrintingAllowedColorModesPolicyHandler::PrintingAllowedColorModesPolicyHandler()
: PrintingEnumPolicyHandler<printing::ColorModeRestriction>(
key::kPrintingAllowedColorModes,
prefs::kPrintingAllowedColorModes,
{
{"any", printing::ColorModeRestriction::kUnset},
{"monochrome", printing::ColorModeRestriction::kMonochrome},
{"color", printing::ColorModeRestriction::kColor},
}) {}
PrintingAllowedColorModesPolicyHandler::
~PrintingAllowedColorModesPolicyHandler() = default;
PrintingColorDefaultPolicyHandler::PrintingColorDefaultPolicyHandler()
: PrintingEnumPolicyHandler<printing::ColorModeRestriction>(
key::kPrintingColorDefault,
prefs::kPrintingColorDefault,
{
{"monochrome", printing::ColorModeRestriction::kMonochrome},
{"color", printing::ColorModeRestriction::kColor},
}) {}
PrintingColorDefaultPolicyHandler::~PrintingColorDefaultPolicyHandler() =
default;
PrintingAllowedDuplexModesPolicyHandler::
PrintingAllowedDuplexModesPolicyHandler()
: PrintingEnumPolicyHandler<printing::DuplexModeRestriction>(
key::kPrintingAllowedDuplexModes,
prefs::kPrintingAllowedDuplexModes,
{
{"any", printing::DuplexModeRestriction::kUnset},
{"simplex", printing::DuplexModeRestriction::kSimplex},
{"duplex", printing::DuplexModeRestriction::kDuplex},
}) {}
PrintingAllowedDuplexModesPolicyHandler::
~PrintingAllowedDuplexModesPolicyHandler() = default;
PrintingDuplexDefaultPolicyHandler::PrintingDuplexDefaultPolicyHandler()
: PrintingEnumPolicyHandler<printing::DuplexModeRestriction>(
key::kPrintingDuplexDefault,
prefs::kPrintingDuplexDefault,
{
{"simplex", printing::DuplexModeRestriction::kSimplex},
{"long-edge", printing::DuplexModeRestriction::kLongEdge},
{"short-edge", printing::DuplexModeRestriction::kShortEdge},
}) {}
PrintingDuplexDefaultPolicyHandler::~PrintingDuplexDefaultPolicyHandler() =
default;
PrintingAllowedPinModesPolicyHandler::PrintingAllowedPinModesPolicyHandler()
: PrintingEnumPolicyHandler<printing::PinModeRestriction>(
key::kPrintingAllowedPinModes,
prefs::kPrintingAllowedPinModes,
{
{"any", printing::PinModeRestriction::kUnset},
{"pin", printing::PinModeRestriction::kPin},
{"no_pin", printing::PinModeRestriction::kNoPin},
}) {}
PrintingAllowedPinModesPolicyHandler::~PrintingAllowedPinModesPolicyHandler() =
default;
PrintingPinDefaultPolicyHandler::PrintingPinDefaultPolicyHandler()
: PrintingEnumPolicyHandler<printing::PinModeRestriction>(
key::kPrintingPinDefault,
prefs::kPrintingPinDefault,
{
{"pin", printing::PinModeRestriction::kPin},
{"no_pin", printing::PinModeRestriction::kNoPin},
}) {}
PrintingPinDefaultPolicyHandler::~PrintingPinDefaultPolicyHandler() = default;
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
PrintingAllowedBackgroundGraphicsModesPolicyHandler::
PrintingAllowedBackgroundGraphicsModesPolicyHandler()
: … { … }
PrintingAllowedBackgroundGraphicsModesPolicyHandler::
~PrintingAllowedBackgroundGraphicsModesPolicyHandler() = default;
PrintingBackgroundGraphicsDefaultPolicyHandler::
PrintingBackgroundGraphicsDefaultPolicyHandler()
: … { … }
PrintingBackgroundGraphicsDefaultPolicyHandler::
~PrintingBackgroundGraphicsDefaultPolicyHandler() = default;
PrintingPaperSizeDefaultPolicyHandler::PrintingPaperSizeDefaultPolicyHandler()
: … { … }
PrintingPaperSizeDefaultPolicyHandler::
~PrintingPaperSizeDefaultPolicyHandler() = default;
bool PrintingPaperSizeDefaultPolicyHandler::CheckIntSubkey(
const base::Value::Dict& dict,
const std::string& key,
PolicyErrorMap* errors) { … }
bool PrintingPaperSizeDefaultPolicyHandler::GetValue(
const PolicyMap& policies,
PolicyErrorMap* errors,
const base::Value** result) { … }
bool PrintingPaperSizeDefaultPolicyHandler::CheckPolicySettings(
const PolicyMap& policies,
PolicyErrorMap* errors) { … }
void PrintingPaperSizeDefaultPolicyHandler::ApplyPolicySettings(
const PolicyMap& policies,
PrefValueMap* prefs) { … }
PrintPdfAsImageDefaultPolicyHandler::PrintPdfAsImageDefaultPolicyHandler()
: … { … }
PrintPdfAsImageDefaultPolicyHandler::~PrintPdfAsImageDefaultPolicyHandler() =
default;
bool PrintPdfAsImageDefaultPolicyHandler::CheckPolicySettings(
const PolicyMap& policies,
PolicyErrorMap* errors) { … }
void PrintPdfAsImageDefaultPolicyHandler::ApplyPolicySettings(
const PolicyMap& policies,
PrefValueMap* prefs) { … }
#endif
}