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

Side by Side Diff: printing/printing_context_mac.mm

Issue 7038010: [Mac] Allow NSExceptions in certain cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oh, clang, you crazy fox. Created 9 years, 7 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 | « chrome/browser/chrome_browser_application_mac.mm ('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')
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"
13 #include "base/mac/scoped_nsexception_enabler.h"
12 #include "base/sys_string_conversions.h" 14 #include "base/sys_string_conversions.h"
13 #include "base/values.h" 15 #include "base/values.h"
14 #include "printing/print_settings_initializer_mac.h" 16 #include "printing/print_settings_initializer_mac.h"
15 17
16 static const CFStringRef kColorModel = CFSTR("ColorModel"); 18 static const CFStringRef kColorModel = CFSTR("ColorModel");
17 static const CFStringRef kGrayColor = CFSTR("Gray"); 19 static const CFStringRef kGrayColor = CFSTR("Gray");
18 20
19 namespace printing { 21 namespace printing {
20 22
21 // static 23 // static
22 PrintingContext* PrintingContext::Create(const std::string& app_locale) { 24 PrintingContext* PrintingContext::Create(const std::string& app_locale) {
23 return static_cast<PrintingContext*>(new PrintingContextMac(app_locale)); 25 return static_cast<PrintingContext*>(new PrintingContextMac(app_locale));
24 } 26 }
25 27
26 PrintingContextMac::PrintingContextMac(const std::string& app_locale) 28 PrintingContextMac::PrintingContextMac(const std::string& app_locale)
27 : PrintingContext(app_locale), 29 : PrintingContext(app_locale),
28 context_(NULL) { 30 context_(NULL) {
29 } 31 }
30 32
31 PrintingContextMac::~PrintingContextMac() { 33 PrintingContextMac::~PrintingContextMac() {
32 ReleaseContext(); 34 ReleaseContext();
33 } 35 }
34 36
35 void PrintingContextMac::AskUserForSettings(gfx::NativeView parent_view, 37 void PrintingContextMac::AskUserForSettings(gfx::NativeView parent_view,
36 int max_pages, 38 int max_pages,
37 bool has_selection, 39 bool has_selection,
38 PrintSettingsCallback* callback) { 40 PrintSettingsCallback* callback) {
41 // Third-party print drivers seem to be an area prone to raising exceptions.
42 // This will allow exceptions to be raised, but does not handle them. The
43 // NSPrintPanel appears to have appropriate NSException handlers.
44 base::mac::ScopedNSExceptionEnabler enabler;
45
46 // Exceptions can also happen when the NSPrintPanel is being
47 // deallocated, so it must be autoreleased within this scope.
48 base::mac::ScopedNSAutoreleasePool pool;
49
39 DCHECK([NSThread isMainThread]); 50 DCHECK([NSThread isMainThread]);
40 51
41 // We deliberately don't feed max_pages into the dialog, because setting 52 // We deliberately don't feed max_pages into the dialog, because setting
42 // NSPrintLastPage makes the print dialog pre-select the option to only print 53 // NSPrintLastPage makes the print dialog pre-select the option to only print
43 // a range. 54 // a range.
44 55
45 // TODO(stuartmorgan): implement 'print selection only' (probably requires 56 // TODO(stuartmorgan): implement 'print selection only' (probably requires
46 // adding a new custom view to the panel on 10.5; 10.6 has 57 // adding a new custom view to the panel on 10.5; 10.6 has
47 // NSPrintPanelShowsPrintSelection). 58 // NSPrintPanelShowsPrintSelection).
48 NSPrintPanel* panel = [NSPrintPanel printPanel]; 59 NSPrintPanel* panel = [NSPrintPanel printPanel];
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 void PrintingContextMac::ReleaseContext() { 366 void PrintingContextMac::ReleaseContext() {
356 print_info_.reset(); 367 print_info_.reset();
357 context_ = NULL; 368 context_ = NULL;
358 } 369 }
359 370
360 gfx::NativeDrawingContext PrintingContextMac::context() const { 371 gfx::NativeDrawingContext PrintingContextMac::context() const {
361 return context_; 372 return context_;
362 } 373 }
363 374
364 } // namespace printing 375 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_application_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698