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

Unified 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: Local autorelease pool to force exceptions into the right handling context. 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 side-by-side diff with in-line comments
Download patch
Index: printing/printing_context_mac.mm
diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm
index a8e4fa048d4a1bfdde5908762788d363e08258b7..7e5333337bd7fbba9a4f45ad60d6711073480a83 100644
--- a/printing/printing_context_mac.mm
+++ b/printing/printing_context_mac.mm
@@ -9,6 +9,8 @@
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
+#include "base/mac/scoped_nsautorelease_pool.h"
+#include "base/mac/scoped_nsexception_enabler.h"
#include "base/sys_string_conversions.h"
#include "base/values.h"
#include "printing/print_settings_initializer_mac.h"
@@ -36,6 +38,15 @@ void PrintingContextMac::AskUserForSettings(gfx::NativeView parent_view,
int max_pages,
bool has_selection,
PrintSettingsCallback* callback) {
+ // Third-party print drivers seem to be an area prone to raising exceptions.
+ // This will allow exceptions to be raised, but does not handle them. The
+ // NSPrintPanel appears to have appropriate NSException handlers.
+ base::mac::ScopedNSExceptionEnabler enabler(true);
+
+ // Exceptions can also happen when the NSPrintPanel is being
+ // deallocated, so it must be autoreleased within this scope.
+ base::mac::ScopedNSAutoreleasePool pool;
+
DCHECK([NSThread isMainThread]);
// We deliberately don't feed max_pages into the dialog, because setting

Powered by Google App Engine
This is Rietveld 408576698