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_mac.h" | 5 #include "printing/printing_context_mac.h" |
6 | 6 |
7 #import <ApplicationServices/ApplicationServices.h> | 7 #import <ApplicationServices/ApplicationServices.h> |
8 #import <AppKit/AppKit.h> | 8 #import <AppKit/AppKit.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 // NOTE: Reset |print_info_| with a copy of |sharedPrintInfo| so as to start | 105 // NOTE: Reset |print_info_| with a copy of |sharedPrintInfo| so as to start |
106 // with a clean slate. | 106 // with a clean slate. |
107 print_info_.reset([[NSPrintInfo sharedPrintInfo] copy]); | 107 print_info_.reset([[NSPrintInfo sharedPrintInfo] copy]); |
108 | 108 |
109 bool collate; | 109 bool collate; |
110 bool color; | 110 bool color; |
111 bool landscape; | 111 bool landscape; |
112 bool print_to_pdf; | 112 bool print_to_pdf; |
113 int copies; | 113 int copies; |
114 int duplex_mode; | 114 DictionaryValue* duplex_info; |
| 115 int user_selected_duplex_value; |
115 std::string device_name; | 116 std::string device_name; |
116 | 117 |
117 if (!job_settings.GetBoolean(kSettingLandscape, &landscape) || | 118 if (!job_settings.GetBoolean(kSettingLandscape, &landscape) || |
118 !job_settings.GetBoolean(kSettingCollate, &collate) || | 119 !job_settings.GetBoolean(kSettingCollate, &collate) || |
119 !job_settings.GetBoolean(kSettingColor, &color) || | 120 !job_settings.GetBoolean(kSettingColor, &color) || |
120 !job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || | 121 !job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || |
121 !job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) || | 122 !job_settings.GetDictionary(kSettingDuplexModeInfo, &duplex_info) || |
| 123 !duplex_info->GetInteger(kUserSelectedDuplexValue, |
| 124 &user_selected_duplex_value) || |
122 !job_settings.GetInteger(kSettingCopies, &copies) || | 125 !job_settings.GetInteger(kSettingCopies, &copies) || |
123 !job_settings.GetString(kSettingDeviceName, &device_name)) { | 126 !job_settings.GetString(kSettingDeviceName, &device_name)) { |
124 return OnError(); | 127 return OnError(); |
125 } | 128 } |
126 | 129 |
127 bool print_to_cloud = job_settings.HasKey(printing::kSettingCloudPrintId); | 130 bool print_to_cloud = job_settings.HasKey(printing::kSettingCloudPrintId); |
128 | 131 |
129 if (!print_to_pdf && !print_to_cloud) { | 132 if (!print_to_pdf && !print_to_cloud) { |
130 if (!SetPrinter(device_name)) | 133 if (!SetPrinter(device_name)) |
131 return OnError(); | 134 return OnError(); |
132 | 135 |
133 if (!SetCopiesInPrintSettings(copies)) | 136 if (!SetCopiesInPrintSettings(copies)) |
134 return OnError(); | 137 return OnError(); |
135 | 138 |
136 if (!SetCollateInPrintSettings(collate)) | 139 if (!SetCollateInPrintSettings(collate)) |
137 return OnError(); | 140 return OnError(); |
138 | 141 |
139 if (!SetDuplexModeInPrintSettings( | 142 if (!SetDuplexModeInPrintSettings( |
140 static_cast<DuplexMode>(duplex_mode))) { | 143 static_cast<DuplexMode>(user_selected_duplex_value))) { |
141 return OnError(); | 144 return OnError(); |
142 } | 145 } |
143 | 146 |
144 if (!SetOutputIsColor(color)) | 147 if (!SetOutputIsColor(color)) |
145 return OnError(); | 148 return OnError(); |
146 } | 149 } |
147 | 150 |
148 if (!SetOrientationIsLandscape(landscape)) | 151 if (!SetOrientationIsLandscape(landscape)) |
149 return OnError(); | 152 return OnError(); |
150 | 153 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 void PrintingContextMac::ReleaseContext() { | 373 void PrintingContextMac::ReleaseContext() { |
371 print_info_.reset(); | 374 print_info_.reset(); |
372 context_ = NULL; | 375 context_ = NULL; |
373 } | 376 } |
374 | 377 |
375 gfx::NativeDrawingContext PrintingContextMac::context() const { | 378 gfx::NativeDrawingContext PrintingContextMac::context() const { |
376 return context_; | 379 return context_; |
377 } | 380 } |
378 | 381 |
379 } // namespace printing | 382 } // namespace printing |
OLD | NEW |