Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Unified Diff: printing/pdf_metafile_skia.cc

Issue 1367713002: PdfMetafileSkia: Embed Creator, CreationDate, and ModDate in PDF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use base::Time::Now(), not SkTime::GetDateTime() Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/pdf_metafile_skia.cc
diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc
index 78bcaec546523e236cc05854e802cf6095364d72..bb22792e40bd45e6fca8cfd90e2682a145ba321c 100644
--- a/printing/pdf_metafile_skia.cc
+++ b/printing/pdf_metafile_skia.cc
@@ -9,6 +9,7 @@
#include "base/metrics/histogram.h"
#include "base/numerics/safe_conversions.h"
#include "base/posix/eintr_wrapper.h"
+#include "base/time/time.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkDocument.h"
@@ -127,6 +128,21 @@ bool PdfMetafileSkia::FinishPage() {
return true;
}
+static SkTime::DateTime TimeToSkTime(base::Time time) {
+ base::Time::Exploded exploded;
+ time.UTCExplode(&exploded);
+ SkTime::DateTime skdate;
+ skdate.fTimeZoneMinutes = 0;
+ skdate.fYear = exploded.year;
+ skdate.fMonth = exploded.month;
+ skdate.fDayOfWeek = exploded.day_of_week;
+ skdate.fDay = exploded.day_of_month;
+ skdate.fHour = exploded.hour;
+ skdate.fMinute = exploded.minute;
+ skdate.fSecond = exploded.second;
+ return skdate;
+}
+
bool PdfMetafileSkia::FinishDocument() {
// If we've already set the data in InitFromData, leave it be.
if (data_->pdf_data_)
@@ -146,6 +162,10 @@ bool PdfMetafileSkia::FinishDocument() {
canvas->drawPicture(page.content_.get());
pdf_doc->endPage();
}
+ SkTArray<SkDocument::Attribute> info;
+ info.emplace_back(SkString("Creator"), SkString("Chromium"));
+ SkTime::DateTime now = TimeToSkTime(base::Time::Now());
+ pdf_doc->setMetadata(info, &now, &now);
if (!pdf_doc->close())
return false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698