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

Side by Side Diff: chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm

Issue 1114803002: Mac: App menuBars: Ignore closing windows if they are not main (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cl format Created 5 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/cocoa/apps/app_shim_menu_controller_mac.h" 5 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h"
6 6
7 #include "base/mac/scoped_nsautorelease_pool.h" 7 #include "base/mac/scoped_nsautorelease_pool.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 extension = appWindow->GetExtension(); 387 extension = appWindow->GetExtension();
388 else 388 else
389 extension = apps::ExtensionAppShimHandler::GetAppForBrowser( 389 extension = apps::ExtensionAppShimHandler::GetAppForBrowser(
390 chrome::FindBrowserWithWindow(window)); 390 chrome::FindBrowserWithWindow(window));
391 391
392 if (extension) 392 if (extension)
393 [self addMenuItems:extension]; 393 [self addMenuItems:extension];
394 else 394 else
395 [self removeMenuItems]; 395 [self removeMenuItems];
396 } else if ([name isEqualToString:NSWindowWillCloseNotification]) { 396 } else if ([name isEqualToString:NSWindowWillCloseNotification]) {
397 // Always reset back to the Chrome menu. This once scanned [NSApp windows] 397 // If the window being closed has main status, reset back to the Chrome
398 // to predict whether we could expect another Chrome window to become main, 398 // menu. This once scanned [NSApp windows] to predict whether we could
399 // and skip the reset. However, panels need to do strange things during 399 // expect another Chrome window to become main, and skip the reset. However,
400 // window close to ensure panels never get chosen for key status over a 400 // panels need to do strange things during window close to ensure panels
401 // browser window (which is likely because they are given an elevated 401 // never get chosen for key status over a browser window (which is likely
402 // [NSWindow level]). Trying to handle this case is not robust. 402 // because they are given an elevated [NSWindow level]). Trying to handle
403 // Unfortunately, resetting the menu to Chrome unconditionally means that 403 // this case is not robust. Unfortunately, resetting the menu to Chrome
404 // if another packaged app window becomes key, the menu will flicker. 404 // unconditionally means that if another packaged app window becomes key,
405 // TODO(tapted): Investigate restoring the logic when the panel code is 405 // the menu will flicker. TODO(tapted): Investigate restoring the logic when
406 // removed. 406 // the panel code is removed.
407 [self removeMenuItems]; 407 if ([[notification object] isMainWindow])
408 [self removeMenuItems];
408 } else { 409 } else {
409 NOTREACHED(); 410 NOTREACHED();
410 } 411 }
411 } 412 }
412 413
413 - (void)addMenuItems:(const extensions::Extension*)app { 414 - (void)addMenuItems:(const extensions::Extension*)app {
414 NSString* appId = base::SysUTF8ToNSString(app->id()); 415 NSString* appId = base::SysUTF8ToNSString(app->id());
415 NSString* title = base::SysUTF8ToNSString(app->name()); 416 NSString* title = base::SysUTF8ToNSString(app->name());
416 417
417 if ([appId_ isEqualToString:appId]) 418 if ([appId_ isEqualToString:appId])
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 515
515 - (void)focusCurrentPlatformApp { 516 - (void)focusCurrentPlatformApp {
516 extensions::AppWindow* appWindow = 517 extensions::AppWindow* appWindow =
517 AppWindowRegistryUtil::GetAppWindowForNativeWindowAnyProfile( 518 AppWindowRegistryUtil::GetAppWindowForNativeWindowAnyProfile(
518 [NSApp keyWindow]); 519 [NSApp keyWindow]);
519 if (appWindow) 520 if (appWindow)
520 apps::ExtensionAppShimHandler::FocusAppForWindow(appWindow); 521 apps::ExtensionAppShimHandler::FocusAppForWindow(appWindow);
521 } 522 }
522 523
523 @end 524 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698