| OLD | NEW |
| 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 "apps/app_shim/app_shim_mac.h" |
| 7 #include "apps/app_shim/extension_app_shim_handler_mac.h" | 8 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
| 8 #include "apps/shell_window.h" | 9 #include "apps/shell_window.h" |
| 9 #include "apps/shell_window_registry.h" | 10 #include "apps/shell_window_registry.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 13 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" | 14 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" |
| 14 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 object:nil]; | 271 object:nil]; |
| 271 } | 272 } |
| 272 | 273 |
| 273 - (void)windowMainStatusChanged:(NSNotification*)notification { | 274 - (void)windowMainStatusChanged:(NSNotification*)notification { |
| 274 id window = [notification object]; | 275 id window = [notification object]; |
| 275 NSString* name = [notification name]; | 276 NSString* name = [notification name]; |
| 276 if ([name isEqualToString:NSWindowDidBecomeMainNotification]) { | 277 if ([name isEqualToString:NSWindowDidBecomeMainNotification]) { |
| 277 apps::ShellWindow* shellWindow = | 278 apps::ShellWindow* shellWindow = |
| 278 apps::ShellWindowRegistry::GetShellWindowForNativeWindowAnyProfile( | 279 apps::ShellWindowRegistry::GetShellWindowForNativeWindowAnyProfile( |
| 279 window); | 280 window); |
| 280 if (shellWindow) | 281 if (shellWindow && apps::IsAppShimsEnabled()) |
| 281 [self addMenuItems:shellWindow->extension()]; | 282 [self addMenuItems:shellWindow->extension()]; |
| 282 else | 283 else |
| 283 [self removeMenuItems]; | 284 [self removeMenuItems]; |
| 284 } else if ([name isEqualToString:NSWindowWillCloseNotification]) { | 285 } else if ([name isEqualToString:NSWindowWillCloseNotification]) { |
| 285 // If there are any other windows that can become main, leave the menu. It | 286 // If there are any other windows that can become main, leave the menu. It |
| 286 // will be changed when another window becomes main. Otherwise, restore the | 287 // will be changed when another window becomes main. Otherwise, restore the |
| 287 // Chrome menu. | 288 // Chrome menu. |
| 288 for (NSWindow* w : [NSApp windows]) { | 289 for (NSWindow* w : [NSApp windows]) { |
| 289 if ([w canBecomeMainWindow] && ![w isEqual:window]) | 290 if ([w canBecomeMainWindow] && ![w isEqual:window]) |
| 290 return; | 291 return; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 368 |
| 368 - (void)focusCurrentPlatformApp { | 369 - (void)focusCurrentPlatformApp { |
| 369 apps::ShellWindow* shellWindow = | 370 apps::ShellWindow* shellWindow = |
| 370 apps::ShellWindowRegistry::GetShellWindowForNativeWindowAnyProfile( | 371 apps::ShellWindowRegistry::GetShellWindowForNativeWindowAnyProfile( |
| 371 [NSApp keyWindow]); | 372 [NSApp keyWindow]); |
| 372 if (shellWindow) | 373 if (shellWindow) |
| 373 apps::ExtensionAppShimHandler::FocusAppForWindow(shellWindow); | 374 apps::ExtensionAppShimHandler::FocusAppForWindow(shellWindow); |
| 374 } | 375 } |
| 375 | 376 |
| 376 @end | 377 @end |
| OLD | NEW |