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" |
(...skipping 26 matching lines...) Expand all Loading... |
37 ReleaseContext(); | 37 ReleaseContext(); |
38 | 38 |
39 settings_.Clear(); | 39 settings_.Clear(); |
40 | 40 |
41 in_print_job_ = false; | 41 in_print_job_ = false; |
42 dialog_box_dismissed_ = false; | 42 dialog_box_dismissed_ = false; |
43 abort_printing_ = false; | 43 abort_printing_ = false; |
44 } | 44 } |
45 | 45 |
46 PrintingContext::Result PrintingContext::OnError() { | 46 PrintingContext::Result PrintingContext::OnError() { |
| 47 Result result = abort_printing_ ? CANCEL : FAILED; |
47 ResetSettings(); | 48 ResetSettings(); |
48 return abort_printing_ ? CANCEL : FAILED; | 49 return result; |
49 } | 50 } |
50 | 51 |
51 PrintingContext::Result PrintingContext::UsePdfSettings() { | 52 PrintingContext::Result PrintingContext::UsePdfSettings() { |
52 scoped_ptr<base::DictionaryValue> pdf_settings(new base::DictionaryValue); | 53 scoped_ptr<base::DictionaryValue> pdf_settings(new base::DictionaryValue); |
53 pdf_settings->SetBoolean(kSettingHeaderFooterEnabled, false); | 54 pdf_settings->SetBoolean(kSettingHeaderFooterEnabled, false); |
54 pdf_settings->SetBoolean(kSettingShouldPrintBackgrounds, false); | 55 pdf_settings->SetBoolean(kSettingShouldPrintBackgrounds, false); |
55 pdf_settings->SetBoolean(kSettingShouldPrintSelectionOnly, false); | 56 pdf_settings->SetBoolean(kSettingShouldPrintSelectionOnly, false); |
56 pdf_settings->SetInteger(kSettingMarginsType, printing::NO_MARGINS); | 57 pdf_settings->SetInteger(kSettingMarginsType, printing::NO_MARGINS); |
57 pdf_settings->SetBoolean(kSettingCollate, true); | 58 pdf_settings->SetBoolean(kSettingCollate, true); |
58 pdf_settings->SetInteger(kSettingCopies, 1); | 59 pdf_settings->SetInteger(kSettingCopies, 1); |
59 pdf_settings->SetInteger(kSettingColor, printing::COLOR); | 60 pdf_settings->SetInteger(kSettingColor, printing::COLOR); |
60 pdf_settings->SetInteger(kSettingDuplexMode, printing::SIMPLEX); | 61 pdf_settings->SetInteger(kSettingDuplexMode, printing::SIMPLEX); |
61 pdf_settings->SetBoolean(kSettingLandscape, false); | 62 pdf_settings->SetBoolean(kSettingLandscape, false); |
62 pdf_settings->SetString(kSettingDeviceName, ""); | 63 pdf_settings->SetString(kSettingDeviceName, ""); |
63 pdf_settings->SetBoolean(kSettingPrintToPDF, true); | 64 pdf_settings->SetBoolean(kSettingPrintToPDF, true); |
64 pdf_settings->SetBoolean(kSettingCloudPrintDialog, false); | 65 pdf_settings->SetBoolean(kSettingCloudPrintDialog, false); |
65 pdf_settings->SetBoolean(kSettingPrintWithPrivet, false); | 66 pdf_settings->SetBoolean(kSettingPrintWithPrivet, false); |
66 return UpdatePrintSettings(*pdf_settings); | 67 return UpdatePrintSettings(*pdf_settings, NULL); |
67 } | 68 } |
68 | 69 |
69 PrintingContext::Result PrintingContext::UpdatePrintSettings( | 70 PrintingContext::Result PrintingContext::UpdatePrintSettings( |
70 const base::DictionaryValue& job_settings) { | 71 const base::DictionaryValue& job_settings, |
| 72 gfx::NativeView parent_view) { |
71 ResetSettings(); | 73 ResetSettings(); |
72 | 74 |
73 if (!PrintSettingsFromJobSettings(job_settings, &settings_)) { | 75 if (!PrintSettingsFromJobSettings(job_settings, &settings_)) { |
74 NOTREACHED(); | 76 NOTREACHED(); |
75 return OnError(); | 77 return OnError(); |
76 } | 78 } |
77 | 79 |
78 bool print_to_pdf = false; | 80 bool print_to_pdf = false; |
79 bool is_cloud_dialog = false; | 81 bool is_cloud_dialog = false; |
80 bool print_with_privet = false; | 82 bool print_with_privet = false; |
(...skipping 24 matching lines...) Expand all Loading... |
105 gfx::Rect paper_rect(0, 0, paper_size.width(), paper_size.height()); | 107 gfx::Rect paper_rect(0, 0, paper_size.width(), paper_size.height()); |
106 if (print_to_cloud || print_with_privet) { | 108 if (print_to_cloud || print_with_privet) { |
107 paper_rect.Inset( | 109 paper_rect.Inset( |
108 kCloudPrintMarginInch * settings_.device_units_per_inch(), | 110 kCloudPrintMarginInch * settings_.device_units_per_inch(), |
109 kCloudPrintMarginInch * settings_.device_units_per_inch()); | 111 kCloudPrintMarginInch * settings_.device_units_per_inch()); |
110 } | 112 } |
111 settings_.SetPrinterPrintableArea(paper_size, paper_rect, true); | 113 settings_.SetPrinterPrintableArea(paper_size, paper_rect, true); |
112 return OK; | 114 return OK; |
113 } | 115 } |
114 | 116 |
115 return UpdatePrinterSettings(open_in_external_preview); | 117 bool show_system_dialog = false; |
| 118 job_settings.GetBoolean(printing::kSettingShowSystemDialog, |
| 119 &show_system_dialog); |
| 120 |
| 121 return UpdatePrinterSettings( |
| 122 open_in_external_preview, show_system_dialog, parent_view); |
116 } | 123 } |
117 | 124 |
118 } // namespace printing | 125 } // namespace printing |
OLD | NEW |