diff options
Diffstat (limited to 'printing/printing_context.cc')
-rw-r--r-- | printing/printing_context.cc | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/printing/printing_context.cc b/printing/printing_context.cc index 98ea11c..edbcaa4 100644 --- a/printing/printing_context.cc +++ b/printing/printing_context.cc @@ -24,7 +24,7 @@ PrintingContext::~PrintingContext() { void PrintingContext::set_margin_type(MarginType type) { DCHECK(type != CUSTOM_MARGINS); - settings_.margin_type = type; + settings_.set_margin_type(type); } void PrintingContext::ResetSettings() { @@ -47,41 +47,31 @@ PrintingContext::Result PrintingContext::UpdatePrintSettings( const PageRanges& ranges) { ResetSettings(); - job_settings.GetBoolean(kSettingHeaderFooterEnabled, - &settings_.display_header_footer); + if (settings_.dpi() == 0) + UseDefaultSettings(); - int margin_type = DEFAULT_MARGINS; - if (!job_settings.GetInteger(kSettingMarginsType, &margin_type) || - (margin_type != DEFAULT_MARGINS && - margin_type != NO_MARGINS && - margin_type != CUSTOM_MARGINS && - margin_type != PRINTABLE_AREA_MARGINS)) { - margin_type = DEFAULT_MARGINS; + if (!PrintSettingsInitializer::InitSettings(job_settings, ranges, + &settings_)) { + NOTREACHED(); + return OnError(); } - settings_.margin_type = static_cast<MarginType>(margin_type); - if (margin_type == CUSTOM_MARGINS) { - printing::PageSizeMargins page_size_margins; - GetCustomMarginsFromJobSettings(job_settings, &page_size_margins); + bool print_to_pdf = false; + bool is_cloud_dialog = false; - PageMargins margins_in_points; - margins_in_points.Clear(); - margins_in_points.top = page_size_margins.margin_top; - margins_in_points.bottom = page_size_margins.margin_bottom; - margins_in_points.left = page_size_margins.margin_left; - margins_in_points.right = page_size_margins.margin_right; - - settings_.SetCustomMargins(margins_in_points); + if (!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || + !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog)) { + NOTREACHED(); + return OnError(); } - PrintingContext::Result result = UpdatePrinterSettings(job_settings, ranges); - PrintSettingsInitializer::InitHeaderFooterStrings(job_settings, &settings_); + bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId); + bool open_in_external_preview = + job_settings.HasKey(kSettingOpenPDFInPreview); - job_settings.GetBoolean(kSettingShouldPrintBackgrounds, - &settings_.should_print_backgrounds); - job_settings.GetBoolean(kSettingShouldPrintSelectionOnly, - &settings_.selection_only); - return result; + return UpdatePrinterSettings( + print_to_pdf || is_cloud_dialog || print_to_cloud, + open_in_external_preview); } } // namespace printing |