| 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/extension_app_shim_handler_mac.h" | 7 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
| 8 #include "base/mac/scoped_nsautorelease_pool.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 11 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" | 12 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" |
| 12 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 13 #include "extensions/browser/app_window/app_window.h" | 14 #include "extensions/browser/app_window/app_window.h" |
| 14 #include "extensions/browser/app_window/app_window_registry.h" | 15 #include "extensions/browser/app_window/app_window_registry.h" |
| 15 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/l10n/l10n_util_mac.h" | 18 #include "ui/base/l10n/l10n_util_mac.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 object:nil]; | 271 object:nil]; |
| 271 | 272 |
| 272 [[NSNotificationCenter defaultCenter] | 273 [[NSNotificationCenter defaultCenter] |
| 273 addObserver:self | 274 addObserver:self |
| 274 selector:@selector(windowMainStatusChanged:) | 275 selector:@selector(windowMainStatusChanged:) |
| 275 name:NSWindowWillCloseNotification | 276 name:NSWindowWillCloseNotification |
| 276 object:nil]; | 277 object:nil]; |
| 277 } | 278 } |
| 278 | 279 |
| 279 - (void)windowMainStatusChanged:(NSNotification*)notification { | 280 - (void)windowMainStatusChanged:(NSNotification*)notification { |
| 281 // A Yosemite AppKit bug causes this notification to be sent during the |
| 282 // -dealloc for a specific NSWindow. Any autoreleases sent to that window |
| 283 // must be drained before the window finishes -dealloc. In this method, an |
| 284 // autorelease is sent by the invocation of [NSApp windows]. |
| 285 // http://crbug.com/406944. |
| 286 base::mac::ScopedNSAutoreleasePool pool; |
| 287 |
| 280 id window = [notification object]; | 288 id window = [notification object]; |
| 281 NSString* name = [notification name]; | 289 NSString* name = [notification name]; |
| 282 if ([name isEqualToString:NSWindowDidBecomeMainNotification]) { | 290 if ([name isEqualToString:NSWindowDidBecomeMainNotification]) { |
| 283 extensions::AppWindow* appWindow = | 291 extensions::AppWindow* appWindow = |
| 284 extensions::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile( | 292 extensions::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile( |
| 285 window); | 293 window); |
| 286 | 294 |
| 287 const extensions::Extension* extension = NULL; | 295 const extensions::Extension* extension = NULL; |
| 288 if (appWindow) | 296 if (appWindow) |
| 289 extension = appWindow->GetExtension(); | 297 extension = appWindow->GetExtension(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 386 |
| 379 - (void)focusCurrentPlatformApp { | 387 - (void)focusCurrentPlatformApp { |
| 380 extensions::AppWindow* appWindow = | 388 extensions::AppWindow* appWindow = |
| 381 extensions::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile( | 389 extensions::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile( |
| 382 [NSApp keyWindow]); | 390 [NSApp keyWindow]); |
| 383 if (appWindow) | 391 if (appWindow) |
| 384 apps::ExtensionAppShimHandler::FocusAppForWindow(appWindow); | 392 apps::ExtensionAppShimHandler::FocusAppForWindow(appWindow); |
| 385 } | 393 } |
| 386 | 394 |
| 387 @end | 395 @end |
| OLD | NEW |