blob: b92b7a4d981f6dd96d4bfc39fe173bcb0e16217e (
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// 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 ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_
#define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_
#pragma once
#include "ash/ash_export.h"
#include "ash/system/user/login_status.h"
#include "base/basictypes.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include <vector>
namespace ash {
class AudioObserver;
class BrightnessObserver;
class DateFormatObserver;
class NetworkObserver;
class PowerStatusObserver;
class UpdateObserver;
class SystemTrayItem;
namespace internal {
class SystemTrayBubble;
}
class ASH_EXPORT SystemTray : public views::View,
public views::Widget::Observer {
public:
SystemTray();
virtual ~SystemTray();
// Adds a new item in the tray.
void AddTrayItem(SystemTrayItem* item);
// Removes an existing tray item.
void RemoveTrayItem(SystemTrayItem* item);
// Shows the default view of all items.
void ShowDefaultView();
// Shows details of a particular item. If |close_delay_in_seconds| is
// non-zero, then the view is automatically closed after the specified time.
void ShowDetailedView(SystemTrayItem* item,
int close_delay_in_seconds,
bool activate);
// Updates the items when the login status of the system changes.
void UpdateAfterLoginStatusChange(user::LoginStatus login_status);
const std::vector<SystemTrayItem*>& items() const { return items_; }
AudioObserver* audio_observer() const {
return audio_observer_;
}
BrightnessObserver* brightness_observer() const {
return brightness_observer_;
}
DateFormatObserver* date_format_observer() const {
return date_format_observer_;
}
NetworkObserver* network_observer() const {
return network_observer_;
}
PowerStatusObserver* power_status_observer() const {
return power_status_observer_;
}
UpdateObserver* update_observer() const {
return update_observer_;
}
private:
friend class Shell;
void ShowItems(std::vector<SystemTrayItem*>& items,
bool details,
bool activate);
// Overridden from views::View.
virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
// Overridden from views::Widget::Observer.
virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
std::vector<SystemTrayItem*> items_;
// The container for all the tray views of the items.
views::View* container_;
// These observers are not owned by the tray.
AudioObserver* audio_observer_;
BrightnessObserver* brightness_observer_;
DateFormatObserver* date_format_observer_;
NetworkObserver* network_observer_;
PowerStatusObserver* power_status_observer_;
UpdateObserver* update_observer_;
// The popup widget and the delegate.
internal::SystemTrayBubble* bubble_;
views::Widget* popup_;
DISALLOW_COPY_AND_ASSIGN(SystemTray);
};
} // namespace ash
#endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_
|