OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "printing/printing_context.h" | 5 #include "printing/printing_context.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "printing/page_setup.h" | 9 #include "printing/page_setup.h" |
10 #include "printing/page_size_margins.h" | 10 #include "printing/page_size_margins.h" |
11 #include "printing/print_job_constants.h" | 11 #include "printing/print_job_constants.h" |
12 #include "printing/print_settings_initializer.h" | 12 #include "printing/print_settings_conversion.h" |
13 #include "printing/units.h" | 13 #include "printing/units.h" |
14 | 14 |
15 namespace printing { | 15 namespace printing { |
16 | 16 |
17 namespace { | 17 namespace { |
18 const float kCloudPrintMarginInch = 0.25; | 18 const float kCloudPrintMarginInch = 0.25; |
19 } | 19 } |
20 | 20 |
21 PrintingContext::PrintingContext(const std::string& app_locale) | 21 PrintingContext::PrintingContext(const std::string& app_locale) |
22 : dialog_box_dismissed_(false), | 22 : dialog_box_dismissed_(false), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 pdf_settings->SetInteger(kSettingMarginsType, printing::NO_MARGINS); | 56 pdf_settings->SetInteger(kSettingMarginsType, printing::NO_MARGINS); |
57 pdf_settings->SetBoolean(kSettingCollate, true); | 57 pdf_settings->SetBoolean(kSettingCollate, true); |
58 pdf_settings->SetInteger(kSettingCopies, 1); | 58 pdf_settings->SetInteger(kSettingCopies, 1); |
59 pdf_settings->SetInteger(kSettingColor, printing::COLOR); | 59 pdf_settings->SetInteger(kSettingColor, printing::COLOR); |
60 pdf_settings->SetInteger(kSettingDuplexMode, printing::SIMPLEX); | 60 pdf_settings->SetInteger(kSettingDuplexMode, printing::SIMPLEX); |
61 pdf_settings->SetBoolean(kSettingLandscape, false); | 61 pdf_settings->SetBoolean(kSettingLandscape, false); |
62 pdf_settings->SetString(kSettingDeviceName, ""); | 62 pdf_settings->SetString(kSettingDeviceName, ""); |
63 pdf_settings->SetBoolean(kSettingPrintToPDF, true); | 63 pdf_settings->SetBoolean(kSettingPrintToPDF, true); |
64 pdf_settings->SetBoolean(kSettingCloudPrintDialog, false); | 64 pdf_settings->SetBoolean(kSettingCloudPrintDialog, false); |
65 pdf_settings->SetBoolean(kSettingPrintWithPrivet, false); | 65 pdf_settings->SetBoolean(kSettingPrintWithPrivet, false); |
66 return UpdatePrintSettings(*pdf_settings, PageRanges()); | 66 return UpdatePrintSettings(*pdf_settings); |
67 } | 67 } |
68 | 68 |
69 PrintingContext::Result PrintingContext::UpdatePrintSettings( | 69 PrintingContext::Result PrintingContext::UpdatePrintSettings( |
70 const base::DictionaryValue& job_settings, | 70 const base::DictionaryValue& job_settings) { |
71 const PageRanges& ranges) { | |
72 ResetSettings(); | 71 ResetSettings(); |
73 | 72 |
74 if (!PrintSettingsInitializer::InitSettings(job_settings, ranges, | 73 if (!PrintSettingsFromJobSettings(job_settings, &settings_)) { |
75 &settings_)) { | |
76 NOTREACHED(); | 74 NOTREACHED(); |
77 return OnError(); | 75 return OnError(); |
78 } | 76 } |
79 | 77 |
80 bool print_to_pdf = false; | 78 bool print_to_pdf = false; |
81 bool is_cloud_dialog = false; | 79 bool is_cloud_dialog = false; |
82 bool print_with_privet = false; | 80 bool print_with_privet = false; |
83 | 81 |
84 if (!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || | 82 if (!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || |
85 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog) || | 83 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog) || |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 kCloudPrintMarginInch * settings_.device_units_per_inch()); | 115 kCloudPrintMarginInch * settings_.device_units_per_inch()); |
118 } | 116 } |
119 settings_.SetPrinterPrintableArea(paper_size, paper_rect, true); | 117 settings_.SetPrinterPrintableArea(paper_size, paper_rect, true); |
120 return OK; | 118 return OK; |
121 } | 119 } |
122 | 120 |
123 return UpdatePrinterSettings(open_in_external_preview); | 121 return UpdatePrinterSettings(open_in_external_preview); |
124 } | 122 } |
125 | 123 |
126 } // namespace printing | 124 } // namespace printing |
OLD | NEW |