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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_parser.cpp

Issue 1898173002: Remove IPDF_CryptoHandler and IPDF_SecurityHandler. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/fpdfapi/fpdf_parser/include/cpdf_parser.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h" 11 #include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
12 #include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
12 #include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h" 13 #include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h"
13 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" 14 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
17 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" 18 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
18 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" 19 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
19 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" 20 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
20 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" 21 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
21 #include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h"
22 #include "core/fxcrt/include/fx_ext.h" 22 #include "core/fxcrt/include/fx_ext.h"
23 #include "core/fxcrt/include/fx_safe_types.h" 23 #include "core/fxcrt/include/fx_safe_types.h"
24 #include "third_party/base/stl_util.h" 24 #include "third_party/base/stl_util.h"
25 25
26 namespace { 26 namespace {
27 27
28 // A limit on the size of the xref table. Theoretical limits are higher, but 28 // A limit on the size of the xref table. Theoretical limits are higher, but
29 // this may be large enough in practice. 29 // this may be large enough in practice.
30 const int32_t kMaxXRefSize = 1048576; 30 const int32_t kMaxXRefSize = 1048576;
31 31
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 bool CPDF_Parser::IsObjectFreeOrNull(uint32_t objnum) const { 95 bool CPDF_Parser::IsObjectFreeOrNull(uint32_t objnum) const {
96 uint8_t type = GetObjectType(objnum); 96 uint8_t type = GetObjectType(objnum);
97 return type == 0 || type == 255; 97 return type == 0 || type == 255;
98 } 98 }
99 99
100 void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) { 100 void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) {
101 m_pEncryptDict = pDict; 101 m_pEncryptDict = pDict;
102 } 102 }
103 103
104 IPDF_CryptoHandler* CPDF_Parser::GetCryptoHandler() { 104 CPDF_CryptoHandler* CPDF_Parser::GetCryptoHandler() {
105 return m_pSyntax->m_pCryptoHandler.get(); 105 return m_pSyntax->m_pCryptoHandler.get();
106 } 106 }
107 107
108 IFX_FileRead* CPDF_Parser::GetFileAccess() const { 108 IFX_FileRead* CPDF_Parser::GetFileAccess() const {
109 return m_pSyntax->m_pFileAccess; 109 return m_pSyntax->m_pFileAccess;
110 } 110 }
111 111
112 void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) { 112 void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) {
113 if (objnum == 0) { 113 if (objnum == 0) {
114 m_ObjectInfo.clear(); 114 m_ObjectInfo.clear();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 SetEncryptDictionary(pEncryptDict); 268 SetEncryptDictionary(pEncryptDict);
269 } else if (CPDF_Reference* pRef = pEncryptObj->AsReference()) { 269 } else if (CPDF_Reference* pRef = pEncryptObj->AsReference()) {
270 pEncryptObj = m_pDocument->GetIndirectObject(pRef->GetRefObjNum()); 270 pEncryptObj = m_pDocument->GetIndirectObject(pRef->GetRefObjNum());
271 if (pEncryptObj) 271 if (pEncryptObj)
272 SetEncryptDictionary(pEncryptObj->GetDict()); 272 SetEncryptDictionary(pEncryptObj->GetDict());
273 } 273 }
274 } 274 }
275 275
276 if (m_pEncryptDict) { 276 if (m_pEncryptDict) {
277 CFX_ByteString filter = m_pEncryptDict->GetStringBy("Filter"); 277 CFX_ByteString filter = m_pEncryptDict->GetStringBy("Filter");
278 std::unique_ptr<IPDF_SecurityHandler> pSecurityHandler; 278 std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler;
279 Error err = HANDLER_ERROR; 279 Error err = HANDLER_ERROR;
280 if (filter == "Standard") { 280 if (filter == "Standard") {
281 pSecurityHandler.reset(new CPDF_StandardSecurityHandler); 281 pSecurityHandler.reset(new CPDF_SecurityHandler);
282 err = PASSWORD_ERROR; 282 err = PASSWORD_ERROR;
283 } 283 }
284 if (!pSecurityHandler) 284 if (!pSecurityHandler)
285 return HANDLER_ERROR; 285 return HANDLER_ERROR;
286 286
287 if (!pSecurityHandler->OnInit(this, m_pEncryptDict)) 287 if (!pSecurityHandler->OnInit(this, m_pEncryptDict))
288 return err; 288 return err;
289 289
290 m_pSecurityHandler = std::move(pSecurityHandler); 290 m_pSecurityHandler = std::move(pSecurityHandler);
291 std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler( 291 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler(
292 m_pSecurityHandler->CreateCryptoHandler()); 292 m_pSecurityHandler->CreateCryptoHandler());
293 if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) 293 if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get()))
294 return HANDLER_ERROR; 294 return HANDLER_ERROR;
295 m_pSyntax->SetEncrypt(std::move(pCryptoHandler)); 295 m_pSyntax->SetEncrypt(std::move(pCryptoHandler));
296 } 296 }
297 return SUCCESS; 297 return SUCCESS;
298 } 298 }
299 299
300 void CPDF_Parser::ReleaseEncryptHandler() { 300 void CPDF_Parser::ReleaseEncryptHandler() {
301 m_pSyntax->m_pCryptoHandler.reset(); 301 m_pSyntax->m_pCryptoHandler.reset();
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) && 1642 if (!LoadLinearizedAllCrossRefV4(m_LastXRefOffset, m_dwXrefStartObjNum) &&
1643 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) { 1643 !LoadLinearizedAllCrossRefV5(m_LastXRefOffset)) {
1644 m_LastXRefOffset = 0; 1644 m_LastXRefOffset = 0;
1645 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1645 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1646 return FORMAT_ERROR; 1646 return FORMAT_ERROR;
1647 } 1647 }
1648 1648
1649 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum; 1649 m_pSyntax->m_MetadataObjnum = dwSaveMetadataObjnum;
1650 return SUCCESS; 1650 return SUCCESS;
1651 } 1651 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698