OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/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 "chrome/common/render_messages.h" | |
10 #include "printing/units.h" | 9 #include "printing/units.h" |
11 | 10 |
12 namespace printing { | 11 namespace printing { |
13 | 12 |
14 // Global SequenceNumber used for generating unique cookie values. | 13 // Global SequenceNumber used for generating unique cookie values. |
15 static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED); | 14 static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED); |
16 | 15 |
17 PrintSettings::PrintSettings() | 16 PrintSettings::PrintSettings() |
18 : min_shrink(1.25), | 17 : min_shrink(1.25), |
19 max_shrink(2.0), | 18 max_shrink(2.0), |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 PageMargins margins; | 86 PageMargins margins; |
88 margins.header = margin_printer_units; | 87 margins.header = margin_printer_units; |
89 margins.footer = margin_printer_units; | 88 margins.footer = margin_printer_units; |
90 margins.left = margin_printer_units; | 89 margins.left = margin_printer_units; |
91 margins.top = margin_printer_units; | 90 margins.top = margin_printer_units; |
92 margins.right = margin_printer_units; | 91 margins.right = margin_printer_units; |
93 margins.bottom = margin_printer_units; | 92 margins.bottom = margin_printer_units; |
94 page_setup_pixels_.SetRequestedMargins(margins); | 93 page_setup_pixels_.SetRequestedMargins(margins); |
95 } | 94 } |
96 | 95 |
97 void PrintSettings::RenderParams(ViewMsg_Print_Params* params) const { | |
98 DCHECK(params); | |
99 params->printable_size.SetSize(page_setup_pixels_.content_area().width(), | |
100 page_setup_pixels_.content_area().height()); | |
101 params->dpi = dpi_; | |
102 // Currently hardcoded at 1.25. See PrintSettings' constructor. | |
103 params->min_shrink = min_shrink; | |
104 // Currently hardcoded at 2.0. See PrintSettings' constructor. | |
105 params->max_shrink = max_shrink; | |
106 // Currently hardcoded at 72dpi. See PrintSettings' constructor. | |
107 params->desired_dpi = desired_dpi; | |
108 // Always use an invalid cookie. | |
109 params->document_cookie = 0; | |
110 params->selection_only = selection_only; | |
111 } | |
112 | |
113 bool PrintSettings::Equals(const PrintSettings& rhs) const { | 96 bool PrintSettings::Equals(const PrintSettings& rhs) const { |
114 // Do not test the display device name (printer_name_) for equality since it | 97 // Do not test the display device name (printer_name_) for equality since it |
115 // may sometimes be chopped off at 30 chars. As long as device_name is the | 98 // may sometimes be chopped off at 30 chars. As long as device_name is the |
116 // same, that's fine. | 99 // same, that's fine. |
117 return ranges == rhs.ranges && | 100 return ranges == rhs.ranges && |
118 min_shrink == rhs.min_shrink && | 101 min_shrink == rhs.min_shrink && |
119 max_shrink == rhs.max_shrink && | 102 max_shrink == rhs.max_shrink && |
120 desired_dpi == rhs.desired_dpi && | 103 desired_dpi == rhs.desired_dpi && |
121 overlays.Equals(rhs.overlays) && | 104 overlays.Equals(rhs.overlays) && |
122 device_name_ == rhs.device_name_ && | 105 device_name_ == rhs.device_name_ && |
123 page_setup_pixels_.Equals(rhs.page_setup_pixels_) && | 106 page_setup_pixels_.Equals(rhs.page_setup_pixels_) && |
124 dpi_ == rhs.dpi_ && | 107 dpi_ == rhs.dpi_ && |
125 landscape_ == rhs.landscape_; | 108 landscape_ == rhs.landscape_; |
126 } | 109 } |
127 | 110 |
128 int PrintSettings::NewCookie() { | 111 int PrintSettings::NewCookie() { |
129 // A cookie of 0 is used to mark a document as unassigned, count from 1. | 112 // A cookie of 0 is used to mark a document as unassigned, count from 1. |
130 return cookie_seq.GetNext() + 1; | 113 return cookie_seq.GetNext() + 1; |
131 } | 114 } |
132 | 115 |
133 } // namespace printing | 116 } // namespace printing |
OLD | NEW |