summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_basic_module.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-06-19 17:17:54 -0700
committerLei Zhang <thestig@chromium.org>2015-06-19 17:17:54 -0700
commitfa6eb28e08d924271d91758f945ce48a1c2dbf0c (patch)
tree6d4e627b18c5ac50cca976709ae5fb2c01b525c6 /core/src/fpdfapi/fpdf_basic_module.cpp
parente5b0bd1a79f90b7758246655e18ef965a87bcd0b (diff)
downloadpdfium-fa6eb28e08d924271d91758f945ce48a1c2dbf0c.tar.xz
Merge to XFA: Make CPDF_PageModuleDef and CPDF_RenderModuleDef pure virtual.
Get rid of the dummy implementations, which are never used when the modules have been initialized. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1177383003. (cherry picked from commit 5fef754bc09e971f1bf1ba79da98c0a7ee1e1c8d) Review URL: https://codereview.chromium.org/1189413006.
Diffstat (limited to 'core/src/fpdfapi/fpdf_basic_module.cpp')
-rw-r--r--core/src/fpdfapi/fpdf_basic_module.cpp52
1 files changed, 22 insertions, 30 deletions
diff --git a/core/src/fpdfapi/fpdf_basic_module.cpp b/core/src/fpdfapi/fpdf_basic_module.cpp
index 62be616d3d..03cfd66afb 100644
--- a/core/src/fpdfapi/fpdf_basic_module.cpp
+++ b/core/src/fpdfapi/fpdf_basic_module.cpp
@@ -6,50 +6,44 @@
#include "../../include/fxcodec/fx_codec.h"
#include "../../include/fpdfapi/fpdf_module.h"
-static CPDF_ModuleMgr* g_FPDFAPI_pDefaultMgr = NULL;
+
+namespace {
+
+CPDF_ModuleMgr* g_FPDFAPI_pDefaultMgr = nullptr;
+
+const char kAddinNameCJK[] = "Eastern Asian Language Support";
+
+} // namespace
+
+// static
CPDF_ModuleMgr* CPDF_ModuleMgr::Get()
{
return g_FPDFAPI_pDefaultMgr;
}
+
+// static
void CPDF_ModuleMgr::Create()
{
+ ASSERT(!g_FPDFAPI_pDefaultMgr);
g_FPDFAPI_pDefaultMgr = new CPDF_ModuleMgr;
- g_FPDFAPI_pDefaultMgr->Initialize();
}
+
+// static
void CPDF_ModuleMgr::Destroy()
{
- if (g_FPDFAPI_pDefaultMgr) {
- delete g_FPDFAPI_pDefaultMgr;
- }
- g_FPDFAPI_pDefaultMgr = NULL;
+ delete g_FPDFAPI_pDefaultMgr;
+ g_FPDFAPI_pDefaultMgr = nullptr;
}
+
CPDF_ModuleMgr::CPDF_ModuleMgr()
+ : m_pCodecModule(nullptr)
{
- m_pCodecModule = NULL;
- m_pPageModule = NULL;
- m_pRenderModule = NULL;
- m_FileBufSize = 512;
-}
-void CPDF_ModuleMgr::Initialize()
-{
- InitModules();
- m_FileBufSize = 512;
-}
-void CPDF_ModuleMgr::InitModules()
-{
- m_pCodecModule = NULL;
- m_pPageModule = new CPDF_PageModuleDef;
- m_pRenderModule = new CPDF_RenderModuleDef;
}
+
CPDF_ModuleMgr::~CPDF_ModuleMgr()
{
- if (m_pPageModule) {
- delete m_pPageModule;
- }
- if (m_pRenderModule) {
- delete m_pRenderModule;
- }
}
+
void CPDF_ModuleMgr::SetDownloadCallback(FX_BOOL (*callback)(const FX_CHAR* module_name))
{
m_pDownloadCallback = callback;
@@ -63,10 +57,8 @@ FX_BOOL CPDF_ModuleMgr::DownloadModule(const FX_CHAR* module_name)
}
void CPDF_ModuleMgr::NotifyModuleAvailable(const FX_CHAR* module_name)
{
- if (FXSYS_strcmp(module_name, ADDIN_NAME_CJK) == 0) {
+ if (FXSYS_strcmp(module_name, kAddinNameCJK) == 0) {
m_pPageModule->NotifyCJKAvailable();
- } else if (FXSYS_strcmp(module_name, ADDIN_NAME_DECODER) == 0) {
- m_pRenderModule->NotifyDecoderAvailable();
}
}
void CPDF_ModuleMgr::RegisterSecurityHandler(const FX_CHAR* filter, CPDF_SecurityHandler * (*CreateHandler)(void* param), void* param)