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

Side by Side Diff: printing/printing_context_mac.mm

Issue 16917011: mac: Replace base::mac::ScopedCFTypeRef with base::ScopedCFTypeRef. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with fixed off-by-1 in git-clang-format Created 7 years, 6 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/pdf_metafile_cg_mac.cc ('k') | remoting/host/curtain_mode_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import <iomanip> 10 #import <iomanip>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 static_cast<PMPrintSession>([print_info_.get() PMPrintSession]); 207 static_cast<PMPrintSession>([print_info_.get() PMPrintSession]);
208 208
209 PMPrinter current_printer; 209 PMPrinter current_printer;
210 if (PMSessionGetCurrentPrinter(print_session, &current_printer) != noErr) 210 if (PMSessionGetCurrentPrinter(print_session, &current_printer) != noErr)
211 return false; 211 return false;
212 212
213 CFStringRef current_printer_id = PMPrinterGetID(current_printer); 213 CFStringRef current_printer_id = PMPrinterGetID(current_printer);
214 if (!current_printer_id) 214 if (!current_printer_id)
215 return false; 215 return false;
216 216
217 base::mac::ScopedCFTypeRef<CFStringRef> new_printer_id( 217 base::ScopedCFTypeRef<CFStringRef> new_printer_id(
218 base::SysUTF8ToCFStringRef(device_name)); 218 base::SysUTF8ToCFStringRef(device_name));
219 if (!new_printer_id.get()) 219 if (!new_printer_id.get())
220 return false; 220 return false;
221 221
222 if (CFStringCompare(new_printer_id.get(), current_printer_id, 0) == 222 if (CFStringCompare(new_printer_id.get(), current_printer_id, 0) ==
223 kCFCompareEqualTo) { 223 kCFCompareEqualTo) {
224 return true; 224 return true;
225 } 225 }
226 226
227 PMPrinter new_printer = PMPrinterCreateFromPrinterID(new_printer_id.get()); 227 PMPrinter new_printer = PMPrinterCreateFromPrinterID(new_printer_id.get());
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); 378 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]);
379 return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr; 379 return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr;
380 } 380 }
381 381
382 bool PrintingContextMac::SetOutputColor(int color_mode) { 382 bool PrintingContextMac::SetOutputColor(int color_mode) {
383 PMPrintSettings pmPrintSettings = 383 PMPrintSettings pmPrintSettings =
384 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); 384 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]);
385 std::string color_setting_name; 385 std::string color_setting_name;
386 std::string color_value; 386 std::string color_value;
387 GetColorModelForMode(color_mode, &color_setting_name, &color_value); 387 GetColorModelForMode(color_mode, &color_setting_name, &color_value);
388 base::mac::ScopedCFTypeRef<CFStringRef> color_setting( 388 base::ScopedCFTypeRef<CFStringRef> color_setting(
389 base::SysUTF8ToCFStringRef(color_setting_name)); 389 base::SysUTF8ToCFStringRef(color_setting_name));
390 base::mac::ScopedCFTypeRef<CFStringRef> output_color( 390 base::ScopedCFTypeRef<CFStringRef> output_color(
391 base::SysUTF8ToCFStringRef(color_value)); 391 base::SysUTF8ToCFStringRef(color_value));
392 392
393 return PMPrintSettingsSetValue(pmPrintSettings, 393 return PMPrintSettingsSetValue(pmPrintSettings,
394 color_setting.get(), 394 color_setting.get(),
395 output_color.get(), 395 output_color.get(),
396 false) == noErr; 396 false) == noErr;
397 } 397 }
398 398
399 PageRanges PrintingContextMac::GetPageRangesFromPrintInfo() { 399 PageRanges PrintingContextMac::GetPageRangesFromPrintInfo() {
400 PageRanges page_ranges; 400 PageRanges page_ranges;
(...skipping 24 matching lines...) Expand all
425 425
426 in_print_job_ = true; 426 in_print_job_ = true;
427 427
428 PMPrintSession print_session = 428 PMPrintSession print_session =
429 static_cast<PMPrintSession>([print_info_.get() PMPrintSession]); 429 static_cast<PMPrintSession>([print_info_.get() PMPrintSession]);
430 PMPrintSettings print_settings = 430 PMPrintSettings print_settings =
431 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); 431 static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]);
432 PMPageFormat page_format = 432 PMPageFormat page_format =
433 static_cast<PMPageFormat>([print_info_.get() PMPageFormat]); 433 static_cast<PMPageFormat>([print_info_.get() PMPageFormat]);
434 434
435 base::mac::ScopedCFTypeRef<CFStringRef> job_title( 435 base::ScopedCFTypeRef<CFStringRef> job_title(
436 base::SysUTF16ToCFStringRef(document_name)); 436 base::SysUTF16ToCFStringRef(document_name));
437 PMPrintSettingsSetJobName(print_settings, job_title.get()); 437 PMPrintSettingsSetJobName(print_settings, job_title.get());
438 438
439 OSStatus status = PMSessionBeginCGDocumentNoDialog(print_session, 439 OSStatus status = PMSessionBeginCGDocumentNoDialog(print_session,
440 print_settings, 440 print_settings,
441 page_format); 441 page_format);
442 if (status != noErr) 442 if (status != noErr)
443 return OnError(); 443 return OnError();
444 444
445 return OK; 445 return OK;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 void PrintingContextMac::ReleaseContext() { 510 void PrintingContextMac::ReleaseContext() {
511 print_info_.reset(); 511 print_info_.reset();
512 context_ = NULL; 512 context_ = NULL;
513 } 513 }
514 514
515 gfx::NativeDrawingContext PrintingContextMac::context() const { 515 gfx::NativeDrawingContext PrintingContextMac::context() const {
516 return context_; 516 return context_;
517 } 517 }
518 518
519 } // namespace printing 519 } // namespace printing
OLDNEW
« no previous file with comments | « printing/pdf_metafile_cg_mac.cc ('k') | remoting/host/curtain_mode_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698