Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "pdf/pdfium/pdfium_engine.h" | 5 #include "pdf/pdfium/pdfium_engine.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 api_string_adapter.Close(FPDFBookmark_GetTitle( | 420 api_string_adapter.Close(FPDFBookmark_GetTitle( |
| 421 bookmark, api_string_adapter.GetData(), buffer_size)); | 421 bookmark, api_string_adapter.GetData(), buffer_size)); |
| 422 } | 422 } |
| 423 dict.Set(pp::Var("title"), pp::Var(base::UTF16ToUTF8(title))); | 423 dict.Set(pp::Var("title"), pp::Var(base::UTF16ToUTF8(title))); |
| 424 | 424 |
| 425 FPDF_DEST dest = FPDFBookmark_GetDest(doc, bookmark); | 425 FPDF_DEST dest = FPDFBookmark_GetDest(doc, bookmark); |
| 426 // Some bookmarks don't have a page to select. | 426 // Some bookmarks don't have a page to select. |
| 427 if (dest) { | 427 if (dest) { |
| 428 int page_index = FPDFDest_GetPageIndex(doc, dest); | 428 int page_index = FPDFDest_GetPageIndex(doc, dest); |
| 429 dict.Set(pp::Var("page"), pp::Var(page_index)); | 429 dict.Set(pp::Var("page"), pp::Var(page_index)); |
| 430 } else { | |
| 431 // Extract URI for bookmarks linking to an external page. | |
| 432 FPDF_ACTION action = FPDFBookmark_GetAction(bookmark); | |
| 433 buffer_size = FPDFAction_GetURIPath(doc, action, NULL, 0); | |
|
raymes
2016/02/01 04:44:32
nit: nullptr
tsergeant
2016/02/01 06:01:00
Done (and the one above)
| |
| 434 std::string uri; | |
|
raymes
2016/02/01 04:44:32
nit: move into if statement
tsergeant
2016/02/01 06:01:00
Done.
| |
| 435 if (buffer_size > 0) { | |
| 436 PDFiumAPIStringBufferAdapter<std::string> | |
| 437 api_string_adapter(&uri, buffer_size, true); | |
| 438 api_string_adapter.Close(FPDFAction_GetURIPath( | |
| 439 doc, action, api_string_adapter.GetData(), buffer_size)); | |
| 440 dict.Set(pp::Var("uri"), pp::Var(uri)); | |
| 441 } | |
| 430 } | 442 } |
| 431 | 443 |
| 432 pp::VarArray children; | 444 pp::VarArray children; |
| 433 | 445 |
| 434 // Don't trust PDFium to handle circular bookmarks. | 446 // Don't trust PDFium to handle circular bookmarks. |
| 435 const unsigned int kMaxDepth = 128; | 447 const unsigned int kMaxDepth = 128; |
| 436 if (depth < kMaxDepth) { | 448 if (depth < kMaxDepth) { |
| 437 int child_index = 0; | 449 int child_index = 0; |
| 438 std::set<FPDF_BOOKMARK> seen_bookmarks; | 450 std::set<FPDF_BOOKMARK> seen_bookmarks; |
| 439 for (FPDF_BOOKMARK child_bookmark = | 451 for (FPDF_BOOKMARK child_bookmark = |
| (...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3959 double* height) { | 3971 double* height) { |
| 3960 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3972 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 3961 if (!doc) | 3973 if (!doc) |
| 3962 return false; | 3974 return false; |
| 3963 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3975 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 3964 FPDF_CloseDocument(doc); | 3976 FPDF_CloseDocument(doc); |
| 3965 return success; | 3977 return success; |
| 3966 } | 3978 } |
| 3967 | 3979 |
| 3968 } // namespace chrome_pdf | 3980 } // namespace chrome_pdf |
| OLD | NEW |