Note that promise is settled on reject. Add test coverage for Resolver.
[chromium-blink-merge.git] / ui / message_center / cocoa / popup_controller.h
blob47a052df97267acf3c47570622b8bfcab38fcf04
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_CONTROLLER_H_
6 #define UI_MESSAGE_CENTER_COCOA_POPUP_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
10 #include <string>
12 #import "base/mac/scoped_nsobject.h"
13 #import "ui/base/cocoa/tracking_area.h"
14 #include "ui/message_center/message_center_export.h"
16 namespace message_center {
17 class MessageCenter;
18 class Notification;
21 @class MCNotificationController;
22 @class MCPopupCollection;
24 // A window controller that hosts a notification as a popup balloon on the
25 // user's desktop. The window controller manages its lifetime because the
26 // popup collection will be destructed when the last popup is closed.
27 MESSAGE_CENTER_EXPORT
28 @interface MCPopupController : NSWindowController<NSAnimationDelegate> {
29 @private
30 // Global message center. Weak.
31 message_center::MessageCenter* messageCenter_;
33 // The collection that contains the popup. Weak.
34 MCPopupCollection* popupCollection_;
36 // The view controller that provide's the popup content view.
37 base::scoped_nsobject<MCNotificationController> notificationController_;
39 // If the swipe-away gesture received NSEventPhaseEnded.
40 BOOL swipeGestureEnded_;
42 // The frame of the popup before any swipe animation started. Used to
43 // calculate the animating position of the window when swiping away.
44 NSRect originalFrame_;
46 // Is the popup currently being closed?
47 BOOL isClosing_;
49 // The current bounds of the popup frame if no animation is playing.
50 // Otherwise, it is the target bounds of the popup frame.
51 NSRect bounds_;
53 // Used to play animation when the popup shows, changes bounds and closes.
54 base::scoped_nsobject<NSViewAnimation> boundsAnimation_;
56 // Used to track the popup for mouse entered and exited events.
57 ui::ScopedCrTrackingArea trackingArea_;
60 // Designated initializer.
61 - (id)initWithNotification:(const message_center::Notification*)notification
62 messageCenter:(message_center::MessageCenter*)messageCenter
63 popupCollection:(MCPopupCollection*)popupCollection;
65 // Accessor for the view controller.
66 - (MCNotificationController*)notificationController;
68 // Accessor for the notification model object.
69 - (const message_center::Notification*)notification;
71 // Gets the notification ID. This string is owned by the NotificationController
72 // rather than the model object, so it's safe to use after the Notification has
73 // been deleted.
74 - (const std::string&)notificationID;
76 // Shows the window with the sliding animation.
77 - (void)showWithAnimation:(NSRect)newBounds;
79 // Closes the window with the fade-out animation.
80 - (void)closeWithAnimation;
82 // Tells that the popupCollection_ is gone.
83 - (void)markPopupCollectionGone;
85 // Returns the window bounds. This is the target bounds to go to if the bounds
86 // animation is playing.
87 - (NSRect)bounds;
89 // Changes the window bounds with animation.
90 - (void)setBounds:(NSRect)newBounds;
92 @end
94 #endif // UI_MESSAGE_CENTER_COCOA_POPUP_CONTROLLER_H_