| 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 #include <AvailabilityMacros.h> |
| 7 #include <objc/objc-exception.h> | 8 #include <objc/objc-exception.h> |
| 8 | 9 |
| 9 #import "base/auto_reset.h" | 10 #import "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/debug/crash_logging.h" | 12 #include "base/debug/crash_logging.h" |
| 12 #include "base/debug/stack_trace.h" | 13 #include "base/debug/stack_trace.h" |
| 13 #import "base/logging.h" | 14 #import "base/logging.h" |
| 14 #include "base/mac/call_with_eh_frame.h" | 15 #include "base/mac/call_with_eh_frame.h" |
| 15 #import "base/mac/scoped_nsobject.h" | 16 #import "base/mac/scoped_nsobject.h" |
| 16 #import "base/mac/scoped_objc_class_swizzler.h" | 17 #import "base/mac/scoped_objc_class_swizzler.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 AppController* appController = static_cast<AppController*>([NSApp delegate]); | 260 AppController* appController = static_cast<AppController*>([NSApp delegate]); |
| 260 [appController tryToTerminateApplication:self]; | 261 [appController tryToTerminateApplication:self]; |
| 261 // Return, don't exit. The application is responsible for exiting on its own. | 262 // Return, don't exit. The application is responsible for exiting on its own. |
| 262 } | 263 } |
| 263 | 264 |
| 264 - (void)cancelTerminate:(id)sender { | 265 - (void)cancelTerminate:(id)sender { |
| 265 AppController* appController = static_cast<AppController*>([NSApp delegate]); | 266 AppController* appController = static_cast<AppController*>([NSApp delegate]); |
| 266 [appController stopTryingToTerminateApplication:self]; | 267 [appController stopTryingToTerminateApplication:self]; |
| 267 } | 268 } |
| 268 | 269 |
| 270 // The event |mask| has historically been declared as an NSUInteger |
| 271 // (unsigned long). Starting in the 10.12 SDK, the mask type changed to |
| 272 // NSEventMask (unsigned long long) if __LP64__ and NSUInteger otherwise. |
| 273 // These types are incompatible, which creates an issue for suppporting |
| 274 // both 10.10/10.11 and 10.12 SDKs. Work around it using the #if below. |
| 275 - (NSEvent*)nextEventMatchingMask: |
| 276 #if !defined(MAC_OS_X_VERSION_10_12) || \ |
| 277 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 || \ |
| 278 !defined(__LP64__) |
| 279 (NSUInteger)mask |
| 280 #else |
| 281 (NSEventMask)mask |
| 282 #endif |
| 283 untilDate:(NSDate*)expiration |
| 284 inMode:(NSString*)mode |
| 285 dequeue:(BOOL)dequeue { |
| 286 __block NSEvent* event = nil; |
| 287 base::mac::CallWithEHFrame(^{ |
| 288 event = [super nextEventMatchingMask:mask |
| 289 untilDate:expiration |
| 290 inMode:mode |
| 291 dequeue:dequeue]; |
| 292 }); |
| 293 return event; |
| 294 } |
| 295 |
| 269 - (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)sender { | 296 - (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)sender { |
| 270 // The Dock menu contains an automagic section where you can select | 297 // The Dock menu contains an automagic section where you can select |
| 271 // amongst open windows. If a window is closed via JavaScript while | 298 // amongst open windows. If a window is closed via JavaScript while |
| 272 // the menu is up, the menu item for that window continues to exist. | 299 // the menu is up, the menu item for that window continues to exist. |
| 273 // When a window is selected this method is called with the | 300 // When a window is selected this method is called with the |
| 274 // now-freed window as |aTarget|. Short-circuit the call if | 301 // now-freed window as |aTarget|. Short-circuit the call if |
| 275 // |aTarget| is not a valid window. | 302 // |aTarget| is not a valid window. |
| 276 if (anAction == @selector(_selectWindow:)) { | 303 if (anAction == @selector(_selectWindow:)) { |
| 277 // Not using -[NSArray containsObject:] because |aTarget| may be a | 304 // Not using -[NSArray containsObject:] because |aTarget| may be a |
| 278 // freed object. | 305 // freed object. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 - (void)_cycleWindowsReversed:(BOOL)arg1 { | 389 - (void)_cycleWindowsReversed:(BOOL)arg1 { |
| 363 base::AutoReset<BOOL> pin(&cyclingWindows_, YES); | 390 base::AutoReset<BOOL> pin(&cyclingWindows_, YES); |
| 364 [super _cycleWindowsReversed:arg1]; | 391 [super _cycleWindowsReversed:arg1]; |
| 365 } | 392 } |
| 366 | 393 |
| 367 - (BOOL)isCyclingWindows { | 394 - (BOOL)isCyclingWindows { |
| 368 return cyclingWindows_; | 395 return cyclingWindows_; |
| 369 } | 396 } |
| 370 | 397 |
| 371 @end | 398 @end |
| OLD | NEW |