OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_BUBBLE_BASE_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_BUBBLE_BASE_H_ |
6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_BUBBLE_BASE_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_BUBBLE_BASE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "ui/gfx/native_widget_types.h" |
11 #include "ui/message_center/message_center.h" | 12 #include "ui/message_center/message_center.h" |
12 #include "ui/message_center/message_center_export.h" | 13 #include "ui/message_center/message_center_export.h" |
13 #include "ui/views/bubble/tray_bubble_view.h" | 14 #include "ui/views/bubble/tray_bubble_view.h" |
14 | 15 |
15 namespace message_center { | 16 namespace message_center { |
16 class MessageCenterTray; | 17 class MessageCenterTray; |
17 | 18 |
18 class MESSAGE_CENTER_EXPORT MessageBubbleBase { | 19 class MESSAGE_CENTER_EXPORT MessageBubbleBase { |
19 public: | 20 public: |
20 MessageBubbleBase(MessageCenter* message_center, MessageCenterTray* tray); | 21 MessageBubbleBase(MessageCenter* message_center, MessageCenterTray* tray); |
21 | 22 |
22 virtual ~MessageBubbleBase(); | 23 virtual ~MessageBubbleBase(); |
23 | 24 |
24 // Gets called when the bubble view associated with this bubble is | 25 // Gets called when the bubble view associated with this bubble is |
25 // destroyed. Clears |bubble_view_| and calls OnBubbleViewDestroyed. | 26 // destroyed. Clears |bubble_view_| and calls OnBubbleViewDestroyed. |
26 void BubbleViewDestroyed(); | 27 void BubbleViewDestroyed(); |
27 | 28 |
28 // Sets/Gets the maximum height of the bubble view. Setting 0 changes the | 29 // Sets/Gets the maximum height of the bubble view. Setting 0 changes the |
29 // bubble to the default size. max_height() will return the default size | 30 // bubble to the default size. max_height() will return the default size |
30 // if SetMaxHeight() has not been called yet. | 31 // if SetMaxHeight() has not been called yet. |
31 void SetMaxHeight(int height); | 32 void SetMaxHeight(int height); |
32 int max_height() const { return max_height_; } | 33 int max_height() const { return max_height_; } |
33 | 34 |
34 // Gets the init params for the implementation. | |
35 virtual views::TrayBubbleView::InitParams GetInitParams( | |
36 views::TrayBubbleView::AnchorAlignment anchor_alignment) = 0; | |
37 | |
38 // Called after the bubble view has been constructed. Creates and initializes | 35 // Called after the bubble view has been constructed. Creates and initializes |
39 // the bubble contents. | 36 // the bubble contents. |
40 virtual void InitializeContents(views::TrayBubbleView* bubble_view) = 0; | 37 virtual void InitializeContents(views::TrayBubbleView* bubble_view) = 0; |
41 | 38 |
42 // Called from BubbleViewDestroyed for implementation specific details. | 39 // Called from BubbleViewDestroyed for implementation specific details. |
43 virtual void OnBubbleViewDestroyed() = 0; | 40 virtual void OnBubbleViewDestroyed() = 0; |
44 | 41 |
45 // Updates the bubble; implementation dependent. | 42 // Updates the bubble; implementation dependent. |
46 virtual void UpdateBubbleView() = 0; | 43 virtual void UpdateBubbleView() = 0; |
47 | 44 |
48 // Called when the mouse enters/exists the view. | 45 // Called when the mouse enters/exists the view. |
49 virtual void OnMouseEnteredView() = 0; | 46 virtual void OnMouseEnteredView() = 0; |
50 virtual void OnMouseExitedView() = 0; | 47 virtual void OnMouseExitedView() = 0; |
51 | 48 |
52 // Schedules bubble for layout after all notifications have been | 49 // Schedules bubble for layout after all notifications have been |
53 // added and icons have had a chance to load. | 50 // added and icons have had a chance to load. |
54 void ScheduleUpdate(); | 51 void ScheduleUpdate(); |
55 | 52 |
56 bool IsVisible() const; | 53 bool IsVisible() const; |
57 | 54 |
58 views::TrayBubbleView* bubble_view() const { return bubble_view_; } | 55 views::TrayBubbleView* bubble_view() const { return bubble_view_; } |
59 | 56 |
60 protected: | 57 protected: |
61 views::TrayBubbleView::InitParams GetDefaultInitParams( | |
62 views::TrayBubbleView::AnchorAlignment anchor_alignment); | |
63 MessageCenter* message_center() { return message_center_; } | 58 MessageCenter* message_center() { return message_center_; } |
64 MessageCenterTray* tray() { return tray_; } | 59 MessageCenterTray* tray() { return tray_; } |
65 void set_bubble_view(views::TrayBubbleView* bubble_view) { | 60 void set_bubble_view(views::TrayBubbleView* bubble_view) { |
66 bubble_view_ = bubble_view; | 61 bubble_view_ = bubble_view; |
67 } | 62 } |
68 | 63 |
69 private: | 64 private: |
70 MessageCenter* message_center_; | 65 MessageCenter* message_center_; |
71 MessageCenterTray* tray_; | 66 MessageCenterTray* tray_; |
72 views::TrayBubbleView* bubble_view_; | 67 views::TrayBubbleView* bubble_view_; |
73 int max_height_; | 68 int max_height_; |
74 base::WeakPtrFactory<MessageBubbleBase> weak_ptr_factory_; | 69 base::WeakPtrFactory<MessageBubbleBase> weak_ptr_factory_; |
75 | 70 |
76 DISALLOW_COPY_AND_ASSIGN(MessageBubbleBase); | 71 DISALLOW_COPY_AND_ASSIGN(MessageBubbleBase); |
77 }; | 72 }; |
78 | 73 |
79 } // namespace message_center | 74 } // namespace message_center |
80 | 75 |
81 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_BUBBLE_BASE_H_ | 76 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_BUBBLE_BASE_H_ |
OLD | NEW |