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

Unified Diff: printing/pdf_metafile_skia.cc

Issue 1397333003: PDF Printing: embed browser user agent string in PDF metadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2015-11-05 (Thursday) 15:50:39 EST Created 5 years, 1 month 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
Index: printing/pdf_metafile_skia.cc
diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc
index bb22792e40bd45e6fca8cfd90e2682a145ba321c..34ad21aee69d05969c13465bd3f903369c3450b1 100644
--- a/printing/pdf_metafile_skia.cc
+++ b/printing/pdf_metafile_skia.cc
@@ -10,6 +10,7 @@
#include "base/numerics/safe_conversions.h"
#include "base/posix/eintr_wrapper.h"
#include "base/time/time.h"
+#include "printing/print_settings.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkDocument.h"
@@ -163,7 +164,13 @@ bool PdfMetafileSkia::FinishDocument() {
pdf_doc->endPage();
}
SkTArray<SkDocument::Attribute> info;
- info.emplace_back(SkString("Creator"), SkString("Chromium"));
+ const std::string& user_agent = printing::GetAgent();
Lei Zhang 2015/11/05 21:37:23 no need for printing::
hal.canary 2015/11/05 22:16:48 done
+ if (user_agent.size() == 0) {
Lei Zhang 2015/11/05 21:37:23 Most foo.size() == 0 checks can be more easily wri
hal.canary 2015/11/05 22:16:48 done
+ info.emplace_back(SkString("Creator"), SkString("Chromium"));
+ } else {
+ info.emplace_back(SkString("Creator"),
+ SkString(user_agent.c_str(), user_agent.size()));
+ }
SkTime::DateTime now = TimeToSkTime(base::Time::Now());
pdf_doc->setMetadata(info, &now, &now);
if (!pdf_doc->close())

Powered by Google App Engine
This is Rietveld 408576698