Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / system / chromeos / screen_security / screen_tray_item.h
blob9e5880d95fed821cef9ac30e2ac5676b69dcee15
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.
5 #ifndef ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_
6 #define ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_
8 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/system_tray_item.h"
10 #include "ash/system/tray/system_tray_notifier.h"
11 #include "ash/system/tray/tray_item_view.h"
12 #include "ash/system/tray/tray_notification_view.h"
13 #include "ash/system/tray/tray_popup_label_button.h"
14 #include "ui/message_center/notification_delegate.h"
15 #include "ui/views/controls/button/button.h"
16 #include "ui/views/controls/image_view.h"
18 namespace views {
19 class View;
22 namespace ash {
23 class ScreenTrayItem;
25 namespace tray {
27 class ScreenTrayView : public TrayItemView {
28 public:
29 ScreenTrayView(ScreenTrayItem* screen_tray_item, int icon_id);
30 virtual ~ScreenTrayView();
32 void Update();
34 private:
35 ScreenTrayItem* screen_tray_item_;
37 DISALLOW_COPY_AND_ASSIGN(ScreenTrayView);
40 class ScreenStatusView : public views::View,
41 public views::ButtonListener {
42 public:
43 ScreenStatusView(ScreenTrayItem* screen_tray_item,
44 int icon_id,
45 const base::string16& label_text,
46 const base::string16& stop_button_text);
47 virtual ~ScreenStatusView();
49 // Overridden from views::View.
50 virtual void Layout() OVERRIDE;
52 // Overridden from views::ButtonListener.
53 virtual void ButtonPressed(views::Button* sender,
54 const ui::Event& event) OVERRIDE;
56 void CreateItems();
57 void Update();
59 private:
60 ScreenTrayItem* screen_tray_item_;
61 views::ImageView* icon_;
62 views::Label* label_;
63 TrayPopupLabelButton* stop_button_;
64 int icon_id_;
65 base::string16 label_text_;
66 base::string16 stop_button_text_;
68 DISALLOW_COPY_AND_ASSIGN(ScreenStatusView);
71 class ScreenNotificationDelegate : public message_center::NotificationDelegate {
72 public:
73 explicit ScreenNotificationDelegate(ScreenTrayItem* screen_tray);
75 // message_center::NotificationDelegate overrides:
76 virtual void Display() OVERRIDE;
77 virtual void Error() OVERRIDE;
78 virtual void Close(bool by_user) OVERRIDE;
79 virtual void Click() OVERRIDE;
80 virtual void ButtonClick(int button_index) OVERRIDE;
82 protected:
83 virtual ~ScreenNotificationDelegate();
85 private:
86 ScreenTrayItem* screen_tray_;
88 DISALLOW_COPY_AND_ASSIGN(ScreenNotificationDelegate);
91 } // namespace tray
94 // The base tray item for screen capture and screen sharing. The
95 // Start method brings up a notification and a tray item, and the user
96 // can stop the screen capture/sharing by pressing the stop button.
97 class ASH_EXPORT ScreenTrayItem : public SystemTrayItem {
98 public:
99 explicit ScreenTrayItem(SystemTray* system_tray);
100 virtual ~ScreenTrayItem();
102 tray::ScreenTrayView* tray_view() { return tray_view_; }
103 void set_tray_view(tray::ScreenTrayView* tray_view) {
104 tray_view_ = tray_view;
107 tray::ScreenStatusView* default_view() { return default_view_; }
108 void set_default_view(tray::ScreenStatusView* default_view) {
109 default_view_ = default_view;
112 bool is_started() const { return is_started_; }
113 void set_is_started(bool is_started) { is_started_ = is_started; }
115 void Update();
116 void Start(const base::Closure& stop_callback);
117 void Stop();
119 // Creates or updates the notification for the tray item.
120 virtual void CreateOrUpdateNotification() = 0;
122 // Returns the id of the notification for the tray item.
123 virtual std::string GetNotificationId() = 0;
125 // Overridden from SystemTrayItem.
126 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE = 0;
127 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE = 0;
128 virtual void DestroyTrayView() OVERRIDE;
129 virtual void DestroyDefaultView() OVERRIDE;
130 virtual void UpdateAfterShelfAlignmentChange(
131 ShelfAlignment alignment) OVERRIDE;
133 private:
134 tray::ScreenTrayView* tray_view_;
135 tray::ScreenStatusView* default_view_;
136 bool is_started_;
137 base::Closure stop_callback_;
139 DISALLOW_COPY_AND_ASSIGN(ScreenTrayItem);
142 } // namespace ash
144 #endif // ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_