| Index: chrome/browser/ui/cocoa/base_bubble_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/base_bubble_controller.mm b/chrome/browser/ui/cocoa/base_bubble_controller.mm
|
| index 7be153afcf4d6359cf50deb6c7e4d2872381ce8e..2cc0a965300b87f4e6e9802316e20385f86f6293 100644
|
| --- a/chrome/browser/ui/cocoa/base_bubble_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/base_bubble_controller.mm
|
| @@ -241,19 +241,26 @@
|
| - (void)windowDidResignKey:(NSNotification*)notification {
|
| NSWindow* window = [self window];
|
| DCHECK_EQ([notification object], window);
|
| - if ([window isVisible] && [self shouldCloseOnResignKey]) {
|
| - // If the window isn't visible, it is already closed, and this notification
|
| - // has been sent as part of the closing operation, so no need to close.
|
| +
|
| + // If the window isn't visible, it is already closed, and this notification
|
| + // has been sent as part of the closing operation, so no need to close.
|
| + if (![window isVisible])
|
| + return;
|
| +
|
| + // Don't close when explicily disabled, or if there's an attached sheet (e.g.
|
| + // Open File dialog).
|
| + if ([self shouldCloseOnResignKey] && ![window attachedSheet]) {
|
| [self close];
|
| - } else if ([window isVisible]) {
|
| - // The bubble should not receive key events when it is no longer key window,
|
| - // so disable sharing parent key state. Share parent key state is only used
|
| - // to enable the close/minimize/maximize buttons of the parent window when
|
| - // the bubble has key state, so disabling it here is safe.
|
| - InfoBubbleWindow* bubbleWindow =
|
| - base::mac::ObjCCastStrict<InfoBubbleWindow>([self window]);
|
| - [bubbleWindow setAllowShareParentKeyState:NO];
|
| + return;
|
| }
|
| +
|
| + // The bubble should not receive key events when it is no longer key window,
|
| + // so disable sharing parent key state. Share parent key state is only used
|
| + // to enable the close/minimize/maximize buttons of the parent window when
|
| + // the bubble has key state, so disabling it here is safe.
|
| + InfoBubbleWindow* bubbleWindow =
|
| + base::mac::ObjCCastStrict<InfoBubbleWindow>([self window]);
|
| + [bubbleWindow setAllowShareParentKeyState:NO];
|
| }
|
|
|
| - (void)windowDidBecomeKey:(NSNotification*)notification {
|
| @@ -264,9 +271,13 @@
|
| [bubbleWindow setAllowShareParentKeyState:YES];
|
| }
|
|
|
| -// Since the bubble shares first responder with its parent window, set
|
| -// event handlers to dismiss the bubble when it would normally lose key
|
| -// state.
|
| +// Since the bubble shares first responder with its parent window, set event
|
| +// handlers to dismiss the bubble when it would normally lose key state.
|
| +// Events on sheets are ignored: this assumes the sheet belongs to the bubble
|
| +// since, to affect a sheet on a different window, the bubble would also lose
|
| +// key status in -[NSWindowDelegate windowDidResignKey:]. This keeps the logic
|
| +// simple, since -[NSWindow attachedSheet] returns nil while the sheet is still
|
| +// closing.
|
| - (void)registerKeyStateEventTap {
|
| // Parent key state sharing is only avaiable on 10.7+.
|
| if (!base::mac::IsOSLionOrLater())
|
| @@ -283,7 +294,7 @@
|
| addLocalMonitorForEventsMatchingMask:NSLeftMouseDownMask |
|
| NSRightMouseDownMask
|
| handler:^NSEvent* (NSEvent* event) {
|
| - if (event.window != window) {
|
| + if ([event window] != window && ![[event window] isSheet]) {
|
| // Do it right now, because if this event is right mouse event,
|
| // it may pop up a menu. windowDidResignKey: will not run until
|
| // the menu is closed.
|
| @@ -302,7 +313,8 @@
|
| object:nil
|
| queue:[NSOperationQueue mainQueue]
|
| usingBlock:^(NSNotification* notif) {
|
| - [self windowDidResignKey:note];
|
| + if (![[notif object] isSheet])
|
| + [self windowDidResignKey:note];
|
| }];
|
| }
|
|
|
|
|