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

Side by Side Diff: chrome/browser/chrome_browser_application_mac.mm

Issue 11667005: Drop event hooking in CrApplication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/auto_reset.h" 7 #import "base/auto_reset.h"
8 #import "base/logging.h" 8 #import "base/logging.h"
9 #include "base/mac/crash_logging.h" 9 #include "base/mac/crash_logging.h"
10 #import "base/mac/scoped_nsexception_enabler.h" 10 #import "base/mac/scoped_nsexception_enabler.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 @implementation BrowserCrApplication 223 @implementation BrowserCrApplication
224 224
225 + (void)initialize { 225 + (void)initialize {
226 // Turn all deallocated Objective-C objects into zombies, keeping 226 // Turn all deallocated Objective-C objects into zombies, keeping
227 // the most recent 10,000 of them on the treadmill. 227 // the most recent 10,000 of them on the treadmill.
228 ObjcEvilDoers::ZombieEnable(true, 10000); 228 ObjcEvilDoers::ZombieEnable(true, 10000);
229 } 229 }
230 230
231 - (id)init { 231 - (id)init {
232 SwizzleInit(); 232 SwizzleInit();
233 if ((self = [super init])) { 233 self = [super init];
234 eventHooks_.reset([[NSMutableArray alloc] init]);
235 }
236 234
237 // Sanity check to alert if overridden methods are not supported. 235 // Sanity check to alert if overridden methods are not supported.
238 DCHECK([NSApplication 236 DCHECK([NSApplication
239 instancesRespondToSelector:@selector(_cycleWindowsReversed:)]); 237 instancesRespondToSelector:@selector(_cycleWindowsReversed:)]);
240 DCHECK([NSApplication 238 DCHECK([NSApplication
241 instancesRespondToSelector:@selector(_removeWindow:)]); 239 instancesRespondToSelector:@selector(_removeWindow:)]);
242 DCHECK([NSApplication 240 DCHECK([NSApplication
243 instancesRespondToSelector:@selector(_setKeyWindow:)]); 241 instancesRespondToSelector:@selector(_setKeyWindow:)]);
244 242
245 return self; 243 return self;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 enableNSExceptions = true; 403 enableNSExceptions = true;
406 } 404 }
407 405
408 // Minimize the window by keeping this close to the super call. 406 // Minimize the window by keeping this close to the super call.
409 scoped_ptr<base::mac::ScopedNSExceptionEnabler> enabler(NULL); 407 scoped_ptr<base::mac::ScopedNSExceptionEnabler> enabler(NULL);
410 if (enableNSExceptions) 408 if (enableNSExceptions)
411 enabler.reset(new base::mac::ScopedNSExceptionEnabler()); 409 enabler.reset(new base::mac::ScopedNSExceptionEnabler());
412 return [super sendAction:anAction to:aTarget from:sender]; 410 return [super sendAction:anAction to:aTarget from:sender];
413 } 411 }
414 412
415 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)handler {
416 [eventHooks_ addObject:handler];
417 }
418
419 - (void)removeEventHook:(id<CrApplicationEventHookProtocol>)handler {
420 [eventHooks_ removeObject:handler];
421 }
422
423 - (BOOL)isHandlingSendEvent { 413 - (BOOL)isHandlingSendEvent {
424 return handlingSendEvent_; 414 return handlingSendEvent_;
425 } 415 }
426 416
427 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent { 417 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
428 handlingSendEvent_ = handlingSendEvent; 418 handlingSendEvent_ = handlingSendEvent;
429 } 419 }
430 420
431 - (void)sendEvent:(NSEvent*)event { 421 - (void)sendEvent:(NSEvent*)event {
432 base::mac::ScopedSendingEvent sendingEventScoper; 422 base::mac::ScopedSendingEvent sendingEventScoper;
433 for (id<CrApplicationEventHookProtocol> handler in eventHooks_.get()) {
434 [handler hookForEvent:event];
435 }
436 [super sendEvent:event]; 423 [super sendEvent:event];
437 } 424 }
438 425
439 // NSExceptions which are caught by the event loop are logged here. 426 // NSExceptions which are caught by the event loop are logged here.
440 // NSException uses setjmp/longjmp, which can be very bad for C++, so 427 // NSException uses setjmp/longjmp, which can be very bad for C++, so
441 // we attempt to track and report them. 428 // we attempt to track and report them.
442 - (void)reportException:(NSException *)anException { 429 - (void)reportException:(NSException *)anException {
443 // If we throw an exception in this code, we can create an infinite 430 // If we throw an exception in this code, we can create an infinite
444 // loop. If we throw out of the if() without resetting 431 // loop. If we throw out of the if() without resetting
445 // |reportException|, we'll stop reporting exceptions for this run. 432 // |reportException|, we'll stop reporting exceptions for this run.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 std::vector<NSWindow*>::iterator window_iterator = 571 std::vector<NSWindow*>::iterator window_iterator =
585 std::find(previousKeyWindows_.begin(), 572 std::find(previousKeyWindows_.begin(),
586 previousKeyWindows_.end(), 573 previousKeyWindows_.end(),
587 window); 574 window);
588 if (window_iterator != previousKeyWindows_.end()) { 575 if (window_iterator != previousKeyWindows_.end()) {
589 previousKeyWindows_.erase(window_iterator); 576 previousKeyWindows_.erase(window_iterator);
590 } 577 }
591 } 578 }
592 579
593 @end 580 @end
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_application_mac.h ('k') | chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698