| 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 #import "chrome/browser/chrome_browser_application_mac.h" | 5 #import "chrome/browser/chrome_browser_application_mac.h" |
| 6 | 6 |
| 7 #import "base/logging.h" | 7 #import "base/logging.h" |
| 8 #include "base/mac/crash_logging.h" |
| 8 #import "base/mac/scoped_nsexception_enabler.h" | 9 #import "base/mac/scoped_nsexception_enabler.h" |
| 9 #import "base/metrics/histogram.h" | 10 #import "base/metrics/histogram.h" |
| 10 #import "base/memory/scoped_nsobject.h" | 11 #import "base/memory/scoped_nsobject.h" |
| 11 #import "base/sys_string_conversions.h" | 12 #import "base/sys_string_conversions.h" |
| 12 #import "chrome/app/breakpad_mac.h" | |
| 13 #import "chrome/browser/app_controller_mac.h" | 13 #import "chrome/browser/app_controller_mac.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 16 #import "chrome/common/mac/objc_method_swizzle.h" | 16 #import "chrome/common/mac/objc_method_swizzle.h" |
| 17 #import "chrome/common/mac/objc_zombie.h" | 17 #import "chrome/common/mac/objc_zombie.h" |
| 18 #include "content/browser/accessibility/browser_accessibility_state.h" | 18 #include "content/browser/accessibility/browser_accessibility_state.h" |
| 19 #include "content/browser/renderer_host/render_view_host.h" | 19 #include "content/browser/renderer_host/render_view_host.h" |
| 20 | 20 |
| 21 // The implementation of NSExceptions break various assumptions in the | 21 // The implementation of NSExceptions break various assumptions in the |
| 22 // Chrome code. This category defines a replacement for | 22 // Chrome code. This category defines a replacement for |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (aName == kAcceptableNSExceptionNames[i]) { | 56 if (aName == kAcceptableNSExceptionNames[i]) { |
| 57 found = YES; | 57 found = YES; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 if (!found) { | 61 if (!found) { |
| 62 // Update breakpad with the exception info. | 62 // Update breakpad with the exception info. |
| 63 static NSString* const kNSExceptionKey = @"nsexception"; | 63 static NSString* const kNSExceptionKey = @"nsexception"; |
| 64 NSString* value = | 64 NSString* value = |
| 65 [NSString stringWithFormat:@"%@ reason %@", aName, aReason]; | 65 [NSString stringWithFormat:@"%@ reason %@", aName, aReason]; |
| 66 SetCrashKeyValue(kNSExceptionKey, value); | 66 base::mac::SetCrashKeyValue(kNSExceptionKey, value); |
| 67 | 67 |
| 68 // Force crash for selected exceptions to generate crash dumps. | 68 // Force crash for selected exceptions to generate crash dumps. |
| 69 BOOL fatal = NO; | 69 BOOL fatal = NO; |
| 70 if (aName == NSInternalInconsistencyException) { | 70 if (aName == NSInternalInconsistencyException) { |
| 71 NSString* const kNSMenuItemArrayBoundsCheck = | 71 NSString* const kNSMenuItemArrayBoundsCheck = |
| 72 @"Invalid parameter not satisfying: (index >= 0) && " | 72 @"Invalid parameter not satisfying: (index >= 0) && " |
| 73 @"(index < [_itemArray count])"; | 73 @"(index < [_itemArray count])"; |
| 74 if ([aReason isEqualToString:kNSMenuItemArrayBoundsCheck]) { | 74 if ([aReason isEqualToString:kNSMenuItemArrayBoundsCheck]) { |
| 75 fatal = YES; | 75 fatal = YES; |
| 76 } | 76 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 } | 331 } |
| 332 } else if ([sender isKindOfClass:[NSMenuItem class]]) { | 332 } else if ([sender isKindOfClass:[NSMenuItem class]]) { |
| 333 tag = [sender tag]; | 333 tag = [sender tag]; |
| 334 } | 334 } |
| 335 | 335 |
| 336 NSString* actionString = NSStringFromSelector(anAction); | 336 NSString* actionString = NSStringFromSelector(anAction); |
| 337 NSString* value = | 337 NSString* value = |
| 338 [NSString stringWithFormat:@"%@ tag %d sending %@ to %p", | 338 [NSString stringWithFormat:@"%@ tag %d sending %@ to %p", |
| 339 [sender className], tag, actionString, aTarget]; | 339 [sender className], tag, actionString, aTarget]; |
| 340 | 340 |
| 341 ScopedCrashKey key(kActionKey, value); | 341 base::mac::ScopedCrashKey key(kActionKey, value); |
| 342 | 342 |
| 343 // Certain third-party code, such as print drivers, can still throw | 343 // Certain third-party code, such as print drivers, can still throw |
| 344 // exceptions and Chromium cannot fix them. This provides a way to | 344 // exceptions and Chromium cannot fix them. This provides a way to |
| 345 // work around those on a spot basis. | 345 // work around those on a spot basis. |
| 346 bool enableNSExceptions = false; | 346 bool enableNSExceptions = false; |
| 347 | 347 |
| 348 // http://crbug.com/80686 , an Epson printer driver. | 348 // http://crbug.com/80686 , an Epson printer driver. |
| 349 if (anAction == @selector(selectPDE:)) { | 349 if (anAction == @selector(selectPDE:)) { |
| 350 enableNSExceptions = true; | 350 enableNSExceptions = true; |
| 351 } | 351 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // 10.6 has -[NSException callStackSymbols] | 399 // 10.6 has -[NSException callStackSymbols] |
| 400 // 10.5 has -[NSException callStackReturnAddresses] | 400 // 10.5 has -[NSException callStackReturnAddresses] |
| 401 // 10.5 has backtrace_symbols(). | 401 // 10.5 has backtrace_symbols(). |
| 402 // I've tried to combine the latter two, but got nothing useful. | 402 // I've tried to combine the latter two, but got nothing useful. |
| 403 // The addresses are right, though, maybe we could train the crash | 403 // The addresses are right, though, maybe we could train the crash |
| 404 // server to decode them for us. | 404 // server to decode them for us. |
| 405 | 405 |
| 406 NSString* value = [NSString stringWithFormat:@"%@ reason %@", | 406 NSString* value = [NSString stringWithFormat:@"%@ reason %@", |
| 407 [anException name], [anException reason]]; | 407 [anException name], [anException reason]]; |
| 408 if (!trackedFirstException) { | 408 if (!trackedFirstException) { |
| 409 SetCrashKeyValue(kFirstExceptionKey, value); | 409 base::mac::SetCrashKeyValue(kFirstExceptionKey, value); |
| 410 trackedFirstException = YES; | 410 trackedFirstException = YES; |
| 411 } else { | 411 } else { |
| 412 SetCrashKeyValue(kLastExceptionKey, value); | 412 base::mac::SetCrashKeyValue(kLastExceptionKey, value); |
| 413 } | 413 } |
| 414 | 414 |
| 415 reportingException = NO; | 415 reportingException = NO; |
| 416 } | 416 } |
| 417 | 417 |
| 418 [super reportException:anException]; | 418 [super reportException:anException]; |
| 419 } | 419 } |
| 420 | 420 |
| 421 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { | 421 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { |
| 422 if ([attribute isEqualToString:@"AXEnhancedUserInterface"] && | 422 if ([attribute isEqualToString:@"AXEnhancedUserInterface"] && |
| 423 [value intValue] == 1) { | 423 [value intValue] == 1) { |
| 424 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); | 424 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); |
| 425 for (TabContentsIterator it; | 425 for (TabContentsIterator it; |
| 426 !it.done(); | 426 !it.done(); |
| 427 ++it) { | 427 ++it) { |
| 428 if (TabContentsWrapper* contents = *it) { | 428 if (TabContentsWrapper* contents = *it) { |
| 429 if (RenderViewHost* rvh = contents->render_view_host()) { | 429 if (RenderViewHost* rvh = contents->render_view_host()) { |
| 430 rvh->EnableRendererAccessibility(); | 430 rvh->EnableRendererAccessibility(); |
| 431 } | 431 } |
| 432 } | 432 } |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 return [super accessibilitySetValue:value forAttribute:attribute]; | 435 return [super accessibilitySetValue:value forAttribute:attribute]; |
| 436 } | 436 } |
| 437 | 437 |
| 438 @end | 438 @end |
| OLD | NEW |