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 #include "base/mac/crash_logging.h" |
9 #import "base/mac/scoped_nsexception_enabler.h" | 9 #import "base/mac/scoped_nsexception_enabler.h" |
10 #import "base/metrics/histogram.h" | 10 #import "base/metrics/histogram.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 @implementation BrowserCrApplication | 208 @implementation BrowserCrApplication |
209 | 209 |
210 + (void)initialize { | 210 + (void)initialize { |
211 // Turn all deallocated Objective-C objects into zombies, keeping | 211 // Turn all deallocated Objective-C objects into zombies, keeping |
212 // the most recent 10,000 of them on the treadmill. | 212 // the most recent 10,000 of them on the treadmill. |
213 ObjcEvilDoers::ZombieEnable(true, 10000); | 213 ObjcEvilDoers::ZombieEnable(true, 10000); |
214 } | 214 } |
215 | 215 |
216 - (id)init { | 216 - (id)init { |
217 SwizzleInit(); | 217 SwizzleInit(); |
218 return [super init]; | 218 if ((self = [super init])) { |
| 219 eventHooks_.reset([[NSMutableArray alloc] init]); |
| 220 } |
| 221 return self; |
219 } | 222 } |
220 | 223 |
221 //////////////////////////////////////////////////////////////////////////////// | 224 //////////////////////////////////////////////////////////////////////////////// |
222 // HISTORICAL COMMENT (by viettrungluu, from | 225 // HISTORICAL COMMENT (by viettrungluu, from |
223 // http://codereview.chromium.org/1520006 with mild editing): | 226 // http://codereview.chromium.org/1520006 with mild editing): |
224 // | 227 // |
225 // A quick summary of the state of things (before the changes to shutdown): | 228 // A quick summary of the state of things (before the changes to shutdown): |
226 // | 229 // |
227 // Currently, we are totally hosed (put in a bad state in which Cmd-W does the | 230 // Currently, we are totally hosed (put in a bad state in which Cmd-W does the |
228 // wrong thing, and which will probably eventually lead to a crash) if we begin | 231 // wrong thing, and which will probably eventually lead to a crash) if we begin |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 enableNSExceptions = true; | 353 enableNSExceptions = true; |
351 } | 354 } |
352 | 355 |
353 // Minimize the window by keeping this close to the super call. | 356 // Minimize the window by keeping this close to the super call. |
354 scoped_ptr<base::mac::ScopedNSExceptionEnabler> enabler(NULL); | 357 scoped_ptr<base::mac::ScopedNSExceptionEnabler> enabler(NULL); |
355 if (enableNSExceptions) | 358 if (enableNSExceptions) |
356 enabler.reset(new base::mac::ScopedNSExceptionEnabler()); | 359 enabler.reset(new base::mac::ScopedNSExceptionEnabler()); |
357 return [super sendAction:anAction to:aTarget from:sender]; | 360 return [super sendAction:anAction to:aTarget from:sender]; |
358 } | 361 } |
359 | 362 |
| 363 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)handler { |
| 364 [eventHooks_ addObject:handler]; |
| 365 } |
| 366 |
| 367 - (void)removeEventHook:(id<CrApplicationEventHookProtocol>)handler { |
| 368 [eventHooks_ removeObject:handler]; |
| 369 } |
| 370 |
| 371 - (void)sendEvent:(NSEvent*)event { |
| 372 content::mac::ScopedSendingEvent sendingEventScoper; |
| 373 for (id<CrApplicationEventHookProtocol> handler in eventHooks_.get()) { |
| 374 [handler hookForEvent:event]; |
| 375 } |
| 376 [super sendEvent:event]; |
| 377 } |
| 378 |
360 // NSExceptions which are caught by the event loop are logged here. | 379 // NSExceptions which are caught by the event loop are logged here. |
361 // NSException uses setjmp/longjmp, which can be very bad for C++, so | 380 // NSException uses setjmp/longjmp, which can be very bad for C++, so |
362 // we attempt to track and report them. | 381 // we attempt to track and report them. |
363 - (void)reportException:(NSException *)anException { | 382 - (void)reportException:(NSException *)anException { |
364 // If we throw an exception in this code, we can create an infinite | 383 // If we throw an exception in this code, we can create an infinite |
365 // loop. If we throw out of the if() without resetting | 384 // loop. If we throw out of the if() without resetting |
366 // |reportException|, we'll stop reporting exceptions for this run. | 385 // |reportException|, we'll stop reporting exceptions for this run. |
367 static BOOL reportingException = NO; | 386 static BOOL reportingException = NO; |
368 DCHECK(!reportingException); | 387 DCHECK(!reportingException); |
369 if (!reportingException) { | 388 if (!reportingException) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 if (RenderViewHost* rvh = contents->render_view_host()) { | 448 if (RenderViewHost* rvh = contents->render_view_host()) { |
430 rvh->EnableRendererAccessibility(); | 449 rvh->EnableRendererAccessibility(); |
431 } | 450 } |
432 } | 451 } |
433 } | 452 } |
434 } | 453 } |
435 return [super accessibilitySetValue:value forAttribute:attribute]; | 454 return [super accessibilitySetValue:value forAttribute:attribute]; |
436 } | 455 } |
437 | 456 |
438 @end | 457 @end |
OLD | NEW |