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