Index: chrome/browser/ui/cocoa/browser_window_utils.mm |
diff --git a/chrome/browser/ui/cocoa/browser_window_utils.mm b/chrome/browser/ui/cocoa/browser_window_utils.mm |
index 442463d7c5de09cacaee7ae1289912a34fbb0cac..8193b48c18c8571efdba69e4c389740c19333bcb 100644 |
--- a/chrome/browser/ui/cocoa/browser_window_utils.mm |
+++ b/chrome/browser/ui/cocoa/browser_window_utils.mm |
@@ -10,6 +10,8 @@ |
#include "chrome/app/chrome_command_ids.h" |
#include "chrome/browser/global_keyboard_shortcuts_mac.h" |
#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/browser_list.h" |
+#include "chrome/browser/ui/browser_window.h" |
#import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
#import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" |
#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
@@ -186,4 +188,22 @@ const CGFloat kPatternVerticalOffsetNoTabStrip = 3; |
SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly); |
} |
++ (void)selectPreviousActiveBrowserWindow:(Browser*)closedBrowser { |
+ if (![NSApp isActive] || closedBrowser != BrowserList::GetLastActive()) |
+ return; |
Scott Hess - ex-Googler
2012/02/09 22:51:54
Are you sure about the -isActive test? You would
jennb
2012/02/09 23:25:24
My thinking is that if Chrome is not active, then
|
+ |
+ // Select previous active window if this is the current active window. |
+ // Otherwise, OSX will always give focus to a Panel window after this one |
+ // is closed because Panels have a higher priority NSWindowLevel. |
+ BrowserList::const_reverse_iterator iter = BrowserList::begin_last_active(); |
+ BrowserList::const_reverse_iterator end = BrowserList::end_last_active(); |
+ for (; iter != end; ++iter) { |
+ Browser* browser = *iter; |
+ if (browser != closedBrowser && |
+ [browser->window()->GetNativeHandle() canBecomeKeyWindow]) { |
+ browser->window()->Activate(); |
+ return; |
+ } |
+ } |
+} |
Scott Hess - ex-Googler
2012/02/09 22:51:54
This will subvert the ordering logic if there are
jennb
2012/02/09 23:25:24
Thanks for pointing out the non-browser window cas
|
@end |