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

Unified Diff: chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm

Issue 1040993005: [Mac] A more robust way to ensure panels avoid key status on window close (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: static Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm
diff --git a/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm b/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm
index b437f6be5e65955cc82317edb33db9c632e8bca9..d0cf82813948187494708513f629c6ac4044d0d2 100644
--- a/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm
+++ b/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm
@@ -373,9 +373,9 @@ void SetItemWithTagVisible(NSMenuItem* top_level_item,
// http://crbug.com/406944.
base::mac::ScopedNSAutoreleasePool pool;
- id window = [notification object];
NSString* name = [notification name];
if ([name isEqualToString:NSWindowDidBecomeMainNotification]) {
+ id window = [notification object];
extensions::AppWindow* appWindow =
AppWindowRegistryUtil::GetAppWindowForNativeWindowAnyProfile(
window);
@@ -394,14 +394,16 @@ void SetItemWithTagVisible(NSMenuItem* top_level_item,
else
[self removeMenuItems];
} else if ([name isEqualToString:NSWindowWillCloseNotification]) {
- // If there are any other windows that can become main, leave the menu. It
- // will be changed when another window becomes main. Otherwise, restore the
- // Chrome menu.
- for (NSWindow* w : [NSApp windows]) {
- if ([w canBecomeMainWindow] && ![w isEqual:window] && [w isOnActiveSpace])
- return;
- }
-
+ // Always reset back to the Chrome menu. This once scanned [NSApp windows]
+ // to predict whether we could expect another Chrome window to become main,
+ // and skip the reset. However, panels need to do strange things during
+ // window close to ensure panels never get chosen for key status over a
+ // browser window (which is likely because they are given an elevated
+ // [NSWindow level]). Trying to handle this case is not robust.
+ // Unfortunately, resetting the menu to Chrome unconditionally means that
+ // if another packaged app window becomes key, the menu will flicker.
+ // TODO(tapted): Investigate restoring the logic when the panel code is
+ // removed.
[self removeMenuItems];
} else {
NOTREACHED();
« no previous file with comments | « chrome/browser/chrome_browser_application_mac.mm ('k') | chrome/browser/ui/cocoa/panels/panel_cocoa_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698