OLD | NEW |
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 "../../include/fxcodec/fx_codec.h" | 7 #include "../../include/fxcodec/fx_codec.h" |
8 #include "../../include/fpdfapi/fpdf_module.h" | 8 #include "../../include/fpdfapi/fpdf_module.h" |
9 static CPDF_ModuleMgr* g_FPDFAPI_pDefaultMgr = NULL; | 9 static CPDF_ModuleMgr* g_FPDFAPI_pDefaultMgr = NULL; |
10 CPDF_ModuleMgr* CPDF_ModuleMgr::Get() | 10 CPDF_ModuleMgr* CPDF_ModuleMgr::Get() |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 CPDF_ModuleMgr::~CPDF_ModuleMgr() | 44 CPDF_ModuleMgr::~CPDF_ModuleMgr() |
45 { | 45 { |
46 if (m_pPageModule) { | 46 if (m_pPageModule) { |
47 delete m_pPageModule; | 47 delete m_pPageModule; |
48 } | 48 } |
49 if (m_pRenderModule) { | 49 if (m_pRenderModule) { |
50 delete m_pRenderModule; | 50 delete m_pRenderModule; |
51 } | 51 } |
52 } | 52 } |
53 void CPDF_ModuleMgr::SetDownloadCallback(FX_BOOL (*callback)(FX_LPCSTR module_na
me)) | 53 void CPDF_ModuleMgr::SetDownloadCallback(FX_BOOL (*callback)(const FX_CHAR* modu
le_name)) |
54 { | 54 { |
55 m_pDownloadCallback = callback; | 55 m_pDownloadCallback = callback; |
56 } | 56 } |
57 FX_BOOL CPDF_ModuleMgr::DownloadModule(FX_LPCSTR module_name) | 57 FX_BOOL CPDF_ModuleMgr::DownloadModule(const FX_CHAR* module_name) |
58 { | 58 { |
59 if (m_pDownloadCallback == NULL) { | 59 if (m_pDownloadCallback == NULL) { |
60 return FALSE; | 60 return FALSE; |
61 } | 61 } |
62 return m_pDownloadCallback(module_name); | 62 return m_pDownloadCallback(module_name); |
63 } | 63 } |
64 void CPDF_ModuleMgr::NotifyModuleAvailable(FX_LPCSTR module_name) | 64 void CPDF_ModuleMgr::NotifyModuleAvailable(const FX_CHAR* module_name) |
65 { | 65 { |
66 if (FXSYS_strcmp(module_name, ADDIN_NAME_CJK) == 0) { | 66 if (FXSYS_strcmp(module_name, ADDIN_NAME_CJK) == 0) { |
67 m_pPageModule->NotifyCJKAvailable(); | 67 m_pPageModule->NotifyCJKAvailable(); |
68 } else if (FXSYS_strcmp(module_name, ADDIN_NAME_DECODER) == 0) { | 68 } else if (FXSYS_strcmp(module_name, ADDIN_NAME_DECODER) == 0) { |
69 m_pRenderModule->NotifyDecoderAvailable(); | 69 m_pRenderModule->NotifyDecoderAvailable(); |
70 } | 70 } |
71 } | 71 } |
72 void CPDF_ModuleMgr::RegisterSecurityHandler(FX_LPCSTR filter, CPDF_SecurityHand
ler * (*CreateHandler)(void* param), void* param) | 72 void CPDF_ModuleMgr::RegisterSecurityHandler(const FX_CHAR* filter, CPDF_Securit
yHandler * (*CreateHandler)(void* param), void* param) |
73 { | 73 { |
74 if (CreateHandler == NULL) { | 74 if (CreateHandler == NULL) { |
75 m_SecurityHandlerMap.RemoveKey(filter); | 75 m_SecurityHandlerMap.RemoveKey(filter); |
76 } else { | 76 } else { |
77 m_SecurityHandlerMap.SetAt(filter, (void*)CreateHandler); | 77 m_SecurityHandlerMap.SetAt(filter, (void*)CreateHandler); |
78 } | 78 } |
79 if (param) { | 79 if (param) { |
80 m_SecurityHandlerMap.SetAt(FX_BSTRC("_param_") + filter, param); | 80 m_SecurityHandlerMap.SetAt(FX_BSTRC("_param_") + filter, param); |
81 } | 81 } |
82 } | 82 } |
83 void CPDF_ModuleMgr::SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CAL
LBACK_FREEDATA callback) | 83 void CPDF_ModuleMgr::SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FR
EEDATA callback) |
84 { | 84 { |
85 m_privateData.SetPrivateData(module_id, pData, callback); | 85 m_privateData.SetPrivateData(module_id, pData, callback); |
86 } | 86 } |
87 FX_LPVOID CPDF_ModuleMgr::GetPrivateData(FX_LPVOID module_id) | 87 void* CPDF_ModuleMgr::GetPrivateData(void* module_id) |
88 { | 88 { |
89 return m_privateData.GetPrivateData(module_id); | 89 return m_privateData.GetPrivateData(module_id); |
90 } | 90 } |
91 CPDF_SecurityHandler* CPDF_ModuleMgr::CreateSecurityHandler(FX_LPCSTR filter) | 91 CPDF_SecurityHandler* CPDF_ModuleMgr::CreateSecurityHandler(const FX_CHAR* filte
r) |
92 { | 92 { |
93 CPDF_SecurityHandler* (*CreateHandler)(void*) = NULL; | 93 CPDF_SecurityHandler* (*CreateHandler)(void*) = NULL; |
94 if (!m_SecurityHandlerMap.Lookup(filter, (void*&)CreateHandler)) { | 94 if (!m_SecurityHandlerMap.Lookup(filter, (void*&)CreateHandler)) { |
95 return NULL; | 95 return NULL; |
96 } | 96 } |
97 if (CreateHandler == NULL) { | 97 if (CreateHandler == NULL) { |
98 return NULL; | 98 return NULL; |
99 } | 99 } |
100 void* param = NULL; | 100 void* param = NULL; |
101 m_SecurityHandlerMap.Lookup(FX_BSTRC("_param_") + filter, param); | 101 m_SecurityHandlerMap.Lookup(FX_BSTRC("_param_") + filter, param); |
(...skipping 16 matching lines...) Expand all Loading... |
118 return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : NULL; | 118 return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : NULL; |
119 } | 119 } |
120 ICodec_IccModule* CPDF_ModuleMgr::GetIccModule() | 120 ICodec_IccModule* CPDF_ModuleMgr::GetIccModule() |
121 { | 121 { |
122 return m_pCodecModule ? m_pCodecModule->GetIccModule() : NULL; | 122 return m_pCodecModule ? m_pCodecModule->GetIccModule() : NULL; |
123 } | 123 } |
124 ICodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() | 124 ICodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() |
125 { | 125 { |
126 return m_pCodecModule ? m_pCodecModule->GetFlateModule() : NULL; | 126 return m_pCodecModule ? m_pCodecModule->GetFlateModule() : NULL; |
127 } | 127 } |
OLD | NEW |