| 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 <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 | 8 |
| 9 #import <iomanip> | 9 #import <iomanip> |
| 10 #import <numeric> | 10 #import <numeric> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
| 14 #include "base/mac/scoped_nsautorelease_pool.h" | 14 #include "base/mac/scoped_nsautorelease_pool.h" |
| 15 #include "base/mac/scoped_nsexception_enabler.h" | |
| 16 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/values.h" | 17 #include "base/values.h" |
| 19 #include "printing/print_settings_initializer_mac.h" | 18 #include "printing/print_settings_initializer_mac.h" |
| 20 #include "printing/units.h" | 19 #include "printing/units.h" |
| 21 | 20 |
| 22 namespace printing { | 21 namespace printing { |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 78 |
| 80 PrintingContextMac::~PrintingContextMac() { | 79 PrintingContextMac::~PrintingContextMac() { |
| 81 ReleaseContext(); | 80 ReleaseContext(); |
| 82 } | 81 } |
| 83 | 82 |
| 84 void PrintingContextMac::AskUserForSettings( | 83 void PrintingContextMac::AskUserForSettings( |
| 85 int max_pages, | 84 int max_pages, |
| 86 bool has_selection, | 85 bool has_selection, |
| 87 bool is_scripted, | 86 bool is_scripted, |
| 88 const PrintSettingsCallback& callback) { | 87 const PrintSettingsCallback& callback) { |
| 89 // Third-party print drivers seem to be an area prone to raising exceptions. | |
| 90 // This will allow exceptions to be raised, but does not handle them. The | |
| 91 // NSPrintPanel appears to have appropriate NSException handlers. | |
| 92 base::mac::ScopedNSExceptionEnabler enabler; | |
| 93 | |
| 94 // Exceptions can also happen when the NSPrintPanel is being | 88 // Exceptions can also happen when the NSPrintPanel is being |
| 95 // deallocated, so it must be autoreleased within this scope. | 89 // deallocated, so it must be autoreleased within this scope. |
| 96 base::mac::ScopedNSAutoreleasePool pool; | 90 base::mac::ScopedNSAutoreleasePool pool; |
| 97 | 91 |
| 98 DCHECK([NSThread isMainThread]); | 92 DCHECK([NSThread isMainThread]); |
| 99 | 93 |
| 100 // We deliberately don't feed max_pages into the dialog, because setting | 94 // We deliberately don't feed max_pages into the dialog, because setting |
| 101 // NSPrintLastPage makes the print dialog pre-select the option to only print | 95 // NSPrintLastPage makes the print dialog pre-select the option to only print |
| 102 // a range. | 96 // a range. |
| 103 | 97 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 void PrintingContextMac::ReleaseContext() { | 513 void PrintingContextMac::ReleaseContext() { |
| 520 print_info_.reset(); | 514 print_info_.reset(); |
| 521 context_ = NULL; | 515 context_ = NULL; |
| 522 } | 516 } |
| 523 | 517 |
| 524 gfx::NativeDrawingContext PrintingContextMac::context() const { | 518 gfx::NativeDrawingContext PrintingContextMac::context() const { |
| 525 return context_; | 519 return context_; |
| 526 } | 520 } |
| 527 | 521 |
| 528 } // namespace printing | 522 } // namespace printing |
| OLD | NEW |