Chromium Code Reviews| Index: pdf/pdfium/pdfium_engine.cc |
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
| index 4b279462043f0ec0d381973849d26b5f089a255a..3189c546a1177573c9eb4d1a41c37e4c16ed1ac5 100644 |
| --- a/pdf/pdfium/pdfium_engine.cc |
| +++ b/pdf/pdfium/pdfium_engine.cc |
| @@ -592,6 +592,7 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) |
| last_page_to_search_(-1), |
| last_character_index_to_search_(-1), |
| permissions_(0), |
| + permissions_handler_revision_(-1), |
| fpdf_availability_(NULL), |
| next_timer_id_(0), |
| last_page_mouse_down_(-1), |
| @@ -2324,16 +2325,30 @@ bool PDFiumEngine::IsSelecting() { |
| } |
| bool PDFiumEngine::HasPermission(DocumentPermission permission) const { |
|
raymes
2015/06/09 00:32:59
Is it worth checking that this is not -1?
Lei Zhang
2015/06/09 00:39:41
I'm interpreting -1 as unknown and treating it as
|
| + // PDF 1.7 spec, section 3.5.2 says: "If the revision number is 2 or greater, |
| + // the operations to which user access can be controlled are as follows: ..." |
| + // |
| + // Thus for revision numbers less than 2, permissions are ignored and this |
| + // always returns true. |
| + if (permissions_handler_revision_ < 2) |
| + return true; |
| + |
| + // Handle high quality printing permission separately for security handler |
| + // revision 3+. |
| + if (permission == PERMISSION_PRINT_HIGH_QUALITY && |
| + permissions_handler_revision_ >= 3) { |
| + return (permissions_ & kPDFPermissionPrintLowQualityMask) != 0 && |
| + (permissions_ & kPDFPermissionPrintHighQualityMask) != 0; |
| + } |
| + |
| switch (permission) { |
| case PERMISSION_COPY: |
| return (permissions_ & kPDFPermissionCopyMask) != 0; |
| case PERMISSION_COPY_ACCESSIBLE: |
| return (permissions_ & kPDFPermissionCopyAccessibleMask) != 0; |
| case PERMISSION_PRINT_LOW_QUALITY: |
| - return (permissions_ & kPDFPermissionPrintLowQualityMask) != 0; |
| case PERMISSION_PRINT_HIGH_QUALITY: |
|
raymes
2015/06/09 00:32:59
So I guess that if the revision is <3 then you onl
Lei Zhang
2015/06/09 00:39:41
Sure.
|
| - return (permissions_ & kPDFPermissionPrintLowQualityMask) != 0 && |
| - (permissions_ & kPDFPermissionPrintHighQualityMask) != 0; |
| + return (permissions_ & kPDFPermissionPrintLowQualityMask) != 0; |
| default: |
| return true; |
| } |
| @@ -2622,6 +2637,7 @@ void PDFiumEngine::ContinueLoadingDocument( |
| client_->DocumentHasUnsupportedFeature("Bookmarks"); |
| permissions_ = FPDF_GetDocPermissions(doc_); |
| + permissions_handler_revision_ = FPDF_GetSecurityHandlerRevision(doc_); |
| if (!form_) { |
| // Only returns 0 when data isn't available. If form data is downloaded, or |