Commit fe846102 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Chromium LUCI CQ

PDF Viewer: Show PDF keywords among properties

Keywords are shown a little differently than other property values.
Given that the string is expected to be a long list, wrap the property
value instead of ellipsing.

Screenshot: https://imgur.com/a/GC1hHCx

Bug: 93619
Change-Id: I450cdc70067e8a23052ee09c1ce5312a9832f7fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623711
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842661}
parent 15c97c3e
......@@ -22,6 +22,7 @@ export const DisplayAnnotationsAction = {
* author: string,
* canSerializeDocument: boolean,
* creator: string,
* keywords: string,
* linearized: boolean,
* producer: string,
* subject: string,
......
......@@ -25,6 +25,7 @@
.name {
color: var(--cr-primary-text-color);
padding-inline-end: 12px;
vertical-align: top;
}
.value {
......@@ -35,6 +36,10 @@
text-overflow: ellipsis;
white-space: nowrap;
}
#keywords {
white-space: normal;
}
</style>
<cr-dialog show-on-attach>
<div slot="title">$i18n{propertiesDialogTitle}</div>
......@@ -68,7 +73,9 @@
</tr>
<tr>
<td class="name">$i18n{propertiesKeywords}</td>
<td class="value" id="keywords">-</td>
<td class="value" id="keywords">
[[getOrPlaceholder_(documentMetadata.keywords)]]
</td>
</tr>
<tr>
<td class="name">$i18n{propertiesCreated}</td>
......
......@@ -55,7 +55,7 @@ const tests = [
['title', 'Sample PDF Document Info'],
['author', 'Chromium Authors'],
['subject', 'Testing'],
['keywords', '-'],
['keywords', 'testing,chromium,pdfium,document,info'],
['created', '-'],
['modified', '-'],
['application', 'Your Preferred Text Editor'],
......
......@@ -30,8 +30,8 @@ enum class PdfVersion {
// dictionary (see section 14.3.3 "Document Information Dictionary" of the ISO
// 32000-1 standard), as well as other properties about the file.
// TODO(crbug.com/93619): Finish adding information dictionary fields like
// `keywords`, `creation_date`, and `mod_date`. Also add fields like
// `size_bytes` and `is_encrypted`.
// `creation_date` and `mod_date`. Also add fields like `size_bytes` and
// `is_encrypted`.
struct DocumentMetadata {
DocumentMetadata();
DocumentMetadata(const DocumentMetadata&) = delete;
......@@ -53,6 +53,9 @@ struct DocumentMetadata {
// The document's subject.
std::string subject;
// The document's keywords.
std::string keywords;
// The name of the application that created the original document.
std::string creator;
......
......@@ -136,6 +136,7 @@ constexpr char kJSLinearized[] = "linearized";
constexpr char kJSTitle[] = "title";
constexpr char kJSAuthor[] = "author";
constexpr char kJSSubject[] = "subject";
constexpr char kJSKeywords[] = "keywords";
constexpr char kJSCreator[] = "creator";
constexpr char kJSProducer[] = "producer";
constexpr char kJSCanSerializeDocument[] = "canSerializeDocument";
......@@ -2442,6 +2443,11 @@ void OutOfProcessInstance::SendMetadata() {
if (!document_metadata.subject.empty())
metadata_data.Set(pp::Var(kJSSubject), pp::Var(document_metadata.subject));
if (!document_metadata.keywords.empty()) {
metadata_data.Set(pp::Var(kJSKeywords),
pp::Var(document_metadata.keywords));
}
if (!document_metadata.creator.empty())
metadata_data.Set(pp::Var(kJSCreator), pp::Var(document_metadata.creator));
......
......@@ -3957,6 +3957,7 @@ void PDFiumEngine::LoadDocumentMetadata() {
doc_metadata_.title = GetTrimmedMetadataByField("Title");
doc_metadata_.author = GetTrimmedMetadataByField("Author");
doc_metadata_.subject = GetTrimmedMetadataByField("Subject");
doc_metadata_.keywords = GetTrimmedMetadataByField("Keywords");
doc_metadata_.creator = GetTrimmedMetadataByField("Creator");
doc_metadata_.producer = GetTrimmedMetadataByField("Producer");
}
......
......@@ -353,6 +353,7 @@ TEST_F(PDFiumEngineTest, GetDocumentMetadata) {
EXPECT_EQ("Sample PDF Document Info", doc_metadata.title);
EXPECT_EQ("Chromium Authors", doc_metadata.author);
EXPECT_EQ("Testing", doc_metadata.subject);
EXPECT_EQ("testing,chromium,pdfium,document,info", doc_metadata.keywords);
EXPECT_EQ("Your Preferred Text Editor", doc_metadata.creator);
EXPECT_EQ("fixup_pdf_template.py", doc_metadata.producer);
}
......@@ -370,6 +371,7 @@ TEST_F(PDFiumEngineTest, GetEmptyDocumentMetadata) {
EXPECT_THAT(doc_metadata.title, IsEmpty());
EXPECT_THAT(doc_metadata.author, IsEmpty());
EXPECT_THAT(doc_metadata.subject, IsEmpty());
EXPECT_THAT(doc_metadata.keywords, IsEmpty());
EXPECT_THAT(doc_metadata.creator, IsEmpty());
EXPECT_THAT(doc_metadata.producer, IsEmpty());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment