summaryrefslogtreecommitdiffstats
path: root/pdf
diff options
context:
space:
mode:
authortsergeant <tsergeant@chromium.org>2016-02-01 18:14:05 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-02 02:21:55 +0000
commit1e42ed1a044a97823e2beed66cfcf71f42c5a2c2 (patch)
tree0455da7433a07939468d6cbff1308197170e9274 /pdf
parente035152dbe6923b8b2ee0c595fe796e8ff4302cb (diff)
downloadchromium_src-1e42ed1a044a97823e2beed66cfcf71f42c5a2c2.zip
chromium_src-1e42ed1a044a97823e2beed66cfcf71f42c5a2c2.tar.gz
chromium_src-1e42ed1a044a97823e2beed66cfcf71f42c5a2c2.tar.bz2
PDF: Allow external navigation links in PDF bookmarks
Adds support for table of contents entries which point to external URIs. These bookmarks will open the link in a new tab when clicked. BUG=581290 Review URL: https://codereview.chromium.org/1654683002 Cr-Commit-Position: refs/heads/master@{#372862}
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdfium/pdfium_engine.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index e44b2dc..b4c07e8 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;