1 // Copyright 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_VIEWS_GROUP_VIEW_H_ 6 #define UI_MESSAGE_CENTER_VIEWS_GROUP_VIEW_H_ 7 8 #include "ui/gfx/image/image_skia.h" 9 #include "ui/message_center/views/message_center_controller.h" 10 #include "ui/message_center/views/message_center_view.h" 11 #include "ui/message_center/views/message_view.h" 12 13 namespace message_center { 14 15 class BoundedLabel; 16 class MessageCenter; 17 class NotificationButton; 18 19 // View that displays a placeholder representing several notifications and a 20 // button to expand it into a set of individual notifications. 21 class GroupView : public MessageView, public MessageViewController { 22 public: 23 // The group view currently shows the latest notificaiton w/o buttons 24 // and a single button like "N more from XYZ". 25 // Each GroupView has a notifier_id which it uses to report clicks and other 26 // user actions to Client. 27 GroupView(MessageCenterController* controller, 28 const NotifierId& notifier_id, 29 const Notification& last_notification, 30 const gfx::ImageSkia& group_icon, 31 int group_size); 32 33 virtual ~GroupView(); 34 35 // Overridden from views::View: 36 virtual gfx::Size GetPreferredSize() OVERRIDE; 37 virtual int GetHeightForWidth(int width) OVERRIDE; 38 virtual void Layout() OVERRIDE; 39 virtual void OnFocus() OVERRIDE; 40 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE; 41 42 // Overridden from MessageView: 43 virtual void ButtonPressed(views::Button* sender, 44 const ui::Event& event) OVERRIDE; 45 46 // Overridden from MessageViewController: 47 virtual void ClickOnNotification(const std::string& notification_id) OVERRIDE; 48 virtual void RemoveNotification(const std::string& notification_id, 49 bool by_user) OVERRIDE; 50 virtual void DisableNotificationsFromThisSource( 51 const NotifierId& notifier_id) OVERRIDE; 52 virtual void ShowNotifierSettingsBubble() OVERRIDE; 53 54 private: 55 MessageCenterController* controller_; // Weak, controls lifetime of views. 56 NotifierId notifier_id_; 57 string16 display_source_; 58 gfx::ImageSkia group_icon_; 59 int group_size_; 60 std::string last_notification_id_; 61 62 // Weak references to GroupView descendants owned by their parents. 63 views::View* background_view_; 64 views::View* top_view_; 65 views::View* bottom_view_; 66 BoundedLabel* title_view_; 67 BoundedLabel* message_view_; 68 BoundedLabel* context_message_view_; 69 views::View* icon_view_; 70 NotificationButton* more_button_; 71 72 DISALLOW_COPY_AND_ASSIGN(GroupView); 73 }; 74 75 } // namespace message_center 76 77 #endif // UI_MESSAGE_CENTER_VIEWS_GROUP_VIEW_H_ 78