summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-08-05 10:50:32 -0700
committerTom Sepez <tsepez@chromium.org>2015-08-05 10:50:32 -0700
commite3166a8c39c8943f6cafb2ffe10bd9564e3eaf16 (patch)
treeb3eba839499ea71bbd1fcbc0d659d0aecafd506e
parent18d0aafda2d4984f510f4f679bfc5393c2c8a81b (diff)
downloadpdfium-e3166a8c39c8943f6cafb2ffe10bd9564e3eaf16.tar.xz
Merge to XFA: CPDF_Parser shouldnt be in the business of opening files
(cherry picked from commit 2b9178181eb82a3611bee5c9435ea5956def24be) Orignal Review URL: https://codereview.chromium.org/1269073003 . TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1278533002 .
-rw-r--r--core/include/fpdfapi/fpdf_parser.h2
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp14
-rw-r--r--fpdfsdk/src/fpdfview.cpp12
3 files changed, 10 insertions, 18 deletions
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index f80bb24a87..7640c857fa 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -355,8 +355,6 @@ class CPDF_Parser {
CPDF_Parser();
~CPDF_Parser();
- FX_DWORD StartParse(const FX_CHAR* filename, FX_BOOL bReParse = FALSE);
- FX_DWORD StartParse(const FX_WCHAR* filename, FX_BOOL bReParse = FALSE);
FX_DWORD StartParse(IFX_FileRead* pFile,
FX_BOOL bReParse = FALSE,
FX_BOOL bOwnFileRead = TRUE);
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index ad4d45908d..714db002de 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -119,20 +119,6 @@ static int32_t GetHeaderOffset(IFX_FileRead* pFile) {
}
return -1;
}
-FX_DWORD CPDF_Parser::StartParse(const FX_CHAR* filename, FX_BOOL bReParse) {
- IFX_FileRead* pFileAccess = FX_CreateFileRead(filename);
- if (!pFileAccess) {
- return PDFPARSE_ERROR_FILE;
- }
- return StartParse(pFileAccess, bReParse);
-}
-FX_DWORD CPDF_Parser::StartParse(const FX_WCHAR* filename, FX_BOOL bReParse) {
- IFX_FileRead* pFileAccess = FX_CreateFileRead(filename);
- if (!pFileAccess) {
- return PDFPARSE_ERROR_FILE;
- }
- return StartParse(pFileAccess, bReParse);
-}
CPDF_SecurityHandler* FPDF_CreateStandardSecurityHandler();
CPDF_SecurityHandler* FPDF_CreatePubKeyHandler(void*);
FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess,
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 159440de59..38a51f9ce2 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -237,12 +237,20 @@ DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
return FSDK_SetSandBoxPolicy(policy, enable);
}
+
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
FPDF_BYTESTRING password) {
- CPDF_Parser* pParser = FX_NEW CPDF_Parser;
+ // NOTE: the creation of the file needs to be by the embedder on the
+ // other side of this API.
+ IFX_FileRead* pFileAccess = FX_CreateFileRead((const FX_CHAR*)file_path);
+ if (!pFileAccess) {
+ return nullptr;
+ }
+
+ CPDF_Parser* pParser = new CPDF_Parser;
pParser->SetPassword(password);
- FX_DWORD err_code = pParser->StartParse((const FX_CHAR*)file_path);
+ FX_DWORD err_code = pParser->StartParse(pFileAccess);
if (err_code) {
delete pParser;
ProcessParseError(err_code);