blob: f078a39f0e2686bb5c4bb2fab6974c7f0f8041bd [file] [log] [blame]
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +01001// 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.
4
5#ifndef ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_
6#define ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_
7
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"
Ben Murdochbb1529c2013-08-08 10:24:53 +010014#include "ui/message_center/notification_delegate.h"
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010015#include "ui/views/controls/button/button.h"
16#include "ui/views/controls/image_view.h"
17
18namespace views {
19class View;
20}
21
22namespace ash {
23namespace internal {
24
25class ScreenTrayItem;
26
27namespace tray {
28
29class ScreenTrayView : public TrayItemView {
30 public:
31 ScreenTrayView(ScreenTrayItem* screen_tray_item, int icon_id);
32 virtual ~ScreenTrayView();
33
34 void Update();
35
36 private:
37 ScreenTrayItem* screen_tray_item_;
38
39 DISALLOW_COPY_AND_ASSIGN(ScreenTrayView);
40};
41
42class ScreenStatusView : public views::View,
43 public views::ButtonListener {
44 public:
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010045 ScreenStatusView(ScreenTrayItem* screen_tray_item,
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010046 int icon_id,
47 const base::string16& label_text,
48 const base::string16& stop_button_text);
49 virtual ~ScreenStatusView();
50
51 // Overridden from views::View.
52 virtual void Layout() OVERRIDE;
53
54 // Overridden from views::ButtonListener.
55 virtual void ButtonPressed(views::Button* sender,
56 const ui::Event& event) OVERRIDE;
57
58 void CreateItems();
59 void Update();
60
61 private:
62 ScreenTrayItem* screen_tray_item_;
63 views::ImageView* icon_;
64 views::Label* label_;
65 TrayPopupLabelButton* stop_button_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010066 int icon_id_;
67 base::string16 label_text_;
68 base::string16 stop_button_text_;
69
70 DISALLOW_COPY_AND_ASSIGN(ScreenStatusView);
71};
72
Ben Murdochbb1529c2013-08-08 10:24:53 +010073class ScreenNotificationDelegate : public message_center::NotificationDelegate {
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010074 public:
Ben Murdochbb1529c2013-08-08 10:24:53 +010075 explicit ScreenNotificationDelegate(ScreenTrayItem* screen_tray);
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010076
Ben Murdochbb1529c2013-08-08 10:24:53 +010077 // message_center::NotificationDelegate overrides:
78 virtual void Display() OVERRIDE;
79 virtual void Error() OVERRIDE;
80 virtual void Close(bool by_user) OVERRIDE;
81 virtual void Click() OVERRIDE;
82 virtual void ButtonClick(int button_index) OVERRIDE;
83
84 protected:
85 virtual ~ScreenNotificationDelegate();
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010086
87 private:
Ben Murdochbb1529c2013-08-08 10:24:53 +010088 ScreenTrayItem* screen_tray_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010089
Ben Murdochbb1529c2013-08-08 10:24:53 +010090 DISALLOW_COPY_AND_ASSIGN(ScreenNotificationDelegate);
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010091};
92
93} // namespace tray
94
95
96// The base tray item for screen capture and screen sharing. The
97// Start method brings up a notification and a tray item, and the user
98// can stop the screen capture/sharing by pressing the stop button.
Ben Murdocheb525c52013-07-10 11:40:50 +010099class ASH_EXPORT ScreenTrayItem : public SystemTrayItem {
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100100 public:
101 explicit ScreenTrayItem(SystemTray* system_tray);
102 virtual ~ScreenTrayItem();
103
104 tray::ScreenTrayView* tray_view() { return tray_view_; }
105 void set_tray_view(tray::ScreenTrayView* tray_view) {
106 tray_view_ = tray_view;
107 }
108
109 tray::ScreenStatusView* default_view() { return default_view_; }
110 void set_default_view(tray::ScreenStatusView* default_view) {
111 default_view_ = default_view;
112 }
113
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100114 bool is_started() const { return is_started_; }
115 void set_is_started(bool is_started) { is_started_ = is_started; }
116
117 void Update();
118 void Start(const base::Closure& stop_callback);
119 void Stop();
120
Ben Murdochbb1529c2013-08-08 10:24:53 +0100121 // Creates or updates the notification for the tray item.
122 virtual void CreateOrUpdateNotification() = 0;
123
124 // Returns the id of the notification for the tray item.
125 virtual std::string GetNotificationId() = 0;
126
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100127 // Overridden from SystemTrayItem.
128 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE = 0;
129 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE = 0;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100130 virtual void DestroyTrayView() OVERRIDE;
131 virtual void DestroyDefaultView() OVERRIDE;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100132
133 private:
134 tray::ScreenTrayView* tray_view_;
135 tray::ScreenStatusView* default_view_;
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +0100136 bool is_started_;
137 base::Closure stop_callback_;
138
139 DISALLOW_COPY_AND_ASSIGN(ScreenTrayItem);
140};
141
142} // namespace internal
143} // namespace ash
144
145#endif // ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_