forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split unsupported features code out of pdfium_engine.cc.
Change-Id: I39005eb8a1c016a6b402fdac3c6484d6db430bb1 Reviewed-on: https://chromium-review.googlesource.com/1081196 Reviewed-by: dsinclair <[email protected]> Commit-Queue: Lei Zhang <[email protected]> Cr-Commit-Position: refs/heads/master@{#563371}
- Loading branch information
Showing
7 changed files
with
131 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "pdf/pdfium/pdfium_unsupported_features.h" | ||
|
||
#include "base/logging.h" | ||
#include "pdf/pdfium/pdfium_engine.h" | ||
#include "third_party/pdfium/public/fpdf_ext.h" | ||
|
||
namespace chrome_pdf { | ||
|
||
namespace { | ||
|
||
PDFiumEngine* g_engine_for_unsupported = nullptr; | ||
|
||
void Unsupported_Handler(UNSUPPORT_INFO*, int type) { | ||
if (!g_engine_for_unsupported) { | ||
NOTREACHED(); | ||
return; | ||
} | ||
|
||
std::string feature; | ||
switch (type) { | ||
case FPDF_UNSP_DOC_XFAFORM: | ||
feature = "XFA"; | ||
break; | ||
case FPDF_UNSP_DOC_PORTABLECOLLECTION: | ||
feature = "Portfolios_Packages"; | ||
break; | ||
case FPDF_UNSP_DOC_ATTACHMENT: | ||
case FPDF_UNSP_ANNOT_ATTACHMENT: | ||
feature = "Attachment"; | ||
break; | ||
case FPDF_UNSP_DOC_SECURITY: | ||
feature = "Rights_Management"; | ||
break; | ||
case FPDF_UNSP_DOC_SHAREDREVIEW: | ||
feature = "Shared_Review"; | ||
break; | ||
case FPDF_UNSP_DOC_SHAREDFORM_ACROBAT: | ||
case FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM: | ||
case FPDF_UNSP_DOC_SHAREDFORM_EMAIL: | ||
feature = "Shared_Form"; | ||
break; | ||
case FPDF_UNSP_ANNOT_3DANNOT: | ||
feature = "3D"; | ||
break; | ||
case FPDF_UNSP_ANNOT_MOVIE: | ||
feature = "Movie"; | ||
break; | ||
case FPDF_UNSP_ANNOT_SOUND: | ||
feature = "Sound"; | ||
break; | ||
case FPDF_UNSP_ANNOT_SCREEN_MEDIA: | ||
case FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA: | ||
feature = "Screen"; | ||
break; | ||
case FPDF_UNSP_ANNOT_SIG: | ||
feature = "Digital_Signature"; | ||
break; | ||
} | ||
|
||
g_engine_for_unsupported->UnsupportedFeature(feature); | ||
} | ||
|
||
UNSUPPORT_INFO g_unsupported_info = {1, Unsupported_Handler}; | ||
|
||
} // namespace | ||
|
||
void InitializeUnsupportedFeaturesHandler() { | ||
FSDK_SetUnSpObjProcessHandler(&g_unsupported_info); | ||
} | ||
|
||
ScopedUnsupportedFeature::ScopedUnsupportedFeature(PDFiumEngine* engine) | ||
: old_engine_(g_engine_for_unsupported) { | ||
g_engine_for_unsupported = engine; | ||
} | ||
|
||
ScopedUnsupportedFeature::~ScopedUnsupportedFeature() { | ||
g_engine_for_unsupported = old_engine_; | ||
} | ||
|
||
} // namespace chrome_pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef PDF_PDFIUM_PDFIUM_UNSUPPORTED_FEATURES_H_ | ||
#define PDF_PDFIUM_PDFIUM_UNSUPPORTED_FEATURES_H_ | ||
|
||
#include "base/macros.h" | ||
|
||
namespace chrome_pdf { | ||
|
||
class PDFiumEngine; | ||
|
||
void InitializeUnsupportedFeaturesHandler(); | ||
|
||
// Create a local variable of this when calling PDFium functions which can call | ||
// our global callback when an unsupported feature is reached. | ||
class ScopedUnsupportedFeature { | ||
public: | ||
explicit ScopedUnsupportedFeature(PDFiumEngine* engine); | ||
~ScopedUnsupportedFeature(); | ||
|
||
private: | ||
PDFiumEngine* const old_engine_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(ScopedUnsupportedFeature); | ||
}; | ||
|
||
} // namespace chrome_pdf | ||
|
||
#endif // PDF_PDFIUM_PDFIUM_UNSUPPORTED_FEATURES_H_ |