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

Side by Side Diff: fpdfsdk/src/fpdfview.cpp

Issue 1269073003: CPDF_Parser shouldnt be in the business of opening files (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 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 | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('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 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../core/include/fxcodec/fx_codec.h" 7 #include "../../core/include/fxcodec/fx_codec.h"
8 #include "../../core/include/fxcrt/fx_safe_types.h" 8 #include "../../core/include/fxcrt/fx_safe_types.h"
9 #include "../../public/fpdf_ext.h" 9 #include "../../public/fpdf_ext.h"
10 #include "../../public/fpdf_progressive.h" 10 #include "../../public/fpdf_progressive.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 break; 148 break;
149 } 149 }
150 SetLastError(err_code); 150 SetLastError(err_code);
151 } 151 }
152 152
153 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, 153 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
154 FPDF_BOOL enable) { 154 FPDF_BOOL enable) {
155 return FSDK_SetSandBoxPolicy(policy, enable); 155 return FSDK_SetSandBoxPolicy(policy, enable);
156 } 156 }
157 157
158
158 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, 159 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
159 FPDF_BYTESTRING password) { 160 FPDF_BYTESTRING password) {
161 // NOTE: the creation of the file needs to be by the embedder on the
162 // other side of this API.
163 IFX_FileRead* pFileAccess = FX_CreateFileRead((const FX_CHAR*)file_path);
164 if (!pFileAccess) {
165 return nullptr;
166 }
167
160 CPDF_Parser* pParser = new CPDF_Parser; 168 CPDF_Parser* pParser = new CPDF_Parser;
161 pParser->SetPassword(password); 169 pParser->SetPassword(password);
162 170
163 FX_DWORD err_code = pParser->StartParse((const FX_CHAR*)file_path); 171 FX_DWORD err_code = pParser->StartParse(pFileAccess);
164 if (err_code) { 172 if (err_code) {
165 delete pParser; 173 delete pParser;
166 ProcessParseError(err_code); 174 ProcessParseError(err_code);
167 return NULL; 175 return NULL;
168 } 176 }
169 return pParser->GetDocument(); 177 return pParser->GetDocument();
170 } 178 }
171 179
172 extern void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code); 180 extern void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code);
173 181
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 if (!buffer) { 908 if (!buffer) {
901 *buflen = len; 909 *buflen = len;
902 } else if (*buflen >= len) { 910 } else if (*buflen >= len) {
903 memcpy(buffer, utf16Name.c_str(), len); 911 memcpy(buffer, utf16Name.c_str(), len);
904 *buflen = len; 912 *buflen = len;
905 } else { 913 } else {
906 *buflen = -1; 914 *buflen = -1;
907 } 915 }
908 return (FPDF_DEST)pDestObj; 916 return (FPDF_DEST)pDestObj;
909 } 917 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698