• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef UI_MESSAGE_CENTER_COCOA_NOTIFICATION_CONTROLLER_H_
6 #define UI_MESSAGE_CENTER_COCOA_NOTIFICATION_CONTROLLER_H_
7 
8 #import <Cocoa/Cocoa.h>
9 
10 #include <string>
11 
12 #import "base/mac/scoped_nsobject.h"
13 #include "ui/message_center/message_center_export.h"
14 
15 namespace message_center {
16 class MessageCenter;
17 class Notification;
18 }
19 
20 @class HoverImageButton;
21 
22 // The base view controller class for notifications. A notification at minimum
23 // has an image, title, body, and close button. This controller can be used as
24 // the content for both a popup bubble and a view in the notification tray.
25 MESSAGE_CENTER_EXPORT
26 @interface MCNotificationController : NSViewController {
27  @protected
28   // The message object. Weak.
29   const message_center::Notification* notification_;
30 
31   // A copy of the notification ID.
32   std::string notificationID_;
33 
34   // Controller of the notifications, where action messages are forwarded. Weak.
35   message_center::MessageCenter* messageCenter_;
36 
37   // The button that invokes |-close:|, in the upper-right corner.
38   base::scoped_nsobject<HoverImageButton> closeButton_;
39 
40   // The small icon associated with the notification, on the bottom right.
41   base::scoped_nsobject<NSImageView> smallImage_;
42 
43   // The large icon associated with the notification, on the left side.
44   base::scoped_nsobject<NSImageView> icon_;
45 
46   // The title of the message.
47   base::scoped_nsobject<NSTextView> title_;
48 
49   // Body text of the message. Hidden for list notifications.
50   base::scoped_nsobject<NSTextView> message_;
51 
52   // Context-giving text of the message.  Alternate font used to distinguish it.
53   base::scoped_nsobject<NSTextView> contextMessage_;
54 
55   // Container for optional list view that contains multiple items.
56   base::scoped_nsobject<NSView> listView_;
57 
58   // Container for optional progress bar view.
59   base::scoped_nsobject<NSProgressIndicator> progressBarView_;
60 
61   // Container for optional items at the bottom of the notification.
62   base::scoped_nsobject<NSView> bottomView_;
63 }
64 
65 // Creates a new controller for a given notification.
66 - (id)initWithNotification:(const message_center::Notification*)notification
67     messageCenter:(message_center::MessageCenter*)messageCenter;
68 
69 // If the model object changes, this method will update the views to reflect
70 // the new model object. Returns the updated frame of the notification.
71 - (NSRect)updateNotification:(const message_center::Notification*)notification;
72 
73 // Action for clicking on the notification's |closeButton_|.
74 - (void)close:(id)sender;
75 
76 // Accessor for the notification.
77 - (const message_center::Notification*)notification;
78 
79 // Gets the notification ID. This string is owned by the NotificationController
80 // rather than the model object, so it's safe to use after the Notification has
81 // been deleted.
82 - (const std::string&)notificationID;
83 
84 // Called when the user clicks within the notification view.
85 - (void)notificationClicked;
86 
87 @end
88 
89 @interface MCNotificationController (TestingInterface)
90 - (NSImageView*)smallImageView;
91 - (NSImageView*)iconView;
92 @end
93 
94 #endif  // UI_MESSAGE_CENTER_COCOA_NOTIFICATION_CONTROLLER_H_
95