1// Copyright 2016 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef CORE_FPDFAPI_CPDF_MODULEMGR_H_
8#define CORE_FPDFAPI_CPDF_MODULEMGR_H_
9
10#include <memory>
11#include <utility>
12
13#include "core/fxcrt/fx_basic.h"
14
15class CCodec_FaxModule;
16class CCodec_FlateModule;
17class CCodec_IccModule;
18class CCodec_Jbig2Module;
19class CCodec_JpegModule;
20class CCodec_JpxModule;
21class CCodec_ModuleMgr;
22class CPDF_PageModule;
23
24class CFSDK_UnsupportInfo_Adapter {
25 public:
26  explicit CFSDK_UnsupportInfo_Adapter(void* unsp_info)
27      : m_unsp_info(unsp_info) {}
28
29  void* GetUnspInfo() const { return m_unsp_info; }
30
31 private:
32  void* const m_unsp_info;
33};
34
35class CPDF_ModuleMgr {
36 public:
37  static CPDF_ModuleMgr* Get();
38  static void Destroy();
39  static const int kFileBufSize = 512;
40
41  void SetCodecModule(CCodec_ModuleMgr* pModule) { m_pCodecModule = pModule; }
42  CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; }
43
44  void InitPageModule();
45  CPDF_PageModule* GetPageModule() const { return m_pPageModule.get(); }
46
47  void SetUnsupportInfoAdapter(
48      std::unique_ptr<CFSDK_UnsupportInfo_Adapter> pAdapter) {
49    m_pUnsupportInfoAdapter = std::move(pAdapter);
50  }
51  CFSDK_UnsupportInfo_Adapter* GetUnsupportInfoAdapter() const {
52    return m_pUnsupportInfoAdapter.get();
53  }
54
55  void LoadEmbeddedGB1CMaps();
56  void LoadEmbeddedCNS1CMaps();
57  void LoadEmbeddedJapan1CMaps();
58  void LoadEmbeddedKorea1CMaps();
59
60  CCodec_FaxModule* GetFaxModule();
61  CCodec_JpegModule* GetJpegModule();
62  CCodec_JpxModule* GetJpxModule();
63  CCodec_Jbig2Module* GetJbig2Module();
64  CCodec_IccModule* GetIccModule();
65  CCodec_FlateModule* GetFlateModule();
66
67 private:
68  CPDF_ModuleMgr();
69  ~CPDF_ModuleMgr();
70
71  CCodec_ModuleMgr* m_pCodecModule;
72  std::unique_ptr<CPDF_PageModule> m_pPageModule;
73  std::unique_ptr<CFSDK_UnsupportInfo_Adapter> m_pUnsupportInfoAdapter;
74};
75
76#endif  // CORE_FPDFAPI_CPDF_MODULEMGR_H_
77