OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/print_settings.h" | 5 #include "printing/print_settings.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "printing/print_job_constants.h" | 9 #include "printing/print_job_constants.h" |
10 #include "printing/units.h" | 10 #include "printing/units.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Global SequenceNumber used for generating unique cookie values. | 110 // Global SequenceNumber used for generating unique cookie values. |
111 static base::StaticAtomicSequenceNumber cookie_seq; | 111 static base::StaticAtomicSequenceNumber cookie_seq; |
112 | 112 |
113 PrintSettings::PrintSettings() | 113 PrintSettings::PrintSettings() |
114 : min_shrink(1.25), | 114 : min_shrink(1.25), |
115 max_shrink(2.0), | 115 max_shrink(2.0), |
116 desired_dpi(72), | 116 desired_dpi(72), |
117 selection_only(false), | 117 selection_only(false), |
118 margin_type(DEFAULT_MARGINS), | 118 margin_type(DEFAULT_MARGINS), |
119 display_header_footer(false), | 119 display_header_footer(false), |
| 120 should_print_backgrounds(false), |
120 dpi_(0), | 121 dpi_(0), |
121 landscape_(false), | 122 landscape_(false), |
122 supports_alpha_blend_(true) { | 123 supports_alpha_blend_(true) { |
123 } | 124 } |
124 | 125 |
125 PrintSettings::~PrintSettings() { | 126 PrintSettings::~PrintSettings() { |
126 } | 127 } |
127 | 128 |
128 void PrintSettings::Clear() { | 129 void PrintSettings::Clear() { |
129 ranges.clear(); | 130 ranges.clear(); |
130 min_shrink = 1.25; | 131 min_shrink = 1.25; |
131 max_shrink = 2.; | 132 max_shrink = 2.; |
132 desired_dpi = 72; | 133 desired_dpi = 72; |
133 selection_only = false; | 134 selection_only = false; |
134 date = string16(); | 135 date = string16(); |
135 title = string16(); | 136 title = string16(); |
136 url = string16(); | 137 url = string16(); |
137 display_header_footer = false; | 138 display_header_footer = false; |
138 printer_name_.clear(); | 139 printer_name_.clear(); |
139 device_name_.clear(); | 140 device_name_.clear(); |
140 page_setup_device_units_.Clear(); | 141 page_setup_device_units_.Clear(); |
141 dpi_ = 0; | 142 dpi_ = 0; |
142 landscape_ = false; | 143 landscape_ = false; |
143 supports_alpha_blend_ = true; | 144 supports_alpha_blend_ = true; |
| 145 should_print_backgrounds = false; |
144 } | 146 } |
145 | 147 |
146 void PrintSettings::SetPrinterPrintableArea( | 148 void PrintSettings::SetPrinterPrintableArea( |
147 gfx::Size const& physical_size_device_units, | 149 gfx::Size const& physical_size_device_units, |
148 gfx::Rect const& printable_area_device_units, | 150 gfx::Rect const& printable_area_device_units, |
149 int units_per_inch) { | 151 int units_per_inch) { |
150 int header_footer_text_height = 0; | 152 int header_footer_text_height = 0; |
151 if (display_header_footer) { | 153 if (display_header_footer) { |
152 // Hard-code text_height = 0.5cm = ~1/5 of inch. | 154 // Hard-code text_height = 0.5cm = ~1/5 of inch. |
153 header_footer_text_height = ConvertUnit(kSettingHeaderFooterInterstice, | 155 header_footer_text_height = ConvertUnit(kSettingHeaderFooterInterstice, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // Do not test the display device name (printer_name_) for equality since it | 226 // Do not test the display device name (printer_name_) for equality since it |
225 // may sometimes be chopped off at 30 chars. As long as device_name is the | 227 // may sometimes be chopped off at 30 chars. As long as device_name is the |
226 // same, that's fine. | 228 // same, that's fine. |
227 return ranges == rhs.ranges && | 229 return ranges == rhs.ranges && |
228 min_shrink == rhs.min_shrink && | 230 min_shrink == rhs.min_shrink && |
229 max_shrink == rhs.max_shrink && | 231 max_shrink == rhs.max_shrink && |
230 desired_dpi == rhs.desired_dpi && | 232 desired_dpi == rhs.desired_dpi && |
231 device_name_ == rhs.device_name_ && | 233 device_name_ == rhs.device_name_ && |
232 page_setup_device_units_.Equals(rhs.page_setup_device_units_) && | 234 page_setup_device_units_.Equals(rhs.page_setup_device_units_) && |
233 dpi_ == rhs.dpi_ && | 235 dpi_ == rhs.dpi_ && |
234 landscape_ == rhs.landscape_; | 236 landscape_ == rhs.landscape_ && |
| 237 should_print_backgrounds == rhs.should_print_backgrounds; |
235 } | 238 } |
236 | 239 |
237 int PrintSettings::NewCookie() { | 240 int PrintSettings::NewCookie() { |
238 // A cookie of 0 is used to mark a document as unassigned, count from 1. | 241 // A cookie of 0 is used to mark a document as unassigned, count from 1. |
239 return cookie_seq.GetNext() + 1; | 242 return cookie_seq.GetNext() + 1; |
240 } | 243 } |
241 | 244 |
242 void PrintSettings::SetOrientation(bool landscape) { | 245 void PrintSettings::SetOrientation(bool landscape) { |
243 if (landscape_ != landscape) { | 246 if (landscape_ != landscape) { |
244 landscape_ = landscape; | 247 landscape_ = landscape; |
245 page_setup_device_units_.FlipOrientation(); | 248 page_setup_device_units_.FlipOrientation(); |
246 } | 249 } |
247 } | 250 } |
248 | 251 |
249 } // namespace printing | 252 } // namespace printing |
OLD | NEW |