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

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 1155963004: PDF: Cleanup more code now that it is completely out of process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bad rebase Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/i18n/icu_encoding_detection.h" 9 #include "base/i18n/icu_encoding_detection.h"
10 #include "base/i18n/icu_string_conversions.h" 10 #include "base/i18n/icu_string_conversions.h"
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 934
935 FPDF_FILEHANDLER* PDFiumEngine::Form_OpenFile(FPDF_FORMFILLINFO* param, 935 FPDF_FILEHANDLER* PDFiumEngine::Form_OpenFile(FPDF_FORMFILLINFO* param,
936 int file_flag, 936 int file_flag,
937 FPDF_WIDESTRING url, 937 FPDF_WIDESTRING url,
938 const char* mode) { 938 const char* mode) {
939 std::string url_str = "NULL"; 939 std::string url_str = "NULL";
940 if (url != NULL) { 940 if (url != NULL) {
941 url_str = 941 url_str =
942 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url)); 942 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
943 } 943 }
944 // TODO: need to implement open file from the url 944 // TODO: need to implement open file from the url
945 // Use a file path for the ease of testing 945 // Use a file path for the ease of testing
946 FILE* file = fopen(XFA_TESTFILE("tem.txt"), mode); 946 FILE* file = fopen(XFA_TESTFILE("tem.txt"), mode);
947 FPDF_FILE* file_wrapper = new FPDF_FILE; 947 FPDF_FILE* file_wrapper = new FPDF_FILE;
948 file_wrapper->file = file; 948 file_wrapper->file = file;
949 file_wrapper->file_handler.clientData = file_wrapper; 949 file_wrapper->file_handler.clientData = file_wrapper;
950 file_wrapper->file_handler.Flush = Sample_Flush; 950 file_wrapper->file_handler.Flush = Sample_Flush;
951 file_wrapper->file_handler.GetSize = Sample_GetSize; 951 file_wrapper->file_handler.GetSize = Sample_GetSize;
952 file_wrapper->file_handler.ReadBlock = Sample_ReadBlock; 952 file_wrapper->file_handler.ReadBlock = Sample_ReadBlock;
953 file_wrapper->file_handler.Release = Sample_Release; 953 file_wrapper->file_handler.Release = Sample_Release;
954 file_wrapper->file_handler.Truncate = Sample_Truncate; 954 file_wrapper->file_handler.Truncate = Sample_Truncate;
955 file_wrapper->file_handler.WriteBlock = Sample_WriteBlock; 955 file_wrapper->file_handler.WriteBlock = Sample_WriteBlock;
(...skipping 29 matching lines...) Expand all
985 return file_avail->loader->IsDataAvailable(offset, size); 985 return file_avail->loader->IsDataAvailable(offset, size);
986 } 986 }
987 987
988 void PDFiumEngine::AddSegment(FX_DOWNLOADHINTS* param, 988 void PDFiumEngine::AddSegment(FX_DOWNLOADHINTS* param,
989 size_t offset, size_t size) { 989 size_t offset, size_t size) {
990 PDFiumEngine::DownloadHints* download_hints = 990 PDFiumEngine::DownloadHints* download_hints =
991 static_cast<PDFiumEngine::DownloadHints*>(param); 991 static_cast<PDFiumEngine::DownloadHints*>(param);
992 return download_hints->loader->RequestData(offset, size); 992 return download_hints->loader->RequestData(offset, size);
993 } 993 }
994 994
995 bool PDFiumEngine::New(const char* url) {
996 url_ = url;
997 headers_ = std::string();
998 return true;
999 }
1000
1001 bool PDFiumEngine::New(const char* url, 995 bool PDFiumEngine::New(const char* url,
1002 const char* headers) { 996 const char* headers) {
1003 url_ = url; 997 url_ = url;
1004 if (!headers) 998 if (!headers)
1005 headers_ = std::string(); 999 headers_.clear();
1006 else 1000 else
1007 headers_ = headers; 1001 headers_ = headers;
1008 return true; 1002 return true;
1009 } 1003 }
1010 1004
1011 void PDFiumEngine::PageOffsetUpdated(const pp::Point& page_offset) { 1005 void PDFiumEngine::PageOffsetUpdated(const pp::Point& page_offset) {
1012 page_offset_ = page_offset; 1006 page_offset_ = page_offset;
1013 } 1007 }
1014 1008
1015 void PDFiumEngine::PluginSizeUpdated(const pp::Size& size) { 1009 void PDFiumEngine::PluginSizeUpdated(const pp::Size& size) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 called_do_document_action_ = true; 1230 called_do_document_action_ = true;
1237 1231
1238 // These can only be called now, as the JS might end up needing a page. 1232 // These can only be called now, as the JS might end up needing a page.
1239 FORM_DoDocumentJSAction(form_); 1233 FORM_DoDocumentJSAction(form_);
1240 FORM_DoDocumentOpenAction(form_); 1234 FORM_DoDocumentOpenAction(form_);
1241 if (most_visible_page_ != -1) { 1235 if (most_visible_page_ != -1) {
1242 FPDF_PAGE new_page = pages_[most_visible_page_]->GetPage(); 1236 FPDF_PAGE new_page = pages_[most_visible_page_]->GetPage();
1243 FORM_DoPageAAction(new_page, form_, FPDFPAGE_AACTION_OPEN); 1237 FORM_DoPageAAction(new_page, form_, FPDFPAGE_AACTION_OPEN);
1244 } 1238 }
1245 1239
1246 if (doc_) // This can only happen if loading |doc_| fails. 1240 if (doc_) // This can only happen if loading |doc_| fails.
1247 client_->DocumentLoadComplete(pages_.size()); 1241 client_->DocumentLoadComplete(pages_.size());
1248 } 1242 }
1249 1243
1250 void PDFiumEngine::UnsupportedFeature(int type) { 1244 void PDFiumEngine::UnsupportedFeature(int type) {
1251 std::string feature; 1245 std::string feature;
1252 switch (type) { 1246 switch (type) {
1253 #ifndef PDF_USE_XFA 1247 #ifndef PDF_USE_XFA
1254 case FPDF_UNSP_DOC_XFAFORM: 1248 case FPDF_UNSP_DOC_XFAFORM:
1255 feature = "XFA"; 1249 feature = "XFA";
1256 break; 1250 break;
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 last_character_index_to_search_ = old_selection[0].char_index(); 1990 last_character_index_to_search_ = old_selection[0].char_index();
1997 character_to_start_searching_from = old_selection[0].char_index(); 1991 character_to_start_searching_from = old_selection[0].char_index();
1998 last_page_to_search_ = next_page_to_search_; 1992 last_page_to_search_ = next_page_to_search_;
1999 } 1993 }
2000 } 1994 }
2001 1995
2002 int current_page = next_page_to_search_; 1996 int current_page = next_page_to_search_;
2003 1997
2004 if (pages_[current_page]->available()) { 1998 if (pages_[current_page]->available()) {
2005 base::string16 str = base::UTF8ToUTF16(text); 1999 base::string16 str = base::UTF8ToUTF16(text);
2006 // Don't use PDFium to search for now, since it doesn't support unicode text . 2000 // Don't use PDFium to search for now, since it doesn't support unicode
2007 // Leave the code for now to avoid bit-rot, in case it's fixed later. 2001 // text. Leave the code for now to avoid bit-rot, in case it's fixed later.
2008 if (0) { 2002 if (0) {
2009 SearchUsingPDFium( 2003 SearchUsingPDFium(
2010 str, case_sensitive, first_search, character_to_start_searching_from, 2004 str, case_sensitive, first_search, character_to_start_searching_from,
2011 current_page); 2005 current_page);
2012 } else { 2006 } else {
2013 SearchUsingICU( 2007 SearchUsingICU(
2014 str, case_sensitive, first_search, character_to_start_searching_from, 2008 str, case_sensitive, first_search, character_to_start_searching_from,
2015 current_page); 2009 current_page);
2016 } 2010 }
2017 2011
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 2470
2477 // Convert |page_size| back to points. 2471 // Convert |page_size| back to points.
2478 size->set_width( 2472 size->set_width(
2479 ConvertUnit(page_size.width(), kPixelsPerInch, kPointsPerInch)); 2473 ConvertUnit(page_size.width(), kPixelsPerInch, kPointsPerInch));
2480 size->set_height( 2474 size->set_height(
2481 ConvertUnit(page_size.height(), kPixelsPerInch, kPointsPerInch)); 2475 ConvertUnit(page_size.height(), kPixelsPerInch, kPointsPerInch));
2482 return true; 2476 return true;
2483 } 2477 }
2484 2478
2485 void PDFiumEngine::AppendBlankPages(int num_pages) { 2479 void PDFiumEngine::AppendBlankPages(int num_pages) {
2486 DCHECK(num_pages != 0); 2480 DCHECK_NE(num_pages, 0);
2487 2481
2488 if (!doc_) 2482 if (!doc_)
2489 return; 2483 return;
2490 2484
2491 selection_.clear(); 2485 selection_.clear();
2492 pending_pages_.clear(); 2486 pending_pages_.clear();
2493 2487
2494 // Delete all pages except the first one. 2488 // Delete all pages except the first one.
2495 while (pages_.size() > 1) { 2489 while (pages_.size() > 1) {
2496 delete pages_.back(); 2490 delete pages_.back();
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
4019 double* height) { 4013 double* height) {
4020 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 4014 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
4021 if (!doc) 4015 if (!doc)
4022 return false; 4016 return false;
4023 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 4017 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4024 FPDF_CloseDocument(doc); 4018 FPDF_CloseDocument(doc);
4025 return success; 4019 return success;
4026 } 4020 }
4027 4021
4028 } // namespace chrome_pdf 4022 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698