| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_browser_application_mac.h" | 5 #import "chrome/browser/chrome_browser_application_mac.h" | 
| 6 | 6 | 
| 7 #import "base/auto_reset.h" | 7 #import "base/auto_reset.h" | 
| 8 #import "base/logging.h" | 8 #import "base/logging.h" | 
| 9 #include "base/mac/crash_logging.h" | 9 #include "base/mac/crash_logging.h" | 
| 10 #import "base/mac/scoped_nsexception_enabler.h" | 10 #import "base/mac/scoped_nsexception_enabler.h" | 
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 324 // | 324 // | 
| 325 // |-tryToTerminateApplication:| differs from the standard | 325 // |-tryToTerminateApplication:| differs from the standard | 
| 326 // |-applicationShouldTerminate:| in that no special event loop is run in the | 326 // |-applicationShouldTerminate:| in that no special event loop is run in the | 
| 327 // case that immediate termination is not possible (e.g., if dialog boxes | 327 // case that immediate termination is not possible (e.g., if dialog boxes | 
| 328 // allowing the user to cancel have to be shown). Instead, this method sets a | 328 // allowing the user to cancel have to be shown). Instead, this method sets a | 
| 329 // flag and tries to close all browsers. This flag causes the closure of the | 329 // flag and tries to close all browsers. This flag causes the closure of the | 
| 330 // final browser window to begin actual tear-down of the application. | 330 // final browser window to begin actual tear-down of the application. | 
| 331 // Termination is cancelled by resetting this flag. The standard | 331 // Termination is cancelled by resetting this flag. The standard | 
| 332 // |-applicationShouldTerminate:| is not supported, and code paths leading to it | 332 // |-applicationShouldTerminate:| is not supported, and code paths leading to it | 
| 333 // must be redirected. | 333 // must be redirected. | 
|  | 334 // | 
|  | 335 // When the last browser has been destroyed, the BrowserList calls | 
|  | 336 // browser::OnAppExiting(), which is the point of no return. That will cause | 
|  | 337 // the NSApplicationWillTerminateNotification to be posted, which ends the | 
|  | 338 // NSApplication event loop, so final post- MessageLoop::Run() work is done | 
|  | 339 // before exiting. | 
| 334 - (void)terminate:(id)sender { | 340 - (void)terminate:(id)sender { | 
| 335   AppController* appController = static_cast<AppController*>([NSApp delegate]); | 341   AppController* appController = static_cast<AppController*>([NSApp delegate]); | 
| 336   if ([appController tryToTerminateApplication:self]) { | 342   [appController tryToTerminateApplication:self]; | 
| 337     [[NSNotificationCenter defaultCenter] |  | 
| 338         postNotificationName:NSApplicationWillTerminateNotification |  | 
| 339                       object:self]; |  | 
| 340   } |  | 
| 341 |  | 
| 342   // Return, don't exit. The application is responsible for exiting on its own. | 343   // Return, don't exit. The application is responsible for exiting on its own. | 
| 343 } | 344 } | 
| 344 | 345 | 
| 345 - (void)cancelTerminate:(id)sender { | 346 - (void)cancelTerminate:(id)sender { | 
| 346   AppController* appController = static_cast<AppController*>([NSApp delegate]); | 347   AppController* appController = static_cast<AppController*>([NSApp delegate]); | 
| 347   [appController stopTryingToTerminateApplication:self]; | 348   [appController stopTryingToTerminateApplication:self]; | 
| 348 } | 349 } | 
| 349 | 350 | 
| 350 - (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)sender { | 351 - (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)sender { | 
| 351   // The Dock menu contains an automagic section where you can select | 352   // The Dock menu contains an automagic section where you can select | 
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 574   std::vector<NSWindow*>::iterator window_iterator = | 575   std::vector<NSWindow*>::iterator window_iterator = | 
| 575       std::find(previousKeyWindows_.begin(), | 576       std::find(previousKeyWindows_.begin(), | 
| 576                 previousKeyWindows_.end(), | 577                 previousKeyWindows_.end(), | 
| 577                 window); | 578                 window); | 
| 578   if (window_iterator != previousKeyWindows_.end()) { | 579   if (window_iterator != previousKeyWindows_.end()) { | 
| 579     previousKeyWindows_.erase(window_iterator); | 580     previousKeyWindows_.erase(window_iterator); | 
| 580   } | 581   } | 
| 581 } | 582 } | 
| 582 | 583 | 
| 583 @end | 584 @end | 
| OLD | NEW | 
|---|