Sparik Hayrapetyan | 48216b3 | 2022-12-16 16:07:26 | [diff] [blame] | 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. |
| 4 | |
| 5 | #ifndef PRINTING_CLIENT_INFO_HELPERS_H_ |
| 6 | #define PRINTING_CLIENT_INFO_HELPERS_H_ |
| 7 | |
Bryan Cain | 034c5dc | 2023-02-09 19:24:54 | [diff] [blame] | 8 | #include <cstddef> |
Sparik Hayrapetyan | 48216b3 | 2022-12-16 16:07:26 | [diff] [blame] | 9 | #include "base/component_export.h" |
| 10 | #include "printing/mojom/print.mojom-forward.h" |
Sparik Hayrapetyan | 48216b3 | 2022-12-16 16:07:26 | [diff] [blame] | 11 | |
| 12 | namespace printing { |
| 13 | |
| 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; |
| 19 | |
Bryan Cain | 034c5dc | 2023-02-09 19:24:54 | [diff] [blame] | 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. |
Sparik Hayrapetyan | 48216b3 | 2022-12-16 16:07:26 | [diff] [blame] | 25 | COMPONENT_EXPORT(PRINTING) |
Bryan Cain | 034c5dc | 2023-02-09 19:24:54 | [diff] [blame] | 26 | bool ValidateClientInfoItem(const mojom::IppClientInfo& client_info); |
Sparik Hayrapetyan | 48216b3 | 2022-12-16 16:07:26 | [diff] [blame] | 27 | |
| 28 | } // namespace printing |
| 29 | |
| 30 | #endif // PRINTING_CLIENT_INFO_HELPERS_H_ |