[M120 Migration][VD] Remove accessing oom_score_adj in zygote process
[platform/framework/web/chromium-efl.git] / printing / printing_utils.h
1 // Copyright 2013 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_PRINTING_UTILS_H_
6 #define PRINTING_PRINTING_UTILS_H_
7
8 #include <stddef.h>
9
10 #include <string>
11
12 #include "base/component_export.h"
13 #include "base/containers/span.h"
14 #include "build/build_config.h"
15 #include "build/chromeos_buildflags.h"
16 #include "printing/buildflags/buildflags.h"
17
18 #if BUILDFLAG(USE_CUPS) && !BUILDFLAG(IS_CHROMEOS_ASH)
19 #include "base/strings/string_piece.h"
20 #endif
21
22 #if BUILDFLAG(IS_WIN)
23 #include "base/win/win_handle_types.h"
24 #include "ui/gfx/geometry/rect.h"
25 #endif
26
27 namespace gfx {
28 class Size;
29 }
30
31 namespace printing {
32
33 // Simplify title to resolve issue with some drivers.
34 COMPONENT_EXPORT(PRINTING_BASE)
35 std::u16string SimplifyDocumentTitle(const std::u16string& title);
36
37 COMPONENT_EXPORT(PRINTING_BASE)
38 std::u16string SimplifyDocumentTitleWithLength(const std::u16string& title,
39                                                size_t length);
40
41 COMPONENT_EXPORT(PRINTING_BASE)
42 std::u16string FormatDocumentTitleWithOwner(const std::u16string& owner,
43                                             const std::u16string& title);
44
45 COMPONENT_EXPORT(PRINTING_BASE)
46 std::u16string FormatDocumentTitleWithOwnerAndLength(
47     const std::u16string& owner,
48     const std::u16string& title,
49     size_t length);
50
51 #if BUILDFLAG(USE_CUPS) && !BUILDFLAG(IS_CHROMEOS_ASH)
52 // Returns the paper size (microns) most common in the locale to the nearest
53 // millimeter. Defaults to ISO A4 for an empty or invalid locale.
54 COMPONENT_EXPORT(PRINTING_BASE)
55 gfx::Size GetDefaultPaperSizeFromLocaleMicrons(base::StringPiece locale);
56
57 // Returns true if both dimensions of the sizes have a delta less than or equal
58 // to the epsilon value.
59 COMPONENT_EXPORT(PRINTING_BASE)
60 bool SizesEqualWithinEpsilon(const gfx::Size& lhs,
61                              const gfx::Size& rhs,
62                              int epsilon);
63 #endif
64
65 #if BUILDFLAG(IS_WIN)
66 // Get page content rect adjusted based on
67 // http://dev.w3.org/csswg/css3-page/#positioning-page-box
68 COMPONENT_EXPORT(PRINTING_BASE)
69 gfx::Rect GetCenteredPageContentRect(const gfx::Size& paper_size,
70                                      const gfx::Size& page_size,
71                                      const gfx::Rect& page_content_rect);
72
73 // Returns the printable area in device units for `hdc`.
74 COMPONENT_EXPORT(PRINTING_BASE)
75 gfx::Rect GetPrintableAreaDeviceUnits(HDC hdc);
76 #endif
77
78 // Helper for tests and DCHECKs to validate that `maybe_pdf_data` suggests a PDF
79 // document. This includes checking a minimal size and magic bytes.
80 COMPONENT_EXPORT(PRINTING_BASE)
81 bool LooksLikePdf(base::span<const char> maybe_pdf_data);
82
83 }  // namespace printing
84
85 #endif  // PRINTING_PRINTING_UTILS_H_