Chromium Code Reviews| Index: pdf/pdfium/pdfium_engine.cc |
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
| index de50c79ff5185b3015857693e3b2698f657eea48..5c9ccf993c57b3e0bb20d4636903162fe8bb3751 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" |
| @@ -92,6 +93,9 @@ const uint32 kPendingPageColor = 0xFFEEEEEE; |
| const int kPointsPerInch = 72; |
| const int kPixelsPerInch = 96; |
| +// URL reference parameters. |
| +const char kDelimiters[] = "#&"; |
|
raymes
2015/01/13 01:59:32
We can remove this (see below)
Deepak
2015/01/13 08:29:08
Done.
|
| + |
| struct ClipBox { |
| float left; |
| float right; |
| @@ -1188,6 +1192,44 @@ void PDFiumEngine::OnDocumentComplete() { |
| FinishLoadingDocument(); |
| } |
| +unsigned long PDFiumEngine::GetNameDestCount() { |
| + return FPDF_CountNamedDests(doc_); |
|
raymes
2015/01/13 01:59:32
This is quite simple, so let's inline it :)
Deepak
2015/01/13 08:29:07
Done.
Deepak
2015/01/13 08:29:08
Done.
|
| +} |
| + |
| +void PDFiumEngine::GetNameDests(std::vector<std::string>* name_dest) { |
|
raymes
2015/01/13 01:59:32
Given the simplifications I mentioned below, I thi
Deepak
2015/01/13 08:29:08
Done.
|
| + unsigned long count = GetNameDestCount(); |
| + for (unsigned long i = 0; i < count; i++) { |
| + wchar_t* name = NULL; |
|
raymes
2015/01/13 01:59:31
I think we should use a std::string16 and the Writ
Deepak
2015/01/13 08:29:08
done
|
| + unsigned long len = 0; |
| + FPDF_DEST dest = NULL; |
| + dest = FPDF_GetNamedDest(doc_, i, name, len); |
| + if (dest) { |
|
raymes
2015/01/13 01:59:32
-This is strange - the API documentation says it s
Deepak
2015/01/13 08:29:07
agreed
|
| + name = new wchar_t[len]; |
| + FPDF_DEST dest = FPDF_GetNamedDest(doc_, i, name, len); |
| + if (dest) { |
| + name_dest->push_back( |
| + base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(name))); |
| + } |
| + delete[] name; |
| + } |
| + } |
| +} |
| + |
| +void PDFiumEngine::GetAllNameDests(pp::VarDictionary* named_destinations) { |
| + std::vector<std::string> name_dest(GetNameDestCount()); |
| + GetNameDests(&name_dest); |
| + for (size_t i = 0; i < name_dest.size(); ++i) { |
| + std::vector<std::string> fragments; |
| + Tokenize(name_dest[i], kDelimiters, &fragments); |
| + if ((fragments.size() == 1) && |
| + (fragments[0].find('=') == std::string::npos)) { |
|
raymes
2015/01/13 01:59:32
I don't think we need the above 3 lines. I suspect
Deepak
2015/01/13 08:29:08
Done.
|
| + int page_number = GetNamedDestinationPage(fragments[0]); |
|
raymes
2015/01/13 01:59:32
We can just have GetNamedDestinationPage(name_dest
Deepak
2015/01/13 08:29:07
Done.
|
| + if (page_number >= 0) |
| + named_destinations->Set(fragments[0], pp::Var(page_number)); |
| + } |
| + } |
| +} |
| + |
| void PDFiumEngine::FinishLoadingDocument() { |
| DCHECK(doc_loader_.IsDocumentComplete() && doc_); |
| if (called_do_document_action_) |