diff options
author | dsinclair <dsinclair@chromium.org> | 2016-04-19 10:32:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-19 10:32:46 -0700 |
commit | 2fa0e13ec2a79cc85d5e018a6420e677b28160cc (patch) | |
tree | 246f2790f5f36af8971994adde0dd72d940e8c86 /core/fpdfapi/fpdf_edit | |
parent | 0582ad18b1e7ab9e404b7f8071a015ec756f5afe (diff) | |
download | pdfium-2fa0e13ec2a79cc85d5e018a6420e677b28160cc.tar.xz |
Remove IPDF_CryptoHandler and IPDF_SecurityHandler.
This CL replaces the interfaces with the concrete classes. The concrete classes
are also renamed to remove the Standard from their names.
BUG=pdfium:468
Review URL: https://codereview.chromium.org/1898173002
Diffstat (limited to 'core/fpdfapi/fpdf_edit')
-rw-r--r-- | core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 22 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_edit/include/cpdf_creator.h | 6 |
2 files changed, 14 insertions, 14 deletions
diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 0bd07a1819..7570a796e4 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -9,8 +9,8 @@ #include <vector> #include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" -#include "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h" -#include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h" +#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h" +#include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" @@ -20,7 +20,6 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" -#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h" #include "core/fxcrt/include/fx_ext.h" #include "third_party/base/stl_util.h" @@ -479,7 +478,7 @@ class CPDF_Encryptor { public: CPDF_Encryptor(); ~CPDF_Encryptor(); - FX_BOOL Initialize(IPDF_CryptoHandler* pHandler, + FX_BOOL Initialize(CPDF_CryptoHandler* pHandler, int objnum, uint8_t* src_data, uint32_t src_size); @@ -492,7 +491,7 @@ CPDF_Encryptor::CPDF_Encryptor() { m_dwSize = 0; m_bNewBuf = FALSE; } -FX_BOOL CPDF_Encryptor::Initialize(IPDF_CryptoHandler* pHandler, +FX_BOOL CPDF_Encryptor::Initialize(CPDF_CryptoHandler* pHandler, int objnum, uint8_t* src_data, uint32_t src_size) { @@ -549,7 +548,7 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) { return 0; } CFX_FileBufferArchive* pFile = &pCreator->m_File; - IPDF_CryptoHandler* pHandler = pCreator->m_pCryptoHandler; + CPDF_CryptoHandler* pHandler = pCreator->m_pCryptoHandler; FX_FILESIZE ObjOffset = pCreator->m_Offset; if (!m_dwObjNum) { m_dwObjNum = ++pCreator->m_dwLastObjNum; @@ -1025,7 +1024,7 @@ int32_t CPDF_Creator::AppendObjectNumberToXRef(uint32_t objnum) { } int32_t CPDF_Creator::WriteStream(const CPDF_Object* pStream, uint32_t objnum, - IPDF_CryptoHandler* pCrypto) { + CPDF_CryptoHandler* pCrypto) { CPDF_FlateEncoder encoder; encoder.Initialize(const_cast<CPDF_Stream*>(pStream->AsStream()), pStream == m_pMetadata ? FALSE : m_bCompress); @@ -1068,7 +1067,7 @@ int32_t CPDF_Creator::WriteIndirectObj(uint32_t objnum, m_Offset += len; if (pObj->IsStream()) { - IPDF_CryptoHandler* pHandler = nullptr; + CPDF_CryptoHandler* pHandler = nullptr; pHandler = (pObj == m_pMetadata && !m_bEncryptMetadata) ? NULL : m_pCryptoHandler; if (WriteStream(pObj, objnum, pHandler) < 0) @@ -1148,7 +1147,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum, encoder.Initialize(const_cast<CPDF_Stream*>(pObj->AsStream()), m_bCompress); CPDF_Encryptor encryptor; - IPDF_CryptoHandler* pHandler = m_pCryptoHandler; + CPDF_CryptoHandler* pHandler = m_pCryptoHandler; encryptor.Initialize(pHandler, objnum, encoder.m_pData, encoder.m_dwSize); if ((uint32_t)encoder.m_pDict->GetIntegerBy("Length") != encryptor.m_dwSize) { @@ -2008,15 +2007,16 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) { m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone()); if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) { if (m_pEncryptDict->GetStringBy("Filter") == "Standard") { - CPDF_StandardSecurityHandler handler; CFX_ByteString user_pass = m_pParser->GetPassword(); uint32_t flag = PDF_ENCRYPT_CONTENT; + + CPDF_SecurityHandler handler; handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(), user_pass.GetLength(), flag); if (m_bNewCrypto) { delete m_pCryptoHandler; } - m_pCryptoHandler = new CPDF_StandardCryptoHandler; + m_pCryptoHandler = new CPDF_CryptoHandler; m_pCryptoHandler->Init(m_pEncryptDict, &handler); m_bNewCrypto = TRUE; m_bSecurityChanged = TRUE; diff --git a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h index d6a1c1079a..e9490a3be7 100644 --- a/core/fpdfapi/fpdf_edit/include/cpdf_creator.h +++ b/core/fpdfapi/fpdf_edit/include/cpdf_creator.h @@ -10,12 +10,12 @@ #include "core/fxcrt/include/fx_basic.h" class CPDF_Array; +class CPDF_CryptoHandler; class CPDF_Dictionary; class CPDF_Document; class CPDF_Object; class CPDF_Parser; class CPDF_XRefStream; -class IPDF_CryptoHandler; #define FPDFCREATE_INCREMENTAL 1 #define FPDFCREATE_NO_ORIGINAL 2 @@ -69,7 +69,7 @@ class CPDF_Creator { int32_t WriteStream(const CPDF_Object* pStream, uint32_t objnum, - IPDF_CryptoHandler* pCrypto); + CPDF_CryptoHandler* pCrypto); CPDF_Document* m_pDocument; CPDF_Parser* m_pParser; @@ -79,7 +79,7 @@ class CPDF_Creator { uint32_t m_dwEnryptObjNum; FX_BOOL m_bEncryptCloned; FX_BOOL m_bStandardSecurity; - IPDF_CryptoHandler* m_pCryptoHandler; + CPDF_CryptoHandler* m_pCryptoHandler; FX_BOOL m_bNewCrypto; FX_BOOL m_bEncryptMetadata; CPDF_Object* m_pMetadata; |