1c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// found in the LICENSE file. 4c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 5c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#ifndef UI_MESSAGE_CENTER_COCOA_NOTIFICATION_CONTROLLER_H_ 6c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define UI_MESSAGE_CENTER_COCOA_NOTIFICATION_CONTROLLER_H_ 7c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 8c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#import <Cocoa/Cocoa.h> 9c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 10c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include <string> 11c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 12eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#import "base/mac/scoped_nsobject.h" 13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ui/message_center/message_center_export.h" 14c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 15c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace message_center { 16c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class MessageCenter; 17c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class Notification; 18c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 19c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)@class HoverImageButton; 21c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// The base view controller class for notifications. A notification at minimum 23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// has an image, title, body, and close button. This controller can be used as 24c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// the content for both a popup bubble and a view in the notification tray. 25c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MESSAGE_CENTER_EXPORT 26c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)@interface MCNotificationController : NSViewController { 27c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) @protected 28c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // The message object. Weak. 29c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const message_center::Notification* notification_; 30c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 31c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // A copy of the notification ID. 32c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) std::string notificationID_; 33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 34c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Controller of the notifications, where action messages are forwarded. Weak. 35c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) message_center::MessageCenter* messageCenter_; 36c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 37c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // The button that invokes |-close:|, in the upper-right corner. 38eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch base::scoped_nsobject<HoverImageButton> closeButton_; 39c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The small icon associated with the notification, on the bottom right. 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::scoped_nsobject<NSImageView> smallImage_; 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // The large icon associated with the notification, on the left side. 44eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch base::scoped_nsobject<NSImageView> icon_; 45c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 46c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // The title of the message. 4768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) base::scoped_nsobject<NSTextView> title_; 48c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 49a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // Body text of the message. Hidden for list notifications. 5068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) base::scoped_nsobject<NSTextView> message_; 5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Context-giving text of the message. Alternate font used to distinguish it. 5368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) base::scoped_nsobject<NSTextView> contextMessage_; 5458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 5568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // Container for optional list view that contains multiple items. 5668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) base::scoped_nsobject<NSView> listView_; 57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 58558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch // Container for optional progress bar view. 59558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch base::scoped_nsobject<NSProgressIndicator> progressBarView_; 60558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch 6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Container for optional items at the bottom of the notification. 62eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch base::scoped_nsobject<NSView> bottomView_; 63c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 64c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 65c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Creates a new controller for a given notification. 66c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)- (id)initWithNotification:(const message_center::Notification*)notification 67c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) messageCenter:(message_center::MessageCenter*)messageCenter; 68c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 69b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)// If the model object changes, this method will update the views to reflect 70b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)// the new model object. Returns the updated frame of the notification. 71b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)- (NSRect)updateNotification:(const message_center::Notification*)notification; 72b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 73c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Action for clicking on the notification's |closeButton_|. 74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)- (void)close:(id)sender; 75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Accessor for the notification. 77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)- (const message_center::Notification*)notification; 78c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 79c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Gets the notification ID. This string is owned by the NotificationController 80c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// rather than the model object, so it's safe to use after the Notification has 81c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// been deleted. 82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)- (const std::string&)notificationID; 83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 84868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Called when the user clicks within the notification view. 85868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)- (void)notificationClicked; 86868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 87c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)@end 88c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 897dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch@interface MCNotificationController (TestingInterface) 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)- (NSImageView*)smallImageView; 917dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch- (NSImageView*)iconView; 927dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch@end 937dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 94c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif // UI_MESSAGE_CENTER_COCOA_NOTIFICATION_CONTROLLER_H_ 95