1 // Copyright (c) 2012 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_NOTIFICATION_VIEW_H_ 6 #define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ 7 8 #include <vector> 9 10 #include "ui/message_center/message_center_export.h" 11 #include "ui/message_center/views/message_view.h" 12 13 namespace views { 14 class ProgressBar; 15 } 16 17 namespace message_center { 18 19 class BoundedLabel; 20 class MessageCenter; 21 22 // View that displays all current types of notification (web, basic, image, and 23 // list). Future notification types may be handled by other classes, in which 24 // case instances of those classes would be returned by the Create() factory 25 // method below. 26 class MESSAGE_CENTER_EXPORT NotificationView : public MessageView { 27 public: 28 // Creates appropriate MessageViews for notifications. Those currently are 29 // always NotificationView or MessageSimpleView instances but in the future 30 // may be instances of other classes, with the class depending on the 31 // notification type. A notification is top level if it needs to be rendered 32 // outside the browser window. No custom shadows are created for top level 33 // notifications on Linux with Aura. 34 static MessageView* Create(const Notification& notification, 35 MessageCenter* message_center, 36 MessageCenterTray* tray, 37 bool expanded, 38 bool top_level); 39 40 virtual ~NotificationView(); 41 42 // Overridden from views::View: 43 virtual gfx::Size GetPreferredSize() OVERRIDE; 44 virtual int GetHeightForWidth(int width) OVERRIDE; 45 virtual void Layout() OVERRIDE; 46 virtual void OnFocus() OVERRIDE; 47 virtual void ScrollRectToVisible(const gfx::Rect& rect) OVERRIDE; 48 virtual views::View* GetEventHandlerForPoint( 49 const gfx::Point& point) OVERRIDE; 50 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE; 51 52 // Overridden from MessageView: 53 virtual void ButtonPressed(views::Button* sender, 54 const ui::Event& event) OVERRIDE; 55 56 protected: 57 NotificationView(const Notification& notification, 58 MessageCenter* message_center, 59 MessageCenterTray* tray, 60 bool expanded); 61 62 private: 63 bool IsExpansionNeeded(int width); 64 bool IsMessageExpansionNeeded(int width); 65 int GetMessageLineLimit(int width); 66 int GetMessageLines(int width, int limit); 67 int GetMessageHeight(int width, int limit); 68 69 // Weak references to NotificationView descendants owned by their parents. 70 views::View* background_view_; 71 views::View* top_view_; 72 BoundedLabel* title_view_; 73 BoundedLabel* message_view_; 74 std::vector<views::View*> item_views_; 75 views::View* icon_view_; 76 views::View* bottom_view_; 77 views::View* image_view_; 78 views::ProgressBar* progress_bar_view_; 79 std::vector<views::View*> action_buttons_; 80 81 DISALLOW_COPY_AND_ASSIGN(NotificationView); 82 }; 83 84 } // namespace message_center 85 86 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_VIEW_H_ 87