Move mojo gypfiles to toplevel mojo
[chromium-blink-merge.git] / ui / message_center / cocoa / popup_collection.h
blob806114b75016006df893ff1e992c838e1be79029
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_MESSAGE_CENTER_COCOA_POPUP_COLLECTION_H_
6 #define UI_MESSAGE_CENTER_COCOA_POPUP_COLLECTION_H_
8 #import <Cocoa/Cocoa.h>
10 #include <set>
12 #include "base/mac/scoped_block.h"
13 #import "base/mac/scoped_nsobject.h"
14 #import "base/memory/scoped_ptr.h"
15 #include "ui/message_center/message_center_export.h"
17 namespace message_center {
18 class MessageCenter;
19 class MessageCenterObserver;
22 namespace message_center {
23 typedef void(^AnimationEndedCallback)();
26 // A popup collection interfaces with the MessageCenter as an observer. It will
27 // arrange notifications on the screen as popups, starting in the upper-right
28 // corner, going to the bottom of the screen. This class maintains ownership of
29 // the Cocoa controllers and windows of the notifications.
30 MESSAGE_CENTER_EXPORT
31 @interface MCPopupCollection : NSObject {
32 @private
33 // The message center that is responsible for the notifications. Weak, global.
34 message_center::MessageCenter* messageCenter_;
36 // MessageCenterObserver implementation.
37 scoped_ptr<message_center::MessageCenterObserver> observer_;
39 // Array of all on-screen popup notifications.
40 base::scoped_nsobject<NSMutableArray> popups_;
42 // Array of all on-screen popup notifications that are being faded out
43 // for removal.
44 base::scoped_nsobject<NSMutableArray> popupsBeingRemoved_;
46 // For testing only. If not a zero rect, this is the screen size to use
47 // for laying out popups.
48 NSRect testingScreenFrame_;
50 // The duration of the popup animation, in the number of seconds.
51 NSTimeInterval popupAnimationDuration_;
53 // Set of notification IDs for those popups to be updated when all existing
54 // animations end.
55 std::set<std::string> pendingUpdateNotificationIDs_;
57 // Set of notification IDs for those popups to be closed when all existing
58 // animations end.
59 std::set<std::string> pendingRemoveNotificationIDs_;
61 // Set of notification IDs for those popups that are being animated due to
62 // showing, bounds change or closing.
63 std::set<std::string> animatingNotificationIDs_;
65 // For testing only. If set, the callback will be called when the animation
66 // ends.
67 base::mac::ScopedBlock<message_center::AnimationEndedCallback>
68 testingAnimationEndedCallback_;
71 // Designated initializer that construct an instance to observe |messageCenter|.
72 - (id)initWithMessageCenter:(message_center::MessageCenter*)messageCenter;
74 // Returns true if an animation is being played.
75 - (BOOL)isAnimating;
77 // Returns the duration of the popup animation.
78 - (NSTimeInterval)popupAnimationDuration;
80 // Called when the animation of a popup ends.
81 - (void)onPopupAnimationEnded:(const std::string&)notificationID;
83 @end
85 @interface MCPopupCollection (ExposedForTesting)
86 - (NSArray*)popups;
88 // Setter for the testingScreenFrame_.
89 - (void)setScreenFrame:(NSRect)frame;
91 // Setter for changing the animation duration. The testing code could set it
92 // to a very small value to expedite the test running.
93 - (void)setAnimationDuration:(NSTimeInterval)duration;
95 // Setter for testingAnimationEndedCallback_. The testing code could set it
96 // to get called back when the animation ends.
97 - (void)setAnimationEndedCallback:
98 (message_center::AnimationEndedCallback)callback;
99 @end
101 #endif // UI_MESSAGE_CENTER_COCOA_POPUP_COLLECTION_H_