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 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "ppapi/c/ppb_core.h" | 23 #include "ppapi/c/ppb_core.h" |
| 24 #include "ppapi/c/private/ppb_pdf.h" | 24 #include "ppapi/c/private/ppb_pdf.h" |
| 25 #include "ppapi/cpp/dev/memory_dev.h" | 25 #include "ppapi/cpp/dev/memory_dev.h" |
| 26 #include "ppapi/cpp/input_event.h" | 26 #include "ppapi/cpp/input_event.h" |
| 27 #include "ppapi/cpp/instance.h" | 27 #include "ppapi/cpp/instance.h" |
| 28 #include "ppapi/cpp/module.h" | 28 #include "ppapi/cpp/module.h" |
| 29 #include "ppapi/cpp/private/pdf.h" | 29 #include "ppapi/cpp/private/pdf.h" |
| 30 #include "ppapi/cpp/trusted/browser_font_trusted.h" | 30 #include "ppapi/cpp/trusted/browser_font_trusted.h" |
| 31 #include "ppapi/cpp/url_response_info.h" | 31 #include "ppapi/cpp/url_response_info.h" |
| 32 #include "ppapi/cpp/var.h" | 32 #include "ppapi/cpp/var.h" |
| 33 #include "ppapi/cpp/var_dictionary.h" | |
| 33 #include "third_party/pdfium/fpdfsdk/include/fpdf_ext.h" | 34 #include "third_party/pdfium/fpdfsdk/include/fpdf_ext.h" |
| 34 #include "third_party/pdfium/fpdfsdk/include/fpdf_flatten.h" | 35 #include "third_party/pdfium/fpdfsdk/include/fpdf_flatten.h" |
| 35 #include "third_party/pdfium/fpdfsdk/include/fpdf_searchex.h" | 36 #include "third_party/pdfium/fpdfsdk/include/fpdf_searchex.h" |
| 36 #include "third_party/pdfium/fpdfsdk/include/fpdf_sysfontinfo.h" | 37 #include "third_party/pdfium/fpdfsdk/include/fpdf_sysfontinfo.h" |
| 37 #include "third_party/pdfium/fpdfsdk/include/fpdf_transformpage.h" | 38 #include "third_party/pdfium/fpdfsdk/include/fpdf_transformpage.h" |
| 38 #include "third_party/pdfium/fpdfsdk/include/fpdfedit.h" | 39 #include "third_party/pdfium/fpdfsdk/include/fpdfedit.h" |
| 39 #include "third_party/pdfium/fpdfsdk/include/fpdfppo.h" | 40 #include "third_party/pdfium/fpdfsdk/include/fpdfppo.h" |
| 40 #include "third_party/pdfium/fpdfsdk/include/fpdfsave.h" | 41 #include "third_party/pdfium/fpdfsdk/include/fpdfsave.h" |
| 41 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PDFWindow.h" | 42 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PDFWindow.h" |
| 42 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PWL_FontMap.h" | 43 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PWL_FontMap.h" |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 need_update = true; | 1182 need_update = true; |
| 1182 if (IsPageVisible(i)) | 1183 if (IsPageVisible(i)) |
| 1183 client_->Invalidate(GetPageScreenRect(i)); | 1184 client_->Invalidate(GetPageScreenRect(i)); |
| 1184 } | 1185 } |
| 1185 if (need_update) | 1186 if (need_update) |
| 1186 LoadPageInfo(true); | 1187 LoadPageInfo(true); |
| 1187 | 1188 |
| 1188 FinishLoadingDocument(); | 1189 FinishLoadingDocument(); |
| 1189 } | 1190 } |
| 1190 | 1191 |
| 1192 pp::VarDictionary PDFiumEngine::GetAllNamedDestinations() { | |
|
raymes
2015/01/14 00:19:01
nit: Can we move this function down near GetNamedD
Deepak
2015/01/14 06:29:01
Done.
| |
| 1193 pp::VarDictionary named_destinations; | |
| 1194 for (unsigned long i = 0; i < GetNameDestCount(); i++) { | |
|
raymes
2015/01/14 00:19:01
Sorry when I said "inline" I just meant actually c
Deepak
2015/01/14 06:29:01
Done.
| |
| 1195 base::string16 name; | |
| 1196 size_t buffer_bytes; | |
|
raymes
2015/01/14 00:19:01
use unsigned long here (as in the API)
Deepak
2015/01/14 06:29:01
Done.
| |
| 1197 FPDF_GetNamedDest(doc_, i, NULL, buffer_bytes); | |
| 1198 if (buffer_bytes > 1) { | |
|
raymes
2015/01/14 00:19:01
We should compute the length of the string here be
Deepak
2015/01/14 06:29:01
Done.
| |
| 1199 FPDF_DEST dest = FPDF_GetNamedDest( | |
| 1200 doc_, i, WriteInto(&name, buffer_bytes + 1), buffer_bytes); | |
| 1201 if (dest) { | |
| 1202 std::string name_dest = base::UTF16ToUTF8(name); | |
| 1203 int page_number = GetNamedDestinationPage(name_dest); | |
| 1204 if (page_number >= 0) { | |
| 1205 named_destinations.Set(pp::Var(name_dest.c_str()), | |
| 1206 pp::Var(page_number)); | |
| 1207 } | |
| 1208 } | |
| 1209 } | |
| 1210 } | |
| 1211 return named_destinations; | |
| 1212 } | |
| 1213 | |
| 1191 void PDFiumEngine::FinishLoadingDocument() { | 1214 void PDFiumEngine::FinishLoadingDocument() { |
| 1192 DCHECK(doc_loader_.IsDocumentComplete() && doc_); | 1215 DCHECK(doc_loader_.IsDocumentComplete() && doc_); |
| 1193 if (called_do_document_action_) | 1216 if (called_do_document_action_) |
| 1194 return; | 1217 return; |
| 1195 called_do_document_action_ = true; | 1218 called_do_document_action_ = true; |
| 1196 | 1219 |
| 1197 // These can only be called now, as the JS might end up needing a page. | 1220 // These can only be called now, as the JS might end up needing a page. |
| 1198 FORM_DoDocumentJSAction(form_); | 1221 FORM_DoDocumentJSAction(form_); |
| 1199 FORM_DoDocumentOpenAction(form_); | 1222 FORM_DoDocumentOpenAction(form_); |
| 1200 if (most_visible_page_ != -1) { | 1223 if (most_visible_page_ != -1) { |
| (...skipping 2715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3916 double* height) { | 3939 double* height) { |
| 3917 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3940 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 3918 if (!doc) | 3941 if (!doc) |
| 3919 return false; | 3942 return false; |
| 3920 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3943 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 3921 FPDF_CloseDocument(doc); | 3944 FPDF_CloseDocument(doc); |
| 3922 return success; | 3945 return success; |
| 3923 } | 3946 } |
| 3924 | 3947 |
| 3925 } // namespace chrome_pdf | 3948 } // namespace chrome_pdf |
| OLD | NEW |