| Index: chrome/browser/chrome_browser_application_mac.mm
|
| diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm
|
| index 3368c06351486e4ff3bf4657a30be1c00d1b420f..af0b6e663b971d5ffc4f0ed5a9e3bfbea5c68175 100644
|
| --- a/chrome/browser/chrome_browser_application_mac.mm
|
| +++ b/chrome/browser/chrome_browser_application_mac.mm
|
| @@ -10,13 +10,13 @@
|
| #import "base/logging.h"
|
| #import "base/mac/scoped_nsexception_enabler.h"
|
| #import "base/mac/scoped_nsobject.h"
|
| +#import "base/mac/scoped_objc_class_swizzler.h"
|
| #import "base/metrics/histogram.h"
|
| #include "base/strings/stringprintf.h"
|
| #import "base/strings/sys_string_conversions.h"
|
| #import "chrome/browser/app_controller_mac.h"
|
| #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
|
| #include "chrome/common/crash_keys.h"
|
| -#import "chrome/common/mac/objc_method_swizzle.h"
|
| #import "chrome/common/mac/objc_zombie.h"
|
| #include "content/public/browser/browser_accessibility_state.h"
|
| #include "content/public/browser/render_view_host.h"
|
| @@ -24,7 +24,7 @@
|
|
|
| namespace {
|
|
|
| -// Tracking for cases being hit by -crInitWithName:reason:userInfo:.
|
| +// Tracking for cases being hit by -initWithName:reason:userInfo:.
|
| enum ExceptionEventType {
|
| EXCEPTION_ACCESSIBILITY = 0,
|
| EXCEPTION_MENU_ITEM_BOUNDS_CHECK,
|
| @@ -44,25 +44,25 @@ void RecordExceptionEvent(ExceptionEventType event_type) {
|
| } // namespace
|
|
|
| // The implementation of NSExceptions break various assumptions in the
|
| -// Chrome code. This category defines a replacement for
|
| +// Chrome code. This interface defines a replacement for
|
| // -initWithName:reason:userInfo: for purposes of forcing a break in
|
| // the debugger when an exception is raised. -raise sounds more
|
| // obvious to intercept, but it doesn't catch the original throw
|
| // because the objc runtime doesn't use it.
|
| -@interface NSException (CrNSExceptionSwizzle)
|
| -- (id)crInitWithName:(NSString*)aName
|
| - reason:(NSString*)aReason
|
| - userInfo:(NSDictionary*)someUserInfo;
|
| +@interface CrNSExceptionInitDonor : NSObject
|
| +- (id)initWithName:(NSString*)aName
|
| + reason:(NSString*)aReason
|
| + userInfo:(NSDictionary*)someUserInfo;
|
| @end
|
|
|
| static IMP gOriginalInitIMP = NULL;
|
|
|
| -@implementation NSException (CrNSExceptionSwizzle)
|
| -- (id)crInitWithName:(NSString*)aName
|
| - reason:(NSString*)aReason
|
| - userInfo:(NSDictionary*)someUserInfo {
|
| +@implementation CrNSExceptionInitDonor
|
| +- (id)initWithName:(NSString*)aName
|
| + reason:(NSString*)aReason
|
| + userInfo:(NSDictionary*)someUserInfo {
|
| // Method only called when swizzled.
|
| - DCHECK(_cmd == @selector(initWithName:reason:userInfo:));
|
| + DCHECK(gOriginalInitIMP);
|
|
|
| // Parts of Cocoa rely on creating and throwing exceptions. These are not
|
| // worth bugging-out over. It is very important that there be zero chance that
|
| @@ -235,10 +235,12 @@ void SwizzleInit() {
|
| // Do-nothing wrapper so that we can arrange to only swizzle
|
| // -[NSException raise] when DCHECK() is turned on (as opposed to
|
| // replicating the preprocess logic which turns DCHECK() on).
|
| - gOriginalInitIMP = ObjcEvilDoers::SwizzleImplementedInstanceMethods(
|
| - [NSException class],
|
| - @selector(initWithName:reason:userInfo:),
|
| - @selector(crInitWithName:reason:userInfo:));
|
| + CR_DEFINE_STATIC_LOCAL(base::mac::ScopedObjCClassSwizzler,
|
| + swizzle_exception,
|
| + ([NSException class],
|
| + [CrNSExceptionInitDonor class],
|
| + @selector(initWithName:reason:userInfo:)));
|
| + gOriginalInitIMP = swizzle_exception.GetOriginalImplementation();
|
| }
|
|
|
| } // namespace
|
|
|