OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/memory/scoped_nsobject.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
12 #include "content/common/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
13 #include "content/public/browser/notification_types.h" | 13 #include "content/public/browser/notification_types.h" |
14 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" | 14 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 const CGFloat kOrderInSlideOffset = 10; | 17 const CGFloat kOrderInSlideOffset = 10; |
18 const NSTimeInterval kOrderInAnimationDuration = 0.075; | 18 const NSTimeInterval kOrderInAnimationDuration = 0.075; |
19 const NSTimeInterval kOrderOutAnimationDuration = 0.15; | 19 const NSTimeInterval kOrderOutAnimationDuration = 0.15; |
20 // The minimum representable time interval. This can be used as the value | 20 // The minimum representable time interval. This can be used as the value |
21 // passed to +[NSAnimationContext setDuration:] to stop an in-progress | 21 // passed to +[NSAnimationContext setDuration:] to stop an in-progress |
22 // animation as quickly as possible. | 22 // animation as quickly as possible. |
23 const NSTimeInterval kMinimumTimeInterval = | 23 const NSTimeInterval kMinimumTimeInterval = |
24 std::numeric_limits<NSTimeInterval>::min(); | 24 std::numeric_limits<NSTimeInterval>::min(); |
25 } | 25 } |
26 | 26 |
27 @interface InfoBubbleWindow(Private) | 27 @interface InfoBubbleWindow(Private) |
28 - (void)appIsTerminating; | 28 - (void)appIsTerminating; |
29 - (void)finishCloseAfterAnimation; | 29 - (void)finishCloseAfterAnimation; |
30 @end | 30 @end |
31 | 31 |
32 // A helper class to proxy app notifications to the window. | 32 // A helper class to proxy app notifications to the window. |
33 class AppNotificationBridge : public content::NotificationObserver { | 33 class AppNotificationBridge : public content::NotificationObserver { |
34 public: | 34 public: |
35 explicit AppNotificationBridge(InfoBubbleWindow* owner) : owner_(owner) { | 35 explicit AppNotificationBridge(InfoBubbleWindow* owner) : owner_(owner) { |
36 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, | 36 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, |
37 NotificationService::AllSources()); | 37 content::NotificationService::AllSources()); |
38 } | 38 } |
39 | 39 |
40 // Overridden from content::NotificationObserver. | 40 // Overridden from content::NotificationObserver. |
41 void Observe(int type, | 41 void Observe(int type, |
42 const content::NotificationSource& source, | 42 const content::NotificationSource& source, |
43 const content::NotificationDetails& details) { | 43 const content::NotificationDetails& details) { |
44 switch (type) { | 44 switch (type) { |
45 case content::NOTIFICATION_APP_TERMINATING: | 45 case content::NOTIFICATION_APP_TERMINATING: |
46 [owner_ appIsTerminating]; | 46 [owner_ appIsTerminating]; |
47 break; | 47 break; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 - (void)sendEvent:(NSEvent*)theEvent { | 221 - (void)sendEvent:(NSEvent*)theEvent { |
222 if (!closing_) | 222 if (!closing_) |
223 [super sendEvent:theEvent]; | 223 [super sendEvent:theEvent]; |
224 } | 224 } |
225 | 225 |
226 - (BOOL)isClosing { | 226 - (BOOL)isClosing { |
227 return closing_; | 227 return closing_; |
228 } | 228 } |
229 | 229 |
230 @end | 230 @end |
OLD | NEW |