1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_CLIENT_INFO_HELPERS_H_
6 #define PRINTING_CLIENT_INFO_HELPERS_H_
9 #include "base/component_export.h"
10 #include "printing/mojom/print.mojom-forward.h"
14 // Maximum length limits for 'client-info' member attributes.
15 inline constexpr size_t kClientInfoMaxNameLength = 127;
16 inline constexpr size_t kClientInfoMaxPatchesLength = 255;
17 inline constexpr size_t kClientInfoMaxStringVersionLength = 127;
18 inline constexpr size_t kClientInfoMaxVersionLength = 64;
20 // Returns true if all members of `client_info` are valid.
21 // String members are considered valid if they match the regex [a-zA-Z0-9_.-]*
22 // and do not exceed the maximum length specified for the respective IPP member
23 // attribute. The `client_type` member is valid if it is equal to one of the
24 // enum values defined for the `client-type` IPP attribute.
25 COMPONENT_EXPORT(PRINTING)
26 bool ValidateClientInfoItem(const mojom::IppClientInfo& client_info);
28 } // namespace printing
30 #endif // PRINTING_CLIENT_INFO_HELPERS_H_