Chromium Code Reviews| Index: pdf/pdfium/pdfium_engine.cc |
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
| index 228a8899cc4f5436c1ca4b7f7015ce40e68d05da..ae1973497e743b9032ff3341acf85b681905cf69 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,30 @@ 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); |
| + size_t bytes_in_char16 = sizeof(base::string16::value_type); |
| + unsigned long name_length = buffer_bytes / bytes_in_char16; |
|
raymes
2015/01/15 04:51:11
nit: merge the above 2 lines
Deepak
2015/01/15 06:30:06
Done.
|
| + if (name_length > 1) { |
|
raymes
2015/01/15 04:51:11
this should just be name_length > 0 when switching
Deepak
2015/01/15 06:30:06
Done.
|
| + FPDF_DEST dest = FPDF_GetNamedDest(doc_, i, WriteInto(&name, name_length), |
| + buffer_bytes); |
|
raymes
2015/01/15 04:51:11
thestig just added a class which will make doing t
Deepak
2015/01/15 06:30:06
These changes are not yet rolled in.Once These rol
|
| + if (dest) { |
| + std::string name_dest = base::UTF16ToUTF8(name); |
| + 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_; |