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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 1654683002: PDF: Allow external navigation links in PDF bookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « chrome/test/data/pdf/test-bookmarks.pdf ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index e44b2dc18b80f0582b406164c5e2a00d0054d336..b4c07e8478a8fd659955c72aee2a7d47c3d66268 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -413,7 +413,7 @@ pp::VarDictionary TraverseBookmarks(FPDF_DOCUMENT doc,
unsigned int depth) {
pp::VarDictionary dict;
base::string16 title;
- unsigned long buffer_size = FPDFBookmark_GetTitle(bookmark, NULL, 0);
+ unsigned long buffer_size = FPDFBookmark_GetTitle(bookmark, nullptr, 0);
if (buffer_size > 0) {
PDFiumAPIStringBufferSizeInBytesAdapter<base::string16> api_string_adapter(
&title, buffer_size, true);
@@ -427,6 +427,18 @@ pp::VarDictionary TraverseBookmarks(FPDF_DOCUMENT doc,
if (dest) {
int page_index = FPDFDest_GetPageIndex(doc, dest);
dict.Set(pp::Var("page"), pp::Var(page_index));
+ } else {
+ // Extract URI for bookmarks linking to an external page.
+ FPDF_ACTION action = FPDFBookmark_GetAction(bookmark);
+ buffer_size = FPDFAction_GetURIPath(doc, action, nullptr, 0);
+ if (buffer_size > 0) {
+ std::string uri;
+ PDFiumAPIStringBufferAdapter<std::string>
+ api_string_adapter(&uri, buffer_size, true);
+ api_string_adapter.Close(FPDFAction_GetURIPath(
+ doc, action, api_string_adapter.GetData(), buffer_size));
+ dict.Set(pp::Var("uri"), pp::Var(uri));
+ }
}
pp::VarArray children;
« no previous file with comments | « chrome/test/data/pdf/test-bookmarks.pdf ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698