Skip to content

Commit

Permalink
Add XPS feature helper functions
Browse files Browse the repository at this point in the history
There are various places in the printing code that need to check if
printing needs to use the GDI or XPS API.  Some printing code is solely
concerned if XPS printing is even a possibility (in particular for
process setup).  Add helper functions to simplify such use cases.

Bug: 1008222
Change-Id: If001018b7bd9615124db21493322fdecbe626573
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032718
Commit-Queue: Alan Screen <awscreen@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745774}
  • Loading branch information
Alan Screen authored and Commit Bot committed Mar 1, 2020
1 parent d693232 commit 28aeff3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions printing/printing_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ const base::Feature kUseXpsForPrinting{"UseXpsForPrinting",
// GDI for modifiable content.
const base::Feature kUseXpsForPrintingFromPdf{
"UseXpsForPrintingFromPdf", base::FEATURE_DISABLED_BY_DEFAULT};

bool IsXpsPrintCapabilityRequired() {
return base::FeatureList::IsEnabled(features::kUseXpsForPrinting) ||
base::FeatureList::IsEnabled(features::kUseXpsForPrintingFromPdf);
}

bool ShouldPrintUsingXps(bool source_is_pdf) {
return base::FeatureList::IsEnabled(source_is_pdf
? features::kUseXpsForPrintingFromPdf
: features::kUseXpsForPrinting);
}
#endif // defined(OS_WIN)

} // namespace features
Expand Down
8 changes: 8 additions & 0 deletions printing/printing_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ PRINTING_EXPORT extern const base::Feature kAdvancedPpdAttributes;
#if defined(OS_WIN)
PRINTING_EXPORT extern const base::Feature kUseXpsForPrinting;
PRINTING_EXPORT extern const base::Feature kUseXpsForPrintingFromPdf;

// Helper function to determine if there is any print path which could require
// the use of XPS print capabilities.
PRINTING_EXPORT bool IsXpsPrintCapabilityRequired();

// Helper function to determine if printing of a document from a particular
// source should be done using XPS printing API instead of with GDI.
PRINTING_EXPORT bool ShouldPrintUsingXps(bool source_is_pdf);
#endif

} // namespace features
Expand Down

0 comments on commit 28aeff3

Please sign in to comment.