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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 830433002: Navigation to relative fragments does not work correctly for OOP pdf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 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
« chrome/browser/resources/pdf/pdf.js ('K') | « pdf/pdfium/pdfium_engine.h ('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 228a8899cc4f5436c1ca4b7f7015ce40e68d05da..fb4634ffed46ff8e4401e4c63b8e1a1e0aaea820 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -30,6 +30,7 @@
#include "ppapi/cpp/trusted/browser_font_trusted.h"
#include "ppapi/cpp/url_response_info.h"
#include "ppapi/cpp/var.h"
+#include "ppapi/cpp/var_dictionary.h"
#include "third_party/pdfium/fpdfsdk/include/fpdf_ext.h"
#include "third_party/pdfium/fpdfsdk/include/fpdf_flatten.h"
#include "third_party/pdfium/fpdfsdk/include/fpdf_searchex.h"
@@ -2334,6 +2335,33 @@ int PDFiumEngine::GetNamedDestinationPage(const std::string& destination) {
return dest ? FPDFDest_GetPageIndex(doc_, dest) : -1;
}
+pp::VarDictionary PDFiumEngine::GetNamedDestinations() {
+ pp::VarDictionary named_destinations;
+ for (unsigned long i = 0; i < FPDF_CountNamedDests(doc_); i++) {
+ base::string16 name;
+ unsigned long buffer_bytes;
+ FPDF_GetNamedDest(doc_, i, NULL, buffer_bytes);
+ unsigned long name_length =
+ buffer_bytes / sizeof(base::string16::value_type);
+ if (name_length > 0) {
+ PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(
+ &name, name_length, true);
+ FPDF_DEST dest = FPDF_GetNamedDest(doc_, i, api_string_adapter.GetData(),
+ buffer_bytes);
+ api_string_adapter.Close(name_length);
+ if (dest) {
+ std::string name_dest = base::UTF16ToUTF8(name);
raymes 2015/01/15 23:07:43 nit: name_dest->named_dest
Deepak 2015/01/16 04:39:21 On 2015/01/15 23:07:43, raymes wrote: Done.
+ int page_number = GetNamedDestinationPage(name_dest);
+ if (page_number >= 0) {
+ named_destinations.Set(pp::Var(name_dest.c_str()),
+ pp::Var(page_number));
+ }
+ }
+ }
+ }
+ return named_destinations;
+}
+
int PDFiumEngine::GetFirstVisiblePage() {
CalculateVisiblePages();
return first_visible_page_;
« chrome/browser/resources/pdf/pdf.js ('K') | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698