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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 #import <QuartzCore/QuartzCore.h> | 6 #import <QuartzCore/QuartzCore.h> |
7 | 7 |
8 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" | 8 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 12 #import "base/mac/sdk_forward_declarations.h" |
12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
13 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
18 #include "chrome/browser/ui/cocoa/confirm_quit.h" | 19 #include "chrome/browser/ui/cocoa/confirm_quit.h" |
19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
20 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
21 #include "components/prefs/pref_registry_simple.h" | 22 #include "components/prefs/pref_registry_simple.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 163 |
163 - (void)animationDidStop:(NSAnimation*)anim { | 164 - (void)animationDidStop:(NSAnimation*)anim { |
164 DCHECK_EQ(self, anim); | 165 DCHECK_EQ(self, anim); |
165 [self autorelease]; | 166 [self autorelease]; |
166 } | 167 } |
167 | 168 |
168 @end | 169 @end |
169 | 170 |
170 // Private Interface /////////////////////////////////////////////////////////// | 171 // Private Interface /////////////////////////////////////////////////////////// |
171 | 172 |
172 @interface ConfirmQuitPanelController (Private) | 173 @interface ConfirmQuitPanelController (Private) <CAAnimationDelegate> |
173 - (void)animateFadeOut; | 174 - (void)animateFadeOut; |
174 - (NSEvent*)pumpEventQueueForKeyUp:(NSApplication*)app untilDate:(NSDate*)date; | 175 - (NSEvent*)pumpEventQueueForKeyUp:(NSApplication*)app untilDate:(NSDate*)date; |
175 - (void)hideAllWindowsForApplication:(NSApplication*)app | 176 - (void)hideAllWindowsForApplication:(NSApplication*)app |
176 withDuration:(NSTimeInterval)duration; | 177 withDuration:(NSTimeInterval)duration; |
177 // Returns the Accelerator for the Quit menu item. | 178 // Returns the Accelerator for the Quit menu item. |
178 + (std::unique_ptr<ui::PlatformAcceleratorCocoa>)quitAccelerator; | 179 + (std::unique_ptr<ui::PlatformAcceleratorCocoa>)quitAccelerator; |
179 @end | 180 @end |
180 | 181 |
181 ConfirmQuitPanelController* g_confirmQuitPanelController = nil; | 182 ConfirmQuitPanelController* g_confirmQuitPanelController = nil; |
182 | 183 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 [[window animationForKey:@"alphaValue"] copy]); | 349 [[window animationForKey:@"alphaValue"] copy]); |
349 [animation setDelegate:self]; | 350 [animation setDelegate:self]; |
350 [animation setDuration:0.2]; | 351 [animation setDuration:0.2]; |
351 NSMutableDictionary* dictionary = | 352 NSMutableDictionary* dictionary = |
352 [NSMutableDictionary dictionaryWithDictionary:[window animations]]; | 353 [NSMutableDictionary dictionaryWithDictionary:[window animations]]; |
353 [dictionary setObject:animation forKey:@"alphaValue"]; | 354 [dictionary setObject:animation forKey:@"alphaValue"]; |
354 [window setAnimations:dictionary]; | 355 [window setAnimations:dictionary]; |
355 [[window animator] setAlphaValue:0.0]; | 356 [[window animator] setAlphaValue:0.0]; |
356 } | 357 } |
357 | 358 |
| 359 - (void)animationDidStart:(CAAnimation*)theAnimation { |
| 360 // CAAnimationDelegate method added on OSX 10.12. |
| 361 } |
| 362 |
358 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { | 363 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { |
359 [self close]; | 364 [self close]; |
360 } | 365 } |
361 | 366 |
362 // This looks at the Main Menu and determines what the user has set as the | 367 // This looks at the Main Menu and determines what the user has set as the |
363 // key combination for quit. It then gets the modifiers and builds a string | 368 // key combination for quit. It then gets the modifiers and builds a string |
364 // to display them. | 369 // to display them. |
365 + (NSString*)keyCommandString { | 370 + (NSString*)keyCommandString { |
366 std::unique_ptr<ui::PlatformAcceleratorCocoa> accelerator( | 371 std::unique_ptr<ui::PlatformAcceleratorCocoa> accelerator( |
367 [self quitAccelerator]); | 372 [self quitAccelerator]); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 if (modifiers & NSAlternateKeyMask) | 423 if (modifiers & NSAlternateKeyMask) |
419 [string appendString:@"\u2325"]; | 424 [string appendString:@"\u2325"]; |
420 if (modifiers & NSShiftKeyMask) | 425 if (modifiers & NSShiftKeyMask) |
421 [string appendString:@"\u21E7"]; | 426 [string appendString:@"\u21E7"]; |
422 | 427 |
423 [string appendString:[item.characters() uppercaseString]]; | 428 [string appendString:[item.characters() uppercaseString]]; |
424 return string; | 429 return string; |
425 } | 430 } |
426 | 431 |
427 @end | 432 @end |
OLD | NEW |