Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: printing/printing_context_mac.mm

Issue 8245012: Revert 105087 - PrintPreview: Fix printer color settings issues based on printer ppd/schema infor... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/print_settings.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
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"
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/mac/scoped_nsautorelease_pool.h" 12 #include "base/mac/scoped_nsautorelease_pool.h"
13 #include "base/mac/scoped_nsexception_enabler.h" 13 #include "base/mac/scoped_nsexception_enabler.h"
14 #include "base/sys_string_conversions.h" 14 #include "base/sys_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "printing/print_settings_initializer_mac.h" 16 #include "printing/print_settings_initializer_mac.h"
17 17
18 static const CFStringRef kColorModel = CFSTR("ColorModel");
19 static const CFStringRef kGrayColor = CFSTR("Gray");
20 static const CFStringRef kCMYK = CFSTR("CMYK");
21
18 namespace printing { 22 namespace printing {
19 23
20 // static 24 // static
21 PrintingContext* PrintingContext::Create(const std::string& app_locale) { 25 PrintingContext* PrintingContext::Create(const std::string& app_locale) {
22 return static_cast<PrintingContext*>(new PrintingContextMac(app_locale)); 26 return static_cast<PrintingContext*>(new PrintingContextMac(app_locale));
23 } 27 }
24 28
25 PrintingContextMac::PrintingContextMac(const std::string& app_locale) 29 PrintingContextMac::PrintingContextMac(const std::string& app_locale)
26 : PrintingContext(app_locale), 30 : PrintingContext(app_locale),
27 print_info_([[NSPrintInfo sharedPrintInfo] copy]), 31 print_info_([[NSPrintInfo sharedPrintInfo] copy]),
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 246 }
243 247
244 PMPrintSettings pmPrintSettings = 248 PMPrintSettings pmPrintSettings =
245 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); 249 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]);
246 return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr; 250 return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr;
247 } 251 }
248 252
249 bool PrintingContextMac::SetOutputColor(int color_mode) { 253 bool PrintingContextMac::SetOutputColor(int color_mode) {
250 PMPrintSettings pmPrintSettings = 254 PMPrintSettings pmPrintSettings =
251 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); 255 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]);
252 std::string color_setting_name; 256 CFStringRef output_color = NULL;
253 std::string color_value; 257 if (color_mode == printing::GRAY)
254 printing::GetColorModelForMode(color_mode, &color_setting_name, &color_value); 258 output_color = kGrayColor;
255 base::mac::ScopedCFTypeRef<CFStringRef> color_setting( 259 else if (color_mode == printing::CMYK)
256 base::SysUTF8ToCFStringRef(color_setting_name)); 260 output_color = kCMYK;
257 base::mac::ScopedCFTypeRef<CFStringRef> output_color(
258 base::SysUTF8ToCFStringRef(color_value));
259 261
260 return PMPrintSettingsSetValue(pmPrintSettings, 262 return PMPrintSettingsSetValue(pmPrintSettings,
261 color_setting.get(), 263 kColorModel,
262 output_color.get(), 264 output_color,
263 false) == noErr; 265 false) == noErr;
264 } 266 }
265 267
266 PageRanges PrintingContextMac::GetPageRangesFromPrintInfo() { 268 PageRanges PrintingContextMac::GetPageRangesFromPrintInfo() {
267 PageRanges page_ranges; 269 PageRanges page_ranges;
268 NSDictionary* print_info_dict = [print_info_.get() dictionary]; 270 NSDictionary* print_info_dict = [print_info_.get() dictionary];
269 if (![[print_info_dict objectForKey:NSPrintAllPages] boolValue]) { 271 if (![[print_info_dict objectForKey:NSPrintAllPages] boolValue]) {
270 PageRange range; 272 PageRange range;
271 range.from = [[print_info_dict objectForKey:NSPrintFirstPage] intValue] - 1; 273 range.from = [[print_info_dict objectForKey:NSPrintFirstPage] intValue] - 1;
272 range.to = [[print_info_dict objectForKey:NSPrintLastPage] intValue] - 1; 274 range.to = [[print_info_dict objectForKey:NSPrintLastPage] intValue] - 1;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 void PrintingContextMac::ReleaseContext() { 379 void PrintingContextMac::ReleaseContext() {
378 print_info_.reset(); 380 print_info_.reset();
379 context_ = NULL; 381 context_ = NULL;
380 } 382 }
381 383
382 gfx::NativeDrawingContext PrintingContextMac::context() const { 384 gfx::NativeDrawingContext PrintingContextMac::context() const {
383 return context_; 385 return context_;
384 } 386 }
385 387
386 } // namespace printing 388 } // namespace printing
OLDNEW
« no previous file with comments | « printing/print_settings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698