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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 !job_settings.GetBoolean(kSettingCollate, &collate) || | 116 !job_settings.GetBoolean(kSettingCollate, &collate) || |
117 !job_settings.GetInteger(kSettingColor, &color) || | 117 !job_settings.GetInteger(kSettingColor, &color) || |
118 !job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || | 118 !job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || |
119 !job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) || | 119 !job_settings.GetInteger(kSettingDuplexMode, &duplex_mode) || |
120 !job_settings.GetInteger(kSettingCopies, &copies) || | 120 !job_settings.GetInteger(kSettingCopies, &copies) || |
121 !job_settings.GetString(kSettingDeviceName, &device_name) || | 121 !job_settings.GetString(kSettingDeviceName, &device_name) || |
122 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog)) { | 122 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog)) { |
123 return OnError(); | 123 return OnError(); |
124 } | 124 } |
125 | 125 |
126 bool print_to_cloud = job_settings.HasKey(printing::kSettingCloudPrintId); | 126 bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId); |
127 | 127 |
128 if (!print_to_pdf && !print_to_cloud && !is_cloud_dialog) { | 128 if (!print_to_pdf && !print_to_cloud && !is_cloud_dialog) { |
129 if (!SetPrinter(device_name)) | 129 if (!SetPrinter(device_name)) |
130 return OnError(); | 130 return OnError(); |
131 | 131 |
132 if (!SetCopiesInPrintSettings(copies)) | 132 if (!SetCopiesInPrintSettings(copies)) |
133 return OnError(); | 133 return OnError(); |
134 | 134 |
135 if (!SetCollateInPrintSettings(collate)) | 135 if (!SetCollateInPrintSettings(collate)) |
136 return OnError(); | 136 return OnError(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 PMPrintSettings pmPrintSettings = | 244 PMPrintSettings pmPrintSettings = |
245 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); | 245 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); |
246 return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr; | 246 return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr; |
247 } | 247 } |
248 | 248 |
249 bool PrintingContextMac::SetOutputColor(int color_mode) { | 249 bool PrintingContextMac::SetOutputColor(int color_mode) { |
250 PMPrintSettings pmPrintSettings = | 250 PMPrintSettings pmPrintSettings = |
251 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); | 251 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); |
252 std::string color_setting_name; | 252 std::string color_setting_name; |
253 std::string color_value; | 253 std::string color_value; |
254 printing::GetColorModelForMode(color_mode, &color_setting_name, &color_value); | 254 GetColorModelForMode(color_mode, &color_setting_name, &color_value); |
255 base::mac::ScopedCFTypeRef<CFStringRef> color_setting( | 255 base::mac::ScopedCFTypeRef<CFStringRef> color_setting( |
256 base::SysUTF8ToCFStringRef(color_setting_name)); | 256 base::SysUTF8ToCFStringRef(color_setting_name)); |
257 base::mac::ScopedCFTypeRef<CFStringRef> output_color( | 257 base::mac::ScopedCFTypeRef<CFStringRef> output_color( |
258 base::SysUTF8ToCFStringRef(color_value)); | 258 base::SysUTF8ToCFStringRef(color_value)); |
259 | 259 |
260 return PMPrintSettingsSetValue(pmPrintSettings, | 260 return PMPrintSettingsSetValue(pmPrintSettings, |
261 color_setting.get(), | 261 color_setting.get(), |
262 output_color.get(), | 262 output_color.get(), |
263 false) == noErr; | 263 false) == noErr; |
264 } | 264 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 void PrintingContextMac::ReleaseContext() { | 377 void PrintingContextMac::ReleaseContext() { |
378 print_info_.reset(); | 378 print_info_.reset(); |
379 context_ = NULL; | 379 context_ = NULL; |
380 } | 380 } |
381 | 381 |
382 gfx::NativeDrawingContext PrintingContextMac::context() const { | 382 gfx::NativeDrawingContext PrintingContextMac::context() const { |
383 return context_; | 383 return context_; |
384 } | 384 } |
385 | 385 |
386 } // namespace printing | 386 } // namespace printing |
OLD | NEW |