Enable chrome with aura for tizen
[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
17 #if defined(USE_CUPS) && !BUILDFLAG(IS_CHROMEOS_ASH)
18 #include "base/strings/string_piece.h"
19 #endif
20
21 #if BUILDFLAG(IS_WIN)
22 #include "ui/gfx/geometry/rect.h"
23 #endif
24
25 namespace gfx {
26 class Size;
27 }
28
29 namespace printing {
30
31 // Simplify title to resolve issue with some drivers.
32 COMPONENT_EXPORT(PRINTING_BASE)
33 std::u16string SimplifyDocumentTitle(const std::u16string& title);
34
35 COMPONENT_EXPORT(PRINTING_BASE)
36 std::u16string SimplifyDocumentTitleWithLength(const std::u16string& title,
37                                                size_t length);
38
39 COMPONENT_EXPORT(PRINTING_BASE)
40 std::u16string FormatDocumentTitleWithOwner(const std::u16string& owner,
41                                             const std::u16string& title);
42
43 COMPONENT_EXPORT(PRINTING_BASE)
44 std::u16string FormatDocumentTitleWithOwnerAndLength(
45     const std::u16string& owner,
46     const std::u16string& title,
47     size_t length);
48
49 #if defined(USE_CUPS) && !BUILDFLAG(IS_CHROMEOS_ASH)
50 // Returns the paper size (microns) most common in the locale to the nearest
51 // millimeter. Defaults to ISO A4 for an empty or invalid locale.
52 COMPONENT_EXPORT(PRINTING_BASE)
53 gfx::Size GetDefaultPaperSizeFromLocaleMicrons(base::StringPiece locale);
54
55 // Returns true if both dimensions of the sizes have a delta less than or equal
56 // to the epsilon value.
57 COMPONENT_EXPORT(PRINTING_BASE)
58 bool SizesEqualWithinEpsilon(const gfx::Size& lhs,
59                              const gfx::Size& rhs,
60                              int epsilon);
61 #endif
62
63 #if BUILDFLAG(IS_WIN)
64 // Get page content rect adjusted based on
65 // http://dev.w3.org/csswg/css3-page/#positioning-page-box
66 COMPONENT_EXPORT(PRINTING_BASE)
67 gfx::Rect GetCenteredPageContentRect(const gfx::Size& paper_size,
68                                      const gfx::Size& page_size,
69                                      const gfx::Rect& page_content_rect);
70 #endif
71
72 // Helper for tests and DCHECKs to validate that `maybe_pdf_data` suggests a PDF
73 // document. This includes checking a minimal size and magic bytes.
74 COMPONENT_EXPORT(PRINTING_BASE)
75 bool LooksLikePdf(base::span<const char> maybe_pdf_data);
76
77 }  // namespace printing
78
79 #endif  // PRINTING_PRINTING_UTILS_H_