| 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/ui/cocoa/info_bubble_window.h" | 5 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #import "base/mac/foundation_util.h" |
| 11 #import "base/mac/scoped_nsobject.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| 13 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 16 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h
" | 18 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h
" |
| 17 | 19 |
| 18 namespace { | 20 namespace { |
| 19 const CGFloat kOrderInSlideOffset = 10; | 21 const CGFloat kOrderInSlideOffset = 10; |
| 20 const NSTimeInterval kOrderInAnimationDuration = 0.075; | 22 const NSTimeInterval kOrderInAnimationDuration = 0.075; |
| 21 const NSTimeInterval kOrderOutAnimationDuration = 0.15; | 23 const NSTimeInterval kOrderOutAnimationDuration = 0.15; |
| 22 // The minimum representable time interval. This can be used as the value | 24 // The minimum representable time interval. This can be used as the value |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 [animations setObject:alphaAnimation forKey:@"alphaValue"]; | 136 [animations setObject:alphaAnimation forKey:@"alphaValue"]; |
| 135 [self setAnimations:animations]; | 137 [self setAnimations:animations]; |
| 136 } | 138 } |
| 137 return self; | 139 return self; |
| 138 } | 140 } |
| 139 | 141 |
| 140 - (BOOL)performKeyEquivalent:(NSEvent*)event { | 142 - (BOOL)performKeyEquivalent:(NSEvent*)event { |
| 141 if (([event keyCode] == kVK_Escape) || | 143 if (([event keyCode] == kVK_Escape) || |
| 142 (([event keyCode] == kVK_ANSI_Period) && | 144 (([event keyCode] == kVK_ANSI_Period) && |
| 143 (([event modifierFlags] & NSCommandKeyMask) != 0))) { | 145 (([event modifierFlags] & NSCommandKeyMask) != 0))) { |
| 144 [[self windowController] cancel:self]; | 146 BaseBubbleController* bubbleController = |
| 147 base::mac::ObjCCastStrict<BaseBubbleController>( |
| 148 [self windowController]); |
| 149 [bubbleController cancel:self]; |
| 145 return YES; | 150 return YES; |
| 146 } | 151 } |
| 147 return [super performKeyEquivalent:event]; | 152 return [super performKeyEquivalent:event]; |
| 148 } | 153 } |
| 149 | 154 |
| 150 // According to | 155 // According to |
| 151 // http://www.cocoabuilder.com/archive/message/cocoa/2006/6/19/165953, | 156 // http://www.cocoabuilder.com/archive/message/cocoa/2006/6/19/165953, |
| 152 // NSBorderlessWindowMask windows cannot become key or main. In this | 157 // NSBorderlessWindowMask windows cannot become key or main. In this |
| 153 // case, this is not necessarily a desired behavior. As an example, the | 158 // case, this is not necessarily a desired behavior. As an example, the |
| 154 // bubble could have buttons. | 159 // bubble could have buttons. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 254 |
| 250 // Override -[NSWindow addChildWindow] to prevent ShareKit bugs propagating | 255 // Override -[NSWindow addChildWindow] to prevent ShareKit bugs propagating |
| 251 // to the browser window. See http://crbug.com/475855. | 256 // to the browser window. See http://crbug.com/475855. |
| 252 - (void)addChildWindow:(NSWindow*)childWindow | 257 - (void)addChildWindow:(NSWindow*)childWindow |
| 253 ordered:(NSWindowOrderingMode)orderingMode { | 258 ordered:(NSWindowOrderingMode)orderingMode { |
| 254 [[self parentWindow] removeChildWindow:self]; | 259 [[self parentWindow] removeChildWindow:self]; |
| 255 [super addChildWindow:childWindow ordered:orderingMode]; | 260 [super addChildWindow:childWindow ordered:orderingMode]; |
| 256 } | 261 } |
| 257 | 262 |
| 258 @end | 263 @end |
| OLD | NEW |