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/values.h" | 7 #include "base/values.h" |
8 #include "printing/page_setup.h" | |
8 #include "printing/print_settings_initializer.h" | 9 #include "printing/print_settings_initializer.h" |
9 | 10 |
10 namespace printing { | 11 namespace printing { |
11 | 12 |
12 PrintingContext::PrintingContext(const std::string& app_locale) | 13 PrintingContext::PrintingContext(const std::string& app_locale) |
13 : dialog_box_dismissed_(false), | 14 : dialog_box_dismissed_(false), |
14 in_print_job_(false), | 15 in_print_job_(false), |
15 abort_printing_(false), | 16 abort_printing_(false), |
16 app_locale_(app_locale) { | 17 app_locale_(app_locale) { |
17 } | 18 } |
(...skipping 12 matching lines...) Expand all Loading... | |
30 } | 31 } |
31 | 32 |
32 PrintingContext::Result PrintingContext::OnError() { | 33 PrintingContext::Result PrintingContext::OnError() { |
33 ResetSettings(); | 34 ResetSettings(); |
34 return abort_printing_ ? CANCEL : FAILED; | 35 return abort_printing_ ? CANCEL : FAILED; |
35 } | 36 } |
36 | 37 |
37 PrintingContext::Result PrintingContext::UpdatePrintSettings( | 38 PrintingContext::Result PrintingContext::UpdatePrintSettings( |
38 const base::DictionaryValue& job_settings, | 39 const base::DictionaryValue& job_settings, |
39 const PageRanges& ranges) { | 40 const PageRanges& ranges) { |
41 ResetSettings(); | |
Lei Zhang
2011/10/08 02:02:05
I see you removed a ResetSettings() call in printi
vandebo (ex-Chrome)
2011/10/15 00:42:50
The previous ResetSettings happened after I set th
| |
42 if (!job_settings.GetBoolean(printing::kSettingHeaderFooterEnabled, | |
Lei Zhang
2011/10/08 02:02:05
this block is not needed. It's already in PrintSet
vandebo (ex-Chrome)
2011/10/15 00:42:50
The value needs to be set for PrintSettings::SetPr
| |
43 &settings_.display_header_footer)) { | |
44 NOTREACHED(); | |
45 } | |
46 bool default_margins; | |
47 if (!job_settings.GetBoolean(printing::kSettingDefaultMarginsSelected, | |
48 &default_margins)) { | |
49 NOTREACHED(); | |
50 default_margins = true; | |
51 } | |
52 if (!default_margins) { | |
53 double top_margin_in_points = 0; | |
54 double bottom_margin_in_points = 0; | |
55 double left_margin_in_points = 0; | |
56 double right_margin_in_points = 0; | |
57 DictionaryValue* custom_margins; | |
58 if (!job_settings.GetDictionary(printing::kSettingMargins, | |
59 &custom_margins) || | |
60 !custom_margins->GetDouble(printing::kSettingMarginTop, | |
61 &top_margin_in_points) || | |
62 !custom_margins->GetDouble(printing::kSettingMarginBottom, | |
63 &bottom_margin_in_points) || | |
64 !custom_margins->GetDouble(printing::kSettingMarginLeft, | |
65 &left_margin_in_points) || | |
66 !custom_margins->GetDouble(printing::kSettingMarginRight, | |
67 &right_margin_in_points)) { | |
68 NOTREACHED(); | |
69 } | |
70 PageMargins margins_in_points; | |
71 margins_in_points.Clear(); | |
72 margins_in_points.top = top_margin_in_points; | |
73 margins_in_points.bottom = bottom_margin_in_points; | |
74 margins_in_points.left = left_margin_in_points; | |
75 margins_in_points.right = right_margin_in_points; | |
76 | |
77 PageMargins empty; | |
78 empty.Clear(); | |
Lei Zhang
2011/10/08 02:02:05
Not needed. Better yet, let's add an is_empty meth
vandebo (ex-Chrome)
2011/10/15 00:42:50
Fixed otherwise.
| |
79 if (margins_in_points.Equals(empty)) { | |
80 settings_.margin_type = NO_MARGINS; | |
81 } else { | |
82 settings_.SetCustomMargins(margins_in_points); | |
83 } | |
84 } | |
85 | |
40 PrintingContext::Result result = UpdatePrinterSettings(job_settings, ranges); | 86 PrintingContext::Result result = UpdatePrinterSettings(job_settings, ranges); |
41 printing::PrintSettingsInitializer::InitHeaderFooterStrings(job_settings, | 87 printing::PrintSettingsInitializer::InitHeaderFooterStrings(job_settings, |
42 &settings_); | 88 &settings_); |
43 return result; | 89 return result; |
44 } | 90 } |
45 | 91 |
46 } // namespace printing | 92 } // namespace printing |
OLD | NEW |