diff --git a/chrome/test/data/pdf/viewer_properties_dialog_test.js b/chrome/test/data/pdf/viewer_properties_dialog_test.js index cc937c5ffca0f..ab668fb7bd349 100644 --- a/chrome/test/data/pdf/viewer_properties_dialog_test.js +++ b/chrome/test/data/pdf/viewer_properties_dialog_test.js @@ -59,7 +59,7 @@ const tests = [ ['pdf-producer', 'fixup_pdf_template.py'], ['pdf-version', '1.7'], ['page-count', '1'], - ['page-size', '2.78 × 2.78 in (portrait)'], + ['page-size', '2.78 × 2.78 in (square)'], ['fast-web-view', 'No'], ].forEach(([field, expectedValue]) => assertField(field, expectedValue)); diff --git a/components/pdf_strings.grdp b/components/pdf_strings.grdp index 0f1ef6784a448..7181ca1513c2e 100644 --- a/components/pdf_strings.grdp +++ b/components/pdf_strings.grdp @@ -97,6 +97,9 @@ <message name="IDS_PDF_PROPERTIES_PAGE_SIZE_LANDSCAPE" desc="Label for a landscape page orientation."> landscape </message> + <message name="IDS_PDF_PROPERTIES_PAGE_SIZE_SQUARE" desc="Label for a square page that has neither portrait nor landscape orientation."> + square + </message> <message name="IDS_PDF_PROPERTIES_PAGE_SIZE_VARIABLE" desc="Value for the page size of a PDF that lacks a uniform page size."> Varies </message> diff --git a/components/pdf_strings_grdp/IDS_PDF_PROPERTIES_PAGE_SIZE_SQUARE.png.sha1 b/components/pdf_strings_grdp/IDS_PDF_PROPERTIES_PAGE_SIZE_SQUARE.png.sha1 new file mode 100644 index 0000000000000..f33a81a49cbb7 --- /dev/null +++ b/components/pdf_strings_grdp/IDS_PDF_PROPERTIES_PAGE_SIZE_SQUARE.png.sha1 @@ -0,0 +1 @@ +161d76850b84697ce3498aec6b98e927b4fefc86 \ No newline at end of file diff --git a/pdf/ui/document_properties.cc b/pdf/ui/document_properties.cc index 2727c6b6ebb99..d6c9e9078d284 100644 --- a/pdf/ui/document_properties.cc +++ b/pdf/ui/document_properties.cc @@ -53,11 +53,15 @@ std::u16string FormatLengthInMillimeters(int length_points) { // Returns the localized string for the orientation. std::u16string GetOrientation(const gfx::Size& size) { - // TODO(crbug.com/1184345): Add a string for square sizes such that they are - // not displayed as "portrait". - return l10n_util::GetStringUTF16( - size.height() >= size.width() ? IDS_PDF_PROPERTIES_PAGE_SIZE_PORTRAIT - : IDS_PDF_PROPERTIES_PAGE_SIZE_LANDSCAPE); + int message_id; + if (size.height() > size.width()) + message_id = IDS_PDF_PROPERTIES_PAGE_SIZE_PORTRAIT; + else if (size.height() < size.width()) + message_id = IDS_PDF_PROPERTIES_PAGE_SIZE_LANDSCAPE; + else + message_id = IDS_PDF_PROPERTIES_PAGE_SIZE_SQUARE; + + return l10n_util::GetStringUTF16(message_id); } bool ShowInches() { diff --git a/pdf/ui/document_properties_unittest.cc b/pdf/ui/document_properties_unittest.cc index 18c2fae9c8be4..21a62a6b21102 100644 --- a/pdf/ui/document_properties_unittest.cc +++ b/pdf/ui/document_properties_unittest.cc @@ -53,7 +53,7 @@ class FormatPageSizeMillimetersTest : public FormatPageSizeTest { }; TEST_F(FormatPageSizeMillimetersTest, EmptySize) { - EXPECT_EQ(FormatPageSize(gfx::Size()), u"0 × 0 mm (portrait)"); + EXPECT_EQ(FormatPageSize(gfx::Size()), u"0 × 0 mm (square)"); } TEST_F(FormatPageSizeMillimetersTest, Portrait) { @@ -65,12 +65,12 @@ TEST_F(FormatPageSizeMillimetersTest, Landscape) { } TEST_F(FormatPageSizeMillimetersTest, Square) { - EXPECT_EQ(FormatPageSize(gfx::Size(100, 100)), u"35 × 35 mm (portrait)"); + EXPECT_EQ(FormatPageSize(gfx::Size(100, 100)), u"35 × 35 mm (square)"); } TEST_F(FormatPageSizeMillimetersTest, Large) { EXPECT_EQ(FormatPageSize(gfx::Size(72000, 72000)), - u"25,400 × 25,400 mm (portrait)"); + u"25,400 × 25,400 mm (square)"); } class FormatPageSizeMillimetersPeriodSeparatorTest : public FormatPageSizeTest { @@ -80,7 +80,7 @@ class FormatPageSizeMillimetersPeriodSeparatorTest : public FormatPageSizeTest { TEST_F(FormatPageSizeMillimetersPeriodSeparatorTest, Large) { EXPECT_EQ(FormatPageSize(gfx::Size(72000, 72000)), - u"25.400 × 25.400 mm (portrait)"); + u"25.400 × 25.400 mm (square)"); } class FormatPageSizeInchesTest : public FormatPageSizeTest { @@ -89,7 +89,7 @@ class FormatPageSizeInchesTest : public FormatPageSizeTest { }; TEST_F(FormatPageSizeInchesTest, EmptySize) { - EXPECT_EQ(FormatPageSize(gfx::Size()), u"0.00 × 0.00 in (portrait)"); + EXPECT_EQ(FormatPageSize(gfx::Size()), u"0.00 × 0.00 in (square)"); } TEST_F(FormatPageSizeInchesTest, Portrait) { @@ -101,12 +101,12 @@ TEST_F(FormatPageSizeInchesTest, Landscape) { } TEST_F(FormatPageSizeInchesTest, Square) { - EXPECT_EQ(FormatPageSize(gfx::Size(100, 100)), u"1.39 × 1.39 in (portrait)"); + EXPECT_EQ(FormatPageSize(gfx::Size(100, 100)), u"1.39 × 1.39 in (square)"); } TEST_F(FormatPageSizeInchesTest, Large) { EXPECT_EQ(FormatPageSize(gfx::Size(72000, 72000)), - u"1,000.00 × 1,000.00 in (portrait)"); + u"1,000.00 × 1,000.00 in (square)"); } TEST(FormatPdfVersion, Valid) {