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

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

Issue 11498008: RenderWidget popup should be a NSWindow so it can go outside the main window. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created EventHookApplication in content Created 8 years 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
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 + (void)initialize { 226 + (void)initialize {
227 // Turn all deallocated Objective-C objects into zombies, keeping 227 // Turn all deallocated Objective-C objects into zombies, keeping
228 // the most recent 10,000 of them on the treadmill. 228 // the most recent 10,000 of them on the treadmill.
229 ObjcEvilDoers::ZombieEnable(true, 10000); 229 ObjcEvilDoers::ZombieEnable(true, 10000);
230 } 230 }
231 231
232 - (id)init { 232 - (id)init {
233 SwizzleInit(); 233 SwizzleInit();
234 if ((self = [super init])) { 234 if ((self = [super init])) {
235 eventHooks_.reset([[NSMutableArray alloc] init]);
236 } 235 }
237 236
238 // Sanity check to alert if overridden methods are not supported. 237 // Sanity check to alert if overridden methods are not supported.
239 DCHECK([NSApplication 238 DCHECK([NSApplication
240 instancesRespondToSelector:@selector(_cycleWindowsReversed:)]); 239 instancesRespondToSelector:@selector(_cycleWindowsReversed:)]);
241 DCHECK([NSApplication 240 DCHECK([NSApplication
242 instancesRespondToSelector:@selector(_removeWindow:)]); 241 instancesRespondToSelector:@selector(_removeWindow:)]);
243 DCHECK([NSApplication 242 DCHECK([NSApplication
244 instancesRespondToSelector:@selector(_setKeyWindow:)]); 243 instancesRespondToSelector:@selector(_setKeyWindow:)]);
245 244
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 enableNSExceptions = true; 405 enableNSExceptions = true;
407 } 406 }
408 407
409 // Minimize the window by keeping this close to the super call. 408 // Minimize the window by keeping this close to the super call.
410 scoped_ptr<base::mac::ScopedNSExceptionEnabler> enabler(NULL); 409 scoped_ptr<base::mac::ScopedNSExceptionEnabler> enabler(NULL);
411 if (enableNSExceptions) 410 if (enableNSExceptions)
412 enabler.reset(new base::mac::ScopedNSExceptionEnabler()); 411 enabler.reset(new base::mac::ScopedNSExceptionEnabler());
413 return [super sendAction:anAction to:aTarget from:sender]; 412 return [super sendAction:anAction to:aTarget from:sender];
414 } 413 }
415 414
416 - (void)addEventHook:(id<CrApplicationEventHookProtocol>)handler {
417 [eventHooks_ addObject:handler];
418 }
419
420 - (void)removeEventHook:(id<CrApplicationEventHookProtocol>)handler {
421 [eventHooks_ removeObject:handler];
422 }
423
424 - (BOOL)isHandlingSendEvent { 415 - (BOOL)isHandlingSendEvent {
425 return handlingSendEvent_; 416 return handlingSendEvent_;
426 } 417 }
427 418
428 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent { 419 - (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
429 handlingSendEvent_ = handlingSendEvent; 420 handlingSendEvent_ = handlingSendEvent;
430 } 421 }
431 422
432 - (void)sendEvent:(NSEvent*)event {
433 base::mac::ScopedSendingEvent sendingEventScoper;
434 for (id<CrApplicationEventHookProtocol> handler in eventHooks_.get()) {
435 [handler hookForEvent:event];
436 }
437 [super sendEvent:event];
438 }
439
440 // NSExceptions which are caught by the event loop are logged here. 423 // NSExceptions which are caught by the event loop are logged here.
441 // NSException uses setjmp/longjmp, which can be very bad for C++, so 424 // NSException uses setjmp/longjmp, which can be very bad for C++, so
442 // we attempt to track and report them. 425 // we attempt to track and report them.
443 - (void)reportException:(NSException *)anException { 426 - (void)reportException:(NSException *)anException {
444 // If we throw an exception in this code, we can create an infinite 427 // If we throw an exception in this code, we can create an infinite
445 // loop. If we throw out of the if() without resetting 428 // loop. If we throw out of the if() without resetting
446 // |reportException|, we'll stop reporting exceptions for this run. 429 // |reportException|, we'll stop reporting exceptions for this run.
447 static BOOL reportingException = NO; 430 static BOOL reportingException = NO;
448 DCHECK(!reportingException); 431 DCHECK(!reportingException);
449 if (!reportingException) { 432 if (!reportingException) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 std::vector<NSWindow*>::iterator window_iterator = 552 std::vector<NSWindow*>::iterator window_iterator =
570 std::find(previousKeyWindows_.begin(), 553 std::find(previousKeyWindows_.begin(),
571 previousKeyWindows_.end(), 554 previousKeyWindows_.end(),
572 window); 555 window);
573 if (window_iterator != previousKeyWindows_.end()) { 556 if (window_iterator != previousKeyWindows_.end()) {
574 previousKeyWindows_.erase(window_iterator); 557 previousKeyWindows_.erase(window_iterator);
575 } 558 }
576 } 559 }
577 560
578 @end 561 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698